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



CMd Problem - yaron0600 - 08.01.2013

Hey there's an problem here in that cmd : I'm trying to add any vehicle's of everyone can have it from planes : Dodo - 530 , Shamal - 519 , Nevada - 553 , Andromanda - 592... Now there's error's :

Код:
d:\Users\User\Desktop\Np\GodFather Roleplay\gamemodes\IC2.pwn(104959) : error 020: invalid symbol name ""
d:\Users\User\Desktop\Np\GodFather Roleplay\gamemodes\IC2.pwn(104959) : error 036: empty statement
d:\Users\User\Desktop\Np\GodFather Roleplay\gamemodes\IC2.pwn(104959) : error 017: undefined symbol "i"
d:\Users\User\Desktop\Np\GodFather Roleplay\gamemodes\IC2.pwn(104959) : fatal error 107: too many error messages on one line

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


4 Errors.


Here's the CMD :

Код:
CMD:loadplane(playerid, params[]) {
	new vehicleid = GetPlayerVehicleID(playerid);
	if(vehicleid == 592 || vehicleid == 519 ||vehicleid == 553||vehicleid == 593 || GetVehicleModel(vehicleid) == 530)
	{
		if(CrateVehicleLoad[vehicleid][vForkLoaded])
		{
		    new PlaneFound, FreeSlot, string[128];
		    PlaneFound = INVALID_VEHICLE_ID;
		    FreeSlot = -1;
		    new Float:vx, Float:vy, Float:vz;
		    for(new i = 0; i < sizeof(519,553,593,530); i++)
		    {
		        GetVehiclePos(519,553,593,530[i], vx, vy, vz);
		        vy -= float(12);
				if(IsPlayerInRangeOfPoint(playerid, 6, vx, vy, vz))
		        {
		            if(GetVehicleModel(CrateIslandVehicles[i]) == 592)
		            {
						PlaneFound = 519,553,593,530[i];
						break;
				    }
		        }
		    }
		    if(PlaneFound != INVALID_VEHICLE_ID)
		    {
			    for(new i = 0; i < 6; i++)
			    {
			        if(CrateVehicleLoad[PlaneFound][vCrateID][i] == -1)
			        {
						FreeSlot = i;
						break;
			        }
			    }
			}
			if(PlaneFound == INVALID_VEHICLE_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not near a plane!");
			if(FreeSlot == -1) return SendClientMessageEx(playerid, COLOR_GRAD2, "The Plane is fully loaded!");
		    DestroyObject(CrateVehicleLoad[vehicleid][vForkObject]);
		    CrateVehicleLoad[vehicleid][vForkLoaded] = 0;
			CrateVehicleLoad[PlaneFound][vCrateID][FreeSlot] = CrateVehicleLoad[vehicleid][vCrateID][0];
		    CrateVehicleLoad[vehicleid][vCrateID][0] = -1;
		    SendClientMessageEx(playerid, COLOR_GRAD2, "You loaded a crate onto the plane!");
		}
		else
		{

		    SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a crate loaded!");
		    return 1;

		}
	}
	else
	{
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not in a forklift!");
	}
	return 1;
}



Re: CMd Problem - RedCrossER - 08.01.2013

Which is that line?


Re: CMd Problem - yaron0600 - 09.01.2013

for(new i = 0; i < sizeof(519,553,593,530); i++) That's the line...


Re: CMd Problem - Avi Raj - 09.01.2013

replace for(new i = 0; i < sizeof(519,553,593,530); i++)
with
pawn Код:
for(new playerid = 0; playerid < sizeof(519,553,593,530); playerid++)



Re: CMd Problem - Konstantinos - 09.01.2013

This is not the correct way to use more than 1 case. You cannot separate them with ",", like the following:
pawn Код:
sizeof(519,553,593,530)
pawn Код:
GetVehiclePos(519,553,593,530[i], vx, vy, vz);
pawn Код:
PlaneFound = 519,553,593,530[i];
Explain, what do you want to do please.

Quote:
Originally Posted by Thour57
Посмотреть сообщение
replace for(new i = 0; i < sizeof(519,553,593,530); i++)
with
pawn Код:
for(new playerid = 0; playerid < sizeof(519,553,593,530); playerid++)
No, by changing the variable's name will not solve the problem.


Re: CMd Problem - yaron0600 - 09.01.2013

Ty very much Dawyne I'm beginner I actually don't know where to put each can u transfer here all the new CMD ?


Re: CMd Problem - Konstantinos - 09.01.2013

I will try if you tell me what do you want to do with the for loop and these model IDs. Also, about the lines I mentioned on my previous post.


Re: CMd Problem - yaron0600 - 09.01.2013

Look I'll give u the cmd there's problem : If I near Plane and I want to /loadplane the plane of Andromanda in that cmd : THat's bugged ! Thats write : "You're not near a plane" Just fix it !

Код:
CMD:loadplane(playerid, params[])
{
	new vehicleid = GetPlayerVehicleID(playerid);
	if(vehicleid == CrateIslandVehicles[2] || vehicleid == CrateIslandVehicles[3] ||vehicleid == CrateIslandVehicles[4] || GetVehicleModel(vehicleid) == 530)
	{
		if(CrateVehicleLoad[vehicleid][vForkLoaded])
		{
		    new PlaneFound, FreeSlot;
		    PlaneFound = INVALID_VEHICLE_ID;
		    FreeSlot = -1;
		    new Float:vx, Float:vy, Float:vz;
		    for(new i = 0; i < sizeof(CrateIslandVehicles); i++)
		    {
		        GetVehiclePos(CrateIslandVehicles[i], vx, vy, vz);
		        //vy -= float(12); X
				if(IsPlayerInRangeOfPoint(playerid, 16, vx, vy, vz))
		        {
		            if(GetVehicleModel(CrateIslandVehicles[i]) == 592 || GetVehicleModel(CrateIslandVehicles[i]) == 519 || GetVehicleModel(CrateIslandVehicles[i]) == 523 || GetVehicleModel(CrateIslandVehicles[i]) == 593)
		            {
						PlaneFound = CrateIslandVehicles[i];
						break;
				    }
		        }
		    }
		    if(PlaneFound != INVALID_VEHICLE_ID)
		    {
			    for(new i = 0; i < 6; i++)
			    {
			        if(CrateVehicleLoad[PlaneFound][vCrateID][i] == -1)
			        {
						FreeSlot = i;
						break;
			        }
			    }
			}
			if(PlaneFound == INVALID_VEHICLE_ID) return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not near a plane!");
			if(FreeSlot == -1) return SendClientMessageEx(playerid, COLOR_GRAD2, "The Plane is fully loaded!");
		    DestroyObject(CrateVehicleLoad[vehicleid][vForkObject]);
		    CrateVehicleLoad[vehicleid][vForkLoaded] = 0;
			CrateVehicleLoad[PlaneFound][vCrateID][FreeSlot] = CrateVehicleLoad[vehicleid][vCrateID][0];
		    CrateVehicleLoad[vehicleid][vCrateID][0] = -1;
		    SendClientMessageEx(playerid, COLOR_GRAD2, "You loaded a crate onto the plane!");
		}
		else
		{

		    SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have a crate loaded!");
		    return 1;

		}
	}
	else
	{
	    return SendClientMessageEx(playerid, COLOR_GRAD2, "You're not in a forklift!");
	}
	return 1;
}



Re: CMd Problem - InActtive™ - 10.01.2013

Try this:

pawn Код:
new i;
for ( i = 0; i < sizeof(CrateIslandVehicles); i++)



Re: CMd Problem - Konstantinos - 10.01.2013

Quote:
Originally Posted by InActtive™
Посмотреть сообщение
Try this:

pawn Код:
new i;
for ( i = 0; i < sizeof(CrateIslandVehicles); i++)
Please, don't post pointless stuff. Defining the variable either before or on the for loop is both correct.

// --

First of all, try with
pawn Код:
for (new i = 0; i < CrateIslandVehicles; i++)
// Instead of
for (new i = 0; i < sizeof(CrateIslandVehicles); i++)
Secondly, are you sure you were in range of one of these airplanes 592, 519, 523, 593. The range distance is 16, but you may were 17 away, be sure about that. If you are close to one of these aircrafts, then the variable PlaneFound gets the modelid of the aircraft. For some reason, PlaneFound's value is equal to INVALID_VEHICLE_ID which is defined as
pawn Код:
#define INVALID_VEHICLE_ID (0xFFFF)
Last, you need to DEBUG your code and see what's the mistake of that command. I will show you an example and add debug messages to print and see what's wrong. Let's take a random line, you need to do it to the most lines that we care about the values.
pawn Код:
GetVehiclePos(CrateIslandVehicles[i], vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 16, vx, vy, vz))
{
    // rest..
With DEBUG, will be
pawn Код:
GetVehiclePos(CrateIslandVehicles[i], vx, vy, vz);
printf("GetVehiclePos(%d, %f, %f, %f);", CrateIslandVehicles[i], vx, vy, vz);
printf("if(IsPlayerInRangeOfPoint(%d, %d, %f, %f, %f))", playerid, 16, vx, vy, vz);
if(IsPlayerInRangeOfPoint(playerid, 16, vx, vy, vz))
{
    print("IsPlayerInRangeOfPoint returns 1");
    // rest..
This will print to the server windows (you can see it from server_log.txt) if you are in range of the vehicle and if you are, it prints the message "IsPlayerInRangeOfPoint returns 1".

Continue with the rest; show us the results!