[Ajuda] Tecla pressionada
#1

Olб, eu criar botar paara o Player PRESSIONAR uma tecla, e fazer para ela.
  • Ligar o carro
  • Ligar o farol do carro
Bom, aqui estб a parte para ligar. Ele ta para apertar e ligar, eu queria que ele preciona-se para ligar.

PHP код:
if((newkeys == 128) && (IsPlayerInAnyVehicle(playerid)))
    {
        
OnPlayerCommandText(playerid"/motor");
        return 
1;
}
if ((
newkeys 4) && (IsPlayerInAnyVehicle(playerid)))
    {
        
OnPlayerCommandText(playerid"/farol");
        return 
1;
    }
    return 
1;

Se poder mudar a tecla "Espaзo" para ligar o carro para a tecla "Shift" agradeзo.
Reply
#2

so vc dar uma olhada e substituir pela desejada


@EDIT
Esta lista aki esta atualizada
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Reply
#3

Sim, trocar a tecla й o de menos, mais eu quero que o Player PRESSIONE a tecla para ligar o carro e o farol...
Reply
#4

No entiendo muy bien portugues. Pero aquн te dejo algo para que no haya errores futuros:
Код:
 
if((newkeys == 128) && (IsPlayerInAnyVehicle(playerid))) 
{ 
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(!engine) OnPlayerCommandText(playerid, "/motor"); 
        return 1; 
} 
if ((newkeys & 4) && (IsPlayerInAnyVehicle(playerid))) 
{ 
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(!lights) OnPlayerCommandText(playerid, "/farol"); 
        return 1; 
} 
return 1; 
}
and for the keys, is say in the topic


EDIT: Test this...
Код:
 
if((newkeys == 128) && (IsPlayerInAnyVehicle(playerid))) 
{ 
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(!engine) 
        {
              GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
              SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
        }
        else
        {
              GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
              SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
        }
        return 1; 
} 
if ((newkeys & 4) && (IsPlayerInAnyVehicle(playerid))) 
{ 
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(!lights)
        {
              GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
              SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
        }
        else
        {
              GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
              SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective);
        }
        return 1; 
} 
return 1; 
}
Reply
#5

Olб adi1, agora o comando nгo funcina.

Eu gostaria de dar um tempo pressionado para ligar o carro e o farol.

Obrigado.
Reply
#6

https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange.


Para ter que esperar, pode usar um SetTimerEx
Reply
#7

Quote:
Originally Posted by Fire_Hell
Посмотреть сообщение
Olб adi1, agora o comando nгo funcina.

Eu gostaria de dar um tempo pressionado para ligar o carro e o farol.

Obrigado.
Okay. This is:
on top:
Код:
new TimerToVehicleParams[MAX_PLAYER];
in OnPlayerKeyStateChange:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys == 128) && (IsPlayerInAnyVehicle(playerid))) 
{ 
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(!engine) 
        {
        TimerToVehicleParams[playerid] = SetTimerEx("ParamsVehicle", 3000, 0, "ii", playerid,1);
        SendClientMessage(playerid,-1,"On vehicle...");
        }
        else
        {
        TimerToVehicleParams[playerid] = SetTimerEx("ParamsVehicle", 3000, 0, "ii", playerid,2);
        SendClientMessage(playerid,-1,"Off vehicle...");
        }
        return 1; 
} 
if ((newkeys & 4) && (IsPlayerInAnyVehicle(playerid))) 
{ 
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
        if(!lights)
        {
              GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
              SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective);
        }
        else
        {
              GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
              SetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective);
        }
        return 1; 
} 
return 1; 
}
}
now in OnPlayerStateChange:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT) 
    {
    KillTimer(TimerToVehicleParams[playerid]);
    }
    return 1;
}
now abajo:
Код:
forward ParamsVehicle(playerid,type);
public ParamsVehicle(playerid,type)
{
if(type == 1)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
}
else if(type == 2)
{
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(GetPlayerVehicleID(playerid), VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
}
return 1;
}
Reply
#8

adri1 nгo й isto.

Bom, olha o que eu tentei.

PHP код:
    if (PRESSED(newkeys 4) && (IsPlayerInAnyVehicle(playerid)))
    {
        
OnPlayerCommandText(playerid"/farol");
        return 
1;
    }
    return 
1
Olha o erro que da.

PHP код:
error 017undefined symbol "PRESSED" 
Reply
#9

Quote:
Originally Posted by Fire_Hell
Посмотреть сообщение
PHP код:
error 017undefined symbol "PRESSED" 
On top:
PHP код:
#define PRESSED(%0) \
    
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0))) 
Reply
#10

Nгo funciono...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)