[Ajuda] Como colocar uma Tecla para ligar o motor...
#1

Preciso colocar Ctrl para ligar e desligar o motor dos carros, jб tentei tudo e nгo consigo... quem puder ajudar agradeзo!!!

public Startup(playerid, vehicleid)

PHP код:
    else if(IsPlayerInAnyVehicle(playerid) && !engineOn[vehicleid] && !vehicleEntered[playerid][vehicleid] && GetPlayerState(playerid) == PLAYER_STATE_DRIVER && !IsASalesVehicle(newcar))
    {
        
SendClientMessage(playeridCOLOR_GREEN"Atencao! Use /ingnicao ou pressione SHIFT para ligar o carro!");
        
TogglePlayerControllable(playeridfalse);
        
vehicleEntered[playerid][vehicleid] = true;
    } 

PHP код:
    if(!strcmp(cmd"/ingnicao"true))
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
IsPlayerInAnyVehicle(playerid))
            {
                new 
idcar GetPlayerVehicleID(playerid);
                if(!
engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(
GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(
pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                     if(
CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999 || IsASalesVehicle(idcar))
                        return 
SendClientMessage(playeridCOLOR_GREY,"* Voce nao pode ligar esse carro!");
                    
GetPlayerName(playeridsendernamesizeof(sendername));
                    
format(stringsizeof(string), "* %s gira a chave e tentar ligar o motor do veнculo."sendername);
                    
ProxDetector(30.0playeridstringCOLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5);
                    
SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
                    
GameTextForPlayer(playerid"~w~Dando ingnicao no carro...",3500,3);
                    
gEngine[playerid] = 1;
                    return 
1;
                }
                else if(
engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(
GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(
pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                    if(
CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
                        return 
SendClientMessage(playeridCOLOR_GREY,"* Voce nao pode desligar esse carro!");
                    
format(stringsizeof(string), "* %s gira a chave e desliga o motor do veнculo."sendername);
                    
ProxDetector(30.0playeridstringCOLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5);
                    
GameTextForPlayer(playerid"~w~Tirando a chave do carro.",3500,3);
                    
gEngine[playerid] = 0;
                    
TogglePlayerControllable(playerid0);
                    return 
1;
                }
            }
     }
        return 
1;
    } 
Reply
#2

poi em
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)

isso

pawn Код:
if (newkeys==KEY_SECONDARY_ATTACK) //key F ou Enter
{
OnPlayerCommandText(playerid, "/ingnicao");
return 1;
}
Reply
#3

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

if(newkeys & 16)//ID ta tecla quando aperta
{
   
if(!strcmp(cmd, "/ingnicao", true))
    {
        if(IsPlayerConnected(playerid))
        {
            if(IsPlayerInAnyVehicle(playerid))
            {
                new idcar = GetPlayerVehicleID(playerid);
                if(!engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                     if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999 || IsASalesVehicle(idcar))
                        return SendClientMessage(playerid, COLOR_GREY,"* Voce nao pode ligar esse carro!");
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    format(string, sizeof(string), "* %s gira a chave e tentar ligar o motor do veнculo.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5);
                    SetTimerEx("StartingTheVehicle",3500,0,"i",playerid);
                    GameTextForPlayer(playerid, "~w~Dando ingnicao no carro...",3500,3);
                    gEngine[playerid] = 1;
                    return 1;
                }
                else if(engineOn[GetPlayerVehicleID(playerid)])
                {
                    if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER) return 1;
                    if(pveh == 510 || pveh == 462 || pveh == 481 || pveh == 509) return 1;
                    if(CanTurnEngine[playerid] != idcar && CanTurnEngine[playerid] == 9999)
                        return SendClientMessage(playerid, COLOR_GREY,"* Voce nao pode desligar esse carro!");

                    format(string, sizeof(string), "* %s gira a chave e desliga o motor do veнculo.", sendername);
                    ProxDetector(30.0, playerid, string, COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5,COLOR_GRAD5);
                    GameTextForPlayer(playerid, "~w~Tirando a chave do carro.",3500,3);
                    gEngine[playerid] = 0;
                    TogglePlayerControllable(playerid, 0);
                    return 1;
                }
            }
     }
        return 1;
    }
Sempre usei assim numca tive erro copie desse topico ↓
https://sampforum.blast.hk/showthread.php?tid=286361
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)