Start engine with key
#1

PHP код:
COMMAND:mootor(playeridparams[])
{
    new 
string[128];
    if(
PlayerLoggedIn[playerid] == true)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
            if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
            {
                new 
vehicleid GetPlayerVehicleID(playerid);
                if(!
IsABike(vehicleid))
                {
                    if(
Mootor[vehicleid] == 0)
                    {
                        if(
IsAnyFactionVehicle(vehicleid))
                        {
                            if(
IsFactionVehicle(vehicleidKasutajaInfo[playerid][Grupeering]))
                            {
                                if(
K2ivitabMootorit[playerid] == 0)
                                {
                                    
format(stringsizeof(string), "* %s kдivitab sхiduki mootori."RPN(playerid));
                                    
SendEmotion(playeridstring);
                                    
SetTimerEx("StartVehicleEngine"1500false"i i"playeridvehicleid);
                                    
K2ivitabMootorit[playerid] = 1;
                                }
                                else 
SendClientMessage(playeridCOLOR_WHITE"Palun oota ennem jдrgmise mootori kaivitamist");
                            }
                            else 
SendClientMessage(playeridCOLOR_RED"See pole sinu masin!");
                        }
                        else if(
IsAnyJobVehicle(vehicleid))
                        {
                            if(
IsJobVehicle(vehicleidKasutajaInfo[playerid][Tookoht]))
                            {
                                if(
K2ivitabMootorit[playerid] == 0)
                                {
                                    
format(stringsizeof(string), "* %s kдivitab sхiduki mootori."RPN(playerid));
                                    
SendEmotion(playeridstring);
                                    
SetTimerEx("StartVehicleEngine"1500false"i i"playeridvehicleid);
                                    
K2ivitabMootorit[playerid] = 1;
                                }
                                else 
SendClientMessage(playeridCOLOR_WHITE"Palun oota ennem jдrgmise mootori kaivitamist");
                            }
                            else 
SendClientMessage(playeridCOLOR_RED"See pole sinu masin!");
                        }
                        else if(!
IsAnyFactionVehicle(vehicleid) && !IsAnyJobVehicle(vehicleid))
                        {
                              if(
MasinaInfo[vehicleid-FraksiMasinaidKokku][MasinOlemas] == 1)
                              {
                                  if(!
strcmp(MasinaInfo[vehicleid-FraksiMasinaidKokku][Omanik], RPNU(playerid), true))
                                  {
                                      if(
K2ivitabMootorit[playerid] == 0)
                                    {
                                        
format(stringsizeof(string), "* %s kдivitab sхiduki mootor."RPN(playerid));
                                        
SendEmotion(playeridstring);
                                        
SetTimerEx("StartVehicleEngine"1500false"i i"playeridvehicleid);
                                        
K2ivitabMootorit[playerid] = 1;
                                    }
                                    else 
SendClientMessage(playeridCOLOR_WHITE"Palun oota ennem jдrgmise mootori kaivitamist");
                                  }
                                  
/*else if(!strcmp(MasinaInfo[vehicleid-FraksiMasinaidKokku][VaruOmanik], RPNU(playerid), true))
                                  {
                                      if(K2ivitabMootorit[playerid] == 0)
                                    {
                                        format(string, sizeof(string), "* %s keerab oma masina varuvхtit ja ьritab kдivitada masina mootorit.", RPN(playerid));
                                        SendEmotion(playerid, string);
                                        SetTimerEx("StartVehicleEngine", 1500, false, "i i", playerid, vehicleid);
                                        K2ivitabMootorit[playerid] = 1;
                                    }
                                    else SendClientMessage(playerid, COLOR_GREY, "Palun oota ennem jдrgmise mootori kдivitamist!");
                                  }*/
                                  
else SendClientMessage(playeridCOLOR_RED"See pole sinu masin!");
                              }
                          }
                    }
                    else if(
Mootor[vehicleid] == 1)
                    {
                        new 
enginelightsalarmdoorsbonnetbootobjective;
                        
GetVehicleParamsEx(vehicleidenginelightsalarmdoorsbonnetbootobjective);
                        
Mootor[vehicleid] = 0;
                        
format(stringsizeof(string), "* %s suretab sхiduki mootori."RPN(playerid));
                        
SendEmotion(playeridstring);
                        
SetVehicleParamsEx(vehicleidfalselightsalarmdoorsbonnetbootobjective);
                    }
                }
                else 
SendClientMessage(playeridCOLOR_WHITE"VIGA: Jalgratastel pole mootorit");
            }
            else 
SendClientMessage(playeridCOLOR_WHITE"VIGA: Sa ei ole masina juht");
        }
        else 
SendClientMessage(playeridCOLOR_WHITE"VIGA: Sa pead olema mingis masinas");
    }
    else 
SendClientMessage(playeridCOLOR_WHITE"VIGA: Sa ei ole veel sisse loginud");
    return 
1;

Here's my /engine command, but i want to start engine with button '2' KEY_LOOK_BEHIND
Reply
#2

You should use the callback OnPlayerKeyStateChange for that.
Reply
#3

i know start, but what next i dont know, maybe anyone can give me a code? or just a little peace of code then i can learn it myself
Reply
#4

Quote:
Originally Posted by b00m112
Посмотреть сообщение
i know start, but what next i dont know, maybe anyone can give me a code? or just a little peace of code then i can learn it myself
Read the DAMN wiki.
Reply
#5

OnPlayerKeyStateChange

Код:
if(newkeys & PUT_YOYR_KEY_HERE)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        cmd_mootor(playerid, "");
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)