OnPlayerStateChange function help.. - 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: OnPlayerStateChange function help.. (
/showthread.php?tid=476145)
OnPlayerStateChange function help.. -
EthanMason - 16.11.2013
Hello guys
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(newstate == PLAYER_STATE_DRIVER)
{
if(Engine[vehicleid] == 0)
{
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, COLOR_YELLOW, "((use /e to turn the vehicle engine on))");
if(newkeys & KEY_SECONDARY_ATTACK)
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
}
else if(Engine[vehicleid] == 1)
{
SendClientMessage(playerid, COLOR_YELLOW, "Engine Running...");
TogglePlayerControllable(playerid, 1);
}
}
}
return 1;
}
I'm recieving this error
pawn Код:
C:\Users\dell\Desktop\Script\gamemodes\hrp.pwn(682) : error 017: undefined symbol "newkeys"
C:\Users\dell\Desktop\Script\gamemodes\hrp.pwn(694) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
can someone help me out please
Re: OnPlayerStateChange function help.. -
Konstantinos - 16.11.2013
OnPlayerStateChange and OnPlayerKeyStateChange differ from each other.
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
if(!Engine[GetPlayerVehicleID(playerid)])
{
TogglePlayerControllable(playerid, 0);
SendClientMessage(playerid, COLOR_YELLOW, "((use /e to turn the vehicle engine on))");
}
else
{
TogglePlayerControllable(playerid, 1);
SendClientMessage(playerid, COLOR_YELLOW, "Engine Running...");
}
}
return 1;
}
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(newkeys & KEY_SECONDARY_ATTACK)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && !Engine[GetPlayerVehicleID(playerid)])
{
RemovePlayerFromVehicle(playerid);
TogglePlayerControllable(playerid, 1);
}
}
return 1;
}