SA-MP Forums Archive
Engine - 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: Engine (/showthread.php?tid=659555)



Engine - KinderClans - 06.10.2018

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 )




Re: Engine - Leaky - 06.10.2018

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 "}"


Re: Engine - KinderClans - 06.10.2018

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.


Re: Engine - Undef1ned - 07.10.2018

Maybe, "case 0:" and "case 1:"?


Re: Engine - UFF - 07.10.2018

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



Re: Engine - Gammix - 07.10.2018

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


Re: Engine - SyS - 07.10.2018

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.


Re: Engine - KinderClans - 07.10.2018

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

Thank you everyone.