OnPlayerKey
#1

Код:
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;

??
Reply
#2

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; 
}
Reply
#3

Ups, Thank you. #Fixed +rep
Reply
#4

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); 
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)