[TuT] Kako napraviti sistem paljenja/gasenja automobila!

Započeo Dimi, Februar 14, 2013, 02:41:37 PRE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Kako napraviti sistem paljenja/gasenja automobila!

Kao sto sam naslov kaze danas cu vam pokazati kako napraviti sistem paljenja automobila

Na vrh skripte stavite
#include <a_samp>
#include <YSI\y_commands>


Zatim isto pri vrhu skripte
forward StartEngine(playerid);
new vehEngine[MAX_VEHICLES];
new engineOn[MAX_VEHICLES];


I Moracemo da definisemo boje koje ce nam biti potrebne u sistemu
#define LJUBICASTA                  0xC2A2DAAA
#define BELA     0xFFFFFFAA


Pod public OnPlayerStateChange stavite
new vehicleid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER) // oznacava kada se igraca nalazi u vozilu kao vozac
        {
            if(vehEngine[vehicleid] == 0) // ako je motor ugasen i i grac udje u vozilo izbaci mu ovaj text dole u SCM
            {
                TogglePlayerControllable(playerid, 0);
                SCM(playerid, BELA, "{00C0FF}Da upalis/ugasis vozilo kucaj /engine!");
                }
                else if(vehEngine[vehicleid] == 1) // ako je vozilo upaljeno izbacuje ovaj text dole u SCM
                {
                    TogglePlayerControllable(playerid, 1);
                    SCM(playerid, BELA, "{00C0FF}Vozilo upaljeno!");
                }
        }


Zatim pravimo public StartEngine
public StartEngine(playerid) // predstavlja timer i pokusaje da li se motor upalio ili nije
{
    new RandomStart;
    RandomStart = random(4);  // ovim stavljamo pokusaje na random ne po redu
    new vehicleid = GetPlayerVehicleID(playerid);
    if(IsPlayerInAnyVehicle(playerid))
        {
            if(vehEngine[vehicleid] == 1)
            {
                switch(RandomStart)
                {
                             case 0,1,2: //Kada se motor upali
                              {
                                         new string[128];
                                         new sendername[MAX_PLAYER_NAME];
                                         GetPlayerName(playerid, sendername, sizeof(sendername));
vehEngine[vehicleid] = 1; // paljenje motora
                                         TogglePlayerControllable(playerid, 1); //pokretljivost igraca
                                         format(string, sizeof(string), "* Motor se upalio (( %s )).", sendername); // text
                                         ProxDetector(30.0, playerid, string, LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA);
                                }
                                case 3: // Kada se motor nije upalio
                                {
                                    new string[128];
    new sendername[MAX_PLAYER_NAME];
    vehEngine[vehicleid] = 0;
                                    TogglePlayerControllable(playerid, 0); // Daje nepokretljivost igracu
                                    GetPlayerName(playerid, sendername, sizeof(sendername));
    format(string, sizeof(string), "* Motor se nije upalio (( %s )).", sendername); // text koji izbacuje
   ProxDetector(30.0, playerid, string, LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA);
                                }
                        }
                }
                else
{
    vehEngine[vehicleid] = 0;
}
    }
        return 1;
}


Onda pod public onplayerexitvehicle stavimo //  Kada igrac izadje iz vozila
TogglePlayerControllable(playerid, 1); // daje pokretljivost igracu

I na kraju kreiramo komandu kojom cemo paliti vozilo
YCMD:engine(playerid, params[], help)
{
    #pragma unused help
    #pragma unused params -
    new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid)) // ako je igrac u vozilu
        {
            if(vehEngine[vehicleid] == 0) // ako je motor vozila ugasen
            {
                                new string[128];
new sendername[MAX_PLAYER_NAME];
                                new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        SetVehicleParamsEx(GetPlayerVehicleID(playerid), 1, 0, alarm, doors, bonnet, boot, objective); // ovime dobijamo da motor bude ugasen tj da ne ide dim iz auspuha
GetPlayerName(playerid, sendername, sizeof(sendername));
vehEngine[vehicleid] = 1;
                                SetTimerEx("StartEngine", 3000, 0, "i", playerid);
                                format(string, sizeof(string), "* %s okrece kljuc i pokusava da upali motor.", sendername); // text
        ProxDetector(30.0, playerid, string, LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA);
                                GameTextForPlayer(playerid, "~w~Motor se pokrece...",3500,3);
                                engineOn[GetPlayerVehicleID(playerid)] == 1;
}
else if(vehEngine[vehicleid] == 1) // ako je motor uplaljen
                       {

                                new string[128];
new sendername[MAX_PLAYER_NAME];
                                new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(GetPlayerVehicleID(playerid), 0, 0, alarm, doors, bonnet, boot, objective); // sada ovim postizemo da se motor ugasi tj da ne ide dim iz auspuha
vehEngine[vehicleid] = 0; // motor ugasen
                                TogglePlayerControllable(playerid, 0); // nepokretiljivost igraca
GetPlayerName(playerid, sendername, sizeof(sendername));
                                format(string, sizeof(string), "* %s okrece kljuc i gasi motor.", sendername); // text
ProxDetector(30.0, playerid, string, LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA,LJUBICASTA);
}
        }
   return 1;
}


Ako neko ima nekih problema neka napise u temu .. bice odg u najkracem roku...
Poslednja Izmena: Februar 21, 2013, 20:38:34 POSLE PODNE od Dimi


Hvala svima .. :D Radio sam u 3 ujutru na oci nisam video pa me mrzelo da objasnjavam sve funkcije posebno :D veceras cu edit :D


Citat: Dude from Prokuplje poslato Februar 14, 2013, 09:33:11 PRE PODNE
Ne razumem se u skriptanje,ali ovo je super. Samo napred...
ti si kralj

ovi kodovi su cini mi se ispravni, ali ti brate nista nisi objasnio,  samo si dao gotove kodove, 2/10

Ako bi mi mogao reci kako jos na ovo da dodam da se posle nekog vremena ugase sva kola i kad bi mi mogao reci kako da napravim komandu da se sva kola isto ugase u isto vreme

Citat: Blaeks poslato Februar 14, 2013, 19:52:31 POSLE PODNE
Citat: Dude from Prokuplje poslato Februar 14, 2013, 09:33:11 PRE PODNE
Ne razumem se u skriptanje,ali ovo je super. Samo napred...
ti si kralj

ovi kodovi su cini mi se ispravni, ali ti brate nista nisi objasnio,  samo si dao gotove kodove, 2/10

pocetnicima ce pomoci mrzelo me da pisem...





C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1866) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1867) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1868) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1869) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1871) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1873) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1874) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : error 017: undefined symbol "engineOn"
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : error 001: expected token: ";", but found "]"
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : error 029: invalid expression, assumed zero
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

:D Å¡ta je ovo,svi postove skupljate,vidis da pola tog nisi reko da treba sta da se ubaci
NEW NEW NEW

Team Fortress od sada i na SA:MP-u!!!
Dodite i zabavite se!

IP: 62.210.122.191:7789

Dobar tutorial ! Posluzit ce .
☢Novica.☢R.I.P DRAŽEN PETROVIĆ☢


Citat: Loupa poslato Februar 21, 2013, 15:54:14 POSLE PODNE

C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1866) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1867) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1868) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1869) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1871) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1873) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1874) : warning 217: loose indentation
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : error 017: undefined symbol "engineOn"
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : error 001: expected token: ";", but found "]"
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : error 029: invalid expression, assumed zero
C:\Users\PC\Desktop\DD-Derby by Alen!\DD-Derby by Alen\gamemodes\dm-stunt.pwn(1875) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.

:D Å¡ta je ovo,svi postove skupljate,vidis da pola tog nisi reko da treba sta da se ubaci

eo ovo stavi na veh skripte zab sam sad sam edit
new engineOn[MAX_VEHICLES];


Hvala ostalima