Engine
#1

I made this engine function (in a command):

pawn Код:
switch (GetEngineStatus(vehicleid))
        {
            case false:
            {
                new rand = random(3);
                if(rand != 0)
                {
                    PlayNearbySound(playerid, 11200);
                    SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
                    SetEngineStatus(vehicleid, true);
                    SendNearbyMessage(playerid, 10.0, COLOR_FACTION, "* %s inserts the key into the ignition lock and starts the engine of %s %s.", ReturnName(playerid, 0), CheckSex(playerid), ReturnVehicleName(vehicleid));
                }
                else
                {
                    GameTextForPlayer(playerid, "~r~ENGINE COULDN'T STARTED~n~~w~Try it again!", 3000, 4);
                }
            }
            case true:
            {
                SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
                SetEngineStatus(vehicleid, false);
                SendNearbyMessage(playerid, 10.0, COLOR_FACTION, "* %s leaves the key from ignition lock and stops the engine of %s %s.", ReturnName(playerid, 0), CheckSex(playerid), ReturnVehicleName(vehicleid));
            }
            }
        }
But i'm getting this:

Quote:

error 040: duplicate "case" label (value 7)
error 040: duplicate "case" label (value 8 )

Reply
#2

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
I made this engine function (in a command):

pawn Код:
switch (GetEngineStatus(vehicleid))
        {
            case false:
            {
                new rand = random(3);
                if(rand != 0)
                {
                    PlayNearbySound(playerid, 11200);
                    SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
                    SetEngineStatus(vehicleid, true);
                    SendNearbyMessage(playerid, 10.0, COLOR_FACTION, "* %s inserts the key into the ignition lock and starts the engine of %s %s.", ReturnName(playerid, 0), CheckSex(playerid), ReturnVehicleName(vehicleid));
                }
                else
                {
                    GameTextForPlayer(playerid, "~r~ENGINE COULDN'T STARTED~n~~w~Try it again!", 3000, 4);
                }
            }
            case true:
            {
                SetPVarInt(playerid,"CmdTime",GetTickCount()+5000);
                SetEngineStatus(vehicleid, false);
                SendNearbyMessage(playerid, 10.0, COLOR_FACTION, "* %s leaves the key from ignition lock and stops the engine of %s %s.", ReturnName(playerid, 0), CheckSex(playerid), ReturnVehicleName(vehicleid));
            }
            }
        }
But i'm getting this:
Your code has an extra "}"
Reply
#3

I know someone would have said that. The problem is not the extra bracket because if i remove it i get a lot of general errors. So problem shouldn't be there.
Reply
#4

Maybe, "case 0:" and "case 1:"?
Reply
#5

You could have defined the case id already (this true and false case are duplicate of it). So, change the dialog id of cases true and false.

Код:
#define true 222
#define false 223
Reply
#6

Because "true" and "false" are already defined as part of boolean!
Reply
#7

Quote:
Originally Posted by KinderClans
Посмотреть сообщение
I know someone would have said that. The problem is not the extra bracket because if i remove it i get a lot of general errors. So problem shouldn't be there.
Remove that curly bracket and fix those "general errors" or post them here. The error says you are using same value multiple times in a switch block.
Reply
#8

Fixed. The code was fine, the error was referring to OnPlayerTakeDamage which i had double case 7 - case 8.

Thank you everyone.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)