HELP: case problem - 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: HELP: case problem (
/showthread.php?tid=346399)
HELP: case problem -
Jimbo01 - 28.05.2012
Код:
public OnPlayerEnterCheckpoint(playerid)
{
new newcar = GetPlayerVehicleID(playerid);
switch (gPlayerCheckpointStatus[playerid])
{
case CHECKPOINT_PROD1:
{
if(newcar >= 108 && newcar <= 111 && IsTrailerAttachedToVehicle(newcar))
//if(IsTrailerAttachedToVehicle(newcar) && GetVehicleTrailer(newcar) == >= 108 && <= 111)
{
DisablePlayerCheckpoint(playerid);
PlayerPlaySound(playerid, 1059, 0.0, 0.0, 0.0);
TogglePlayerControllable(playerid,false);
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~obtaining the package, please wait",4000,3);
SetTimerEx("Product1", 3000, false, "i", playerid);
}
else
{
SendClientMessage(playerid,COLOR_YELLOW,"You are not inside a Truck with a Trailer.");
}
}
case CHECKPOINT_PROD2:
{
if(newcar >= 108 && newcar <= 111 && IsTrailerAttachedToVehicle(newcar))
{
DisablePlayerCheckpoint(playerid);
TogglePlayerControllable(playerid,false);
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Delivering the package, please wait",4000,3);
SetTimerEx("Product2", 2000, false, "i", playerid);
}
else
{
SendClientMessage(playerid,COLOR_YELLOW,"You are not inside a Truck with a Trailer.");
}
}
return 1; <-------- ERROR LINE
}
Код:
Error: error 002: only a single statement (or expression) can follow each "case"
Re: HELP: case problem -
Kirollos - 28.05.2012
you didnt close the {} of the switch.
you closed the case CHECKPOINT_PROD2 then return 1 then closed the {} of public OnPlayerEnterCheckPoint?
AW: HELP: case problem -
Jimbo01 - 28.05.2012
hmm how to fix then?
I need to add "}" this over/under the error line ?
Re: HELP: case problem -
Kirollos - 28.05.2012
it should be like this:
pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
new newcar = GetPlayerVehicleID(playerid);
switch (gPlayerCheckpointStatus[playerid])
{
case CHECKPOINT_PROD1:
{
if(newcar >= 108 && newcar <= 111 && IsTrailerAttachedToVehicle(newcar))
//if(IsTrailerAttachedToVehicle(newcar) && GetVehicleTrailer(newcar) == >= 108 && <= 111)
{
DisablePlayerCheckpoint(playerid);
PlayerPlaySound(playerid, 1059, 0.0, 0.0, 0.0);
TogglePlayerControllable(playerid,false);
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~obtaining the package, please wait",4000,3);
SetTimerEx("Product1", 3000, false, "i", playerid);
}
else
{
SendClientMessage(playerid,COLOR_YELLOW,"You are not inside a Truck with a Trailer.");
}
}
case CHECKPOINT_PROD2:
{
if(newcar >= 108 && newcar <= 111 && IsTrailerAttachedToVehicle(newcar))
{
DisablePlayerCheckpoint(playerid);
TogglePlayerControllable(playerid,false);
GameTextForPlayer(playerid,"~w~~n~~n~~n~~n~~n~~n~~n~~n~~n~Delivering the package, please wait",4000,3);
SetTimerEx("Product2", 2000, false, "i", playerid);
}
else
{
SendClientMessage(playerid,COLOR_YELLOW,"You are not inside a Truck with a Trailer.");
}
}
}
return 1;
}