ONPlayerExitMenu() - 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: ONPlayerExitMenu() (
/showthread.php?tid=316494)
ONPlayerExitMenu() -
Shabi RoxX - 07.02.2012
Hi guys , Am making ONPlayerExitMenu() That if Player Current Menu is Some thing ShowPlayerMenu...
But its Crashes Server
Код:
public OnPlayerExitedMenu(playerid)
{
new Menu:Current = GetPlayerMenu(playerid);
if(Current == FW_H_Tunning || Current == FW_S_Tunning || Current == FW_R_Tunning || Current == FW_BW_Tunning)
{
ShowMenuForPlayer(FW_Tunning,playerid);
}
else if(Current == FW_Tunning)
{
TogglePlayerControllable(playerid,1);
}
return 1;
}
How to do this?
Re: ONPlayerExitMenu() -
thimo - 07.02.2012
Try using cases instead of the || symbols like switch(Current)
Re: ONPlayerExitMenu() -
Konstantinos - 07.02.2012
You can't use variables with
switch. You have to use
else if.
Even if the variables are global, you will still get errors for:
pawn Код:
must be a constant expression; assumed zero
Re: ONPlayerExitMenu() -
Shabi RoxX - 07.02.2012
NeverMind , I was Forgeting to /reloadFS as these codes are in FS,
Re: ONPlayerExitMenu() -
Wesley221 - 07.02.2012
You can use a switch with variables:
pawn Код:
switch( Current )
{
case FW_H_TUNING, FW_S_TUNING: // etc etc
{
}
case FW_Tuning:
{
}
default: // none of those above
{
}
}
Re: ONPlayerExitMenu() -
Konstantinos - 07.02.2012
Quote:
Originally Posted by Wesley221
You can use a switch with variables:
pawn Код:
switch( Current ) { case FW_H_TUNING, FW_S_TUNING: // etc etc { } case FW_Tuning: { } default: // none of those above { } }
|
You can't Wesley and to proove it.
The result:
pawn Код:
error 008: must be a constant expression; assumed zero
pawn Код:
#include < a_samp >
new
Menu:FW_H_Tunning, Menu:FW_R_Tunning, Menu:FW_BW_Tunning, Menu:FW_Tunning, Menu:FW_S_Tunning;
public OnPlayerExitedMenu( playerid )
{
new Menu:Current = GetPlayerMenu( playerid );
switch( Current )
{
case FW_H_Tunning, FW_S_Tunning, FW_R_Tunning, FW_BW_Tunning: ShowMenuForPlayer( FW_Tunning, playerid );
case FW_Tunning: TogglePlayerControllable( playerid, 1 );
}
return 1;
}
Re: ONPlayerExitMenu() -
Wesley221 - 07.02.2012
Then it must be because of the Menu:, with normal variables it should work.