This is funny,BUT I need help with it!!! - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: This is funny,BUT I need help with it!!! (
/showthread.php?tid=251238)
This is funny,BUT I need help with it!!! -
Cjgogo - 26.04.2011
I made this engine system:
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
ToggleEngine(playerid);
SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
}
if((newkeys == KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid)))
{
ToggleEngine(playerid);
SendClientMessage(playerid,BLUE,"The engine is turned on");
}
return 1;
}
No compiling errors,and in game it's working,only 1 bug that all the chat is spammed with:"press 2 to turn engine on." How to solve that?
Re: This is funny,BUT I need help with it!!! -
xDeadlyBoy - 26.04.2011
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if((newkeys == KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid)))
{
ToggleEngine(playerid);
SendClientMessage(playerid,BLUE,"The engine is turned on");
}
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
ToggleEngine(playerid);
SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
}
}
Re: This is funny,BUT I need help with it!!! -
Cjgogo - 26.04.2011
Thansk
Re: This is funny,BUT I need help with it!!! -
Steven82 - 26.04.2011
Quote:
Originally Posted by xDeadlyBoy
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if((newkeys == KEY_SUBMISSION) && (IsPlayerInAnyVehicle(playerid))) { ToggleEngine(playerid); SendClientMessage(playerid,BLUE,"The engine is turned on"); } return 1; }
public OnPlayerStateChange(playerid, newstate, oldstate) { if(newstate == PLAYER_STATE_DRIVER) { ToggleEngine(playerid); SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on"); } }
|
You helping him didn't fix it, it bugged it. The ToggleEngine should only be called once, and thats when the key is pressed not when they enter the vehicle as a driver...think next time.
Re: This is funny,BUT I need help with it!!! -
xDeadlyBoy - 26.04.2011
oops, you right...
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
SendClientMessage(playerid,GREEN,"Press 2 to turn the engine on");
}
}