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



Trucker Error - DerickClark - 14.05.2013

i'm trying to add a mission text loading up the truck on the textdraw
with out GameText
Код:
error 003: declaration of a local variable must appear in a compound block
error 029: invalid expression, assumed zero
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Код:
// This function is called when a truckdriver enters a checkpoint
Trucker_OnPlayerEnterCheckpoint(playerid)
{
	// Check if the player is inside his vehicle while entering a checkpoint
	if (GetPlayerVehicleID(playerid) == APlayerData[playerid][VehicleID])
	{
		// Also check if the player still has his trailer attached
		if (APlayerData[playerid][TrailerID] == GetVehicleTrailer(GetPlayerVehicleID(playerid)))
		{
		    // Check the jobstep
		    switch (APlayerData[playerid][JobStep])
		    {
				// JobStep is 1 (truckdriver is loading his goods at the checkpoint)
		 		case 1:
				new RouteText[50];
                format(RouteText, 50, "Loading");
			    TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
				// JobStep is 2 (truckdriver is unloading his goods at the checkpoint) or 3 (unloading for convoys)
				case 2, 3: GameTextForPlayer(playerid, TXT_TruckerUnloadingGoods, 5000, 4);
		    }

			// Disable the player's actions (he cannot move anymore)
			TogglePlayerControllable(playerid, 0);
			// Start a timer (Public function "LoadUnload(playerid)" gets called when the timer runs out)
			APlayerData[playerid][LoadingTimer] = SetTimerEx("Trucker_LoadUnload", 5000, false, "d" , playerid);
		}
		else
		    SendClientMessage(playerid, 0xFFFFFFFF, TXT_NeedTrailerToProceed);
	}
	else
	    SendClientMessage(playerid, 0xFFFFFFFF, TXT_NeedVehicleToProceed);

	return 1;
}
The error in dis line

Код:
// Check the jobstep
		    switch (APlayerData[playerid][JobStep])
		    {
				// JobStep is 1 (truckdriver is loading his goods at the checkpoint)
		 		case 1:
				new RouteText[50];
                format(RouteText, 50, "Loading");
			    TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
				// JobStep is 2 (truckdriver is unloading his goods at the checkpoint) or 3 (unloading for convoys)
				case 2, 3: GameTextForPlayer(playerid, TXT_TruckerUnloadingGoods, 5000, 4);
		    }



Re: Trucker Error - RedForceFT - 14.05.2013

Try to replace this:

Код:
// Check the jobstep
		    switch (APlayerData[playerid][JobStep])
		    {
				// JobStep is 1 (truckdriver is loading his goods at the checkpoint)
		 		case 1:
				new RouteText[50];
                format(RouteText, 50, "Loading");
			    TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
				// JobStep is 2 (truckdriver is unloading his goods at the checkpoint) or 3 (unloading for convoys)
				case 2, 3: GameTextForPlayer(playerid, TXT_TruckerUnloadingGoods, 5000, 4);
		    }
With this:
Код:
// Check the jobstep
		    switch (APlayerData[playerid][JobStep])
		    {
		 		case 1;
                                {
				new RouteText[50];
                               format(RouteText, 50, "Loading");
			      TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
				}	
                               case 2;
                                {
                               GameTextForPlayer(playerid, TXT_TruckerUnloadingGoods, 5000, 4);
                               }
		    }



Re: Trucker Error - DerickClark - 14.05.2013

Still same errors.


Re: Trucker Error - RvGamers - 14.05.2013

You need to place a colon after case, not a semi-colon.

pawn Код:
switch (APlayerData[playerid][JobStep])
    {
        case 1:
        {
            new RouteText[50];
            format(RouteText, 50, "Loading");
            TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
        }  
        case 2:
        {
            GameTextForPlayer(playerid, TXT_TruckerUnloadingGoods, 5000, 4);
        }
    }



Re: Trucker Error - RedForceFT - 14.05.2013

Write exactly the line where appear the error please.


Re: Trucker Error - DerickClark - 14.05.2013

i still give the same error of diff codes i don't khow why.


Код:
// This function is called when a truckdriver enters a checkpoint
Trucker_OnPlayerEnterCheckpoint(playerid)
{
	// Check if the player is inside his vehicle while entering a checkpoint
	if (GetPlayerVehicleID(playerid) == APlayerData[playerid][VehicleID])
	{
		// Also check if the player still has his trailer attached
		if (APlayerData[playerid][TrailerID] == GetVehicleTrailer(GetPlayerVehicleID(playerid)))
		{
		    // Check the jobstep
		    switch (APlayerData[playerid][JobStep])
		    {
				// JobStep is 1 (truckdriver is loading his goods at the checkpoint)
		 		case 1:
		 		}
    	          new RouteText[50];
                  format(RouteText, 50, "Loading");
			      TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
			    }
				// JobStep is 2 (truckdriver is unloading his goods at the checkpoint) or 3 (unloading for convoys)
				case 2:
				}
				    GameTextForPlayer(playerid, TXT_TruckerUnloadingGoods, 5000, 4);
				}
		   	}
			// Disable the player's actions (he cannot move anymore)
			TogglePlayerControllable(playerid, 0);
			// Start a timer (Public function "LoadUnload(playerid)" gets called when the timer runs out)
			APlayerData[playerid][LoadingTimer] = SetTimerEx("Trucker_LoadUnload", 5000, false, "d" , playerid);
		}
		else
		    SendClientMessage(playerid, 0xFFFFFFFF, TXT_NeedTrailerToProceed);
	}
	else
	    SendClientMessage(playerid, 0xFFFFFFFF, TXT_NeedVehicleToProceed);

	return 1;
}



Re: Trucker Error - rebelgaming - 14.05.2013

pawn Код:
error 001: expected token: ";", but found "]"
Which line exactly gave you this error, if you tell me that I can figure out what happened because I need the exact line not all the lines just the one line it says that on, or does it say lines 200--300 like that?

Quote:

You need to place a colon after case, not a semi-colon.

The issue isn't a colon, its asking to find a semicolon not a bracket but its finding the bracket on that line at the end instead of the semicolon.


Re: Trucker Error - RedForceFT - 14.05.2013

I asked you to show me the line where the error appears.....


Re: Trucker Error - RvGamers - 14.05.2013

Quote:
Originally Posted by rebelgaming
Посмотреть сообщение
pawn Код:
error 001: expected token: ";", but found "]"
Which line exactly gave you this error, if you tell me that I can figure out what happened because I need the exact line not all the lines just the one line it says that on, or does it say lines 200--300 like that?



The issue isn't a colon, its asking to find a semicolon not a bracket but its finding the bracket on that line at the end instead of the semicolon.
I was correcting the error made by someone responding to the thread, not the original poster. I figure that if people are going to post improper code as a response in the first place that I may as well call them out for it.


Re: Trucker Error - rebelgaming - 14.05.2013

Quote:
Originally Posted by RvGamers
Посмотреть сообщение
I was correcting the error made by someone responding to the thread, not the original poster. I figure that if people are going to post improper code as a response in the first place that I may as well call them out for it.
True I must of missed that part when I skimmed over it. I do agree with that.

pawn Код:
TextDrawSetString(APlayerData[playerid][MissionText], RouteText);
pawn Код:
switch (APlayerData[playerid][JobStep])
Back to the matter at hand this is the only lines I could find with the ] issue because pawn normally shows the bracket depending on the bracket if its } this it will show } that. So I believe the issue is in this line. Unless he gave us the wrong 6-8 lines which really doesn't help simplify it lol.