HELP: case problem
#1

Код:
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"
Reply
#2

you didnt close the {} of the switch.

you closed the case CHECKPOINT_PROD2 then return 1 then closed the {} of public OnPlayerEnterCheckPoint?
Reply
#3

hmm how to fix then?

I need to add "}" this over/under the error line ?
Reply
#4

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


Forum Jump:


Users browsing this thread: 1 Guest(s)