SA-MP Forums Archive
OnPlayerKey - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: OnPlayerKey (/showthread.php?tid=647238)



OnPlayerKey - Thanks - 01.01.2018

Код:
error 029: invalid expression, assumed zero
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
playerState GetPlayerState(PLAYER_STATE_DRIVER); // Get the killer's state
    
if(PRESSED(KEY_LOOK_BEHIND)
    {
        if(
playerState == PLAYER_STATE_DRIVER)
        {
            
RepairVehicle(Infernus[0]);
        }
    }
    return 
1;

??


Re: OnPlayerKey - FailerZ - 01.01.2018

You have forgot one closing bracket
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) 
{ 
    new playerState = GetPlayerState(PLAYER_STATE_DRIVER); // Get the killer's state 
    if(PRESSED(KEY_LOOK_BEHIND)) //<<< Here
    { 
        if(playerState == PLAYER_STATE_DRIVER) 
        { 
            RepairVehicle(Infernus[0]); 
        } 
    } 
    return 1; 
}



Re: OnPlayerKey - Thanks - 01.01.2018

Ups, Thank you. #Fixed +rep


Re: OnPlayerKey - ThePhenix - 01.01.2018

Quote:
Originally Posted by Thanks
Посмотреть сообщение
Код:
error 029: invalid expression, assumed zero
PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    new 
playerState GetPlayerState(PLAYER_STATE_DRIVER); // Get the killer's state
    
if(PRESSED(KEY_LOOK_BEHIND)
    {
        if(
playerState == PLAYER_STATE_DRIVER)
        {
            
RepairVehicle(Infernus[0]);
        }
    }
    return 
1;

??
This part is wrong as well, it should be
PHP код:
GetPlayerState(playerid); 



Re: OnPlayerKey - Abagail - 01.01.2018

Another thing: new playerState can simply go below PRESSED (assuming it's not needed further in the callback) as it's only used in that specific condition. For more optimization, you could also simply do: GetPlayerState(playerid) == P.... This will help get into better coding practice but to each their own.