SA-MP Forums Archive
error 008 problem with switch(playerid) - 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: error 008 problem with switch(playerid) (/showthread.php?tid=385969)



error 008 problem with switch(playerid) - niels44 - 18.10.2012

hey everyone,

i made this switch for my GM but somehow it gives me errors and i dont know why...

pawn Код:
WaitForBot( playerid, menu, action[] )
{
    PlayerInfo[playerid][botready] = false;
    switch(playerid)
    {
        case FirstRaceBot:
        {
            SendClientMessage(FirstRaceBot, COLOR_GREEN, action );
        }
        case FirstFightBot:
        {
            SendClientMessage(FirstFightBot, COLOR_GREEN, action );
        }
        case SecondFightBot:
        {
            SendClientMessage(SecondFightBot, COLOR_GREEN, action );
        }
    }
    PlayerInfo[playerid][waitingforbot] = SetTimerEx("WaitForBotTimer",250,true,"dd",playerid,menu );
    return 1;
}
i get these errors:
pawn Код:
D:\Program Files\High Speed Drivers\gamemodes\HighSpeedDrivers.pwn(721) : error 008: must be a constant expression; assumed zero
D:\Program Files\High Speed Drivers\gamemodes\HighSpeedDrivers.pwn(725) : error 008: must be a constant expression; assumed zero
D:\Program Files\High Speed Drivers\gamemodes\HighSpeedDrivers.pwn(729) : error 008: must be a constant expression; assumed zero
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
any idea of how it is possible those errors? and the lines of the errors are:
pawn Код:
case FirstRaceBot:
case FirstFightBot:
case SecondFightBot:
thats my code and errors, but does anybody sees wut im doing wrong?

greets niels


Re: error 008 problem with switch(playerid) - gtakillerIV - 18.10.2012

Try to use "if" statements. Because you can't use variables with switch. So use else if.


Re: error 008 problem with switch(playerid) - Red_Dragon. - 18.10.2012

Try to use if or else


Re: error 008 problem with switch(playerid) - niels44 - 18.10.2012

hmm ye i did that before, and it worked, but i didnt knew this couldnt be used with variables, anyways thnx


Re: error 008 problem with switch(playerid) - Kirollos - 18.10.2012

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
Try to use "if" statements. Because you can't use variables with switch. So use else if.
oh my god.

switch works with variables..


Re: error 008 problem with switch(playerid) - gtakillerIV - 18.10.2012

Thanks for the info then I read on some site that you can't use them with variables