ONPlayerExitMenu()
#1

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?
Reply
#2

Try using cases instead of the || symbols like switch(Current)
Reply
#3

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
Reply
#4

NeverMind , I was Forgeting to /reloadFS as these codes are in FS,
Reply
#5

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
    {
   
    }
}
Reply
#6

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

Then it must be because of the Menu:, with normal variables it should work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)