Need help
#1

I Dont know why it keeps telling me undefined symbol even it is defined Here is the full command

Код:
CMD:veh(playerid, params[]) {
	if(PlayerInfo[playerid][pAdmin] >= 4) {
	
		new
			iVehicle[32], iModel, iColors[2];

		if(sscanf(params, "s[32]ii", iVehicle, iColors[0], iColors[1])) {
			return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /veh [model ID/vehicle name] [color 1] [color 2]");
		}

		if(IsNumeric(iVehicle))
		    iModel = strval(iVehicle);
		}
		else
			iModel = GetVehicleIDByName(iVehicle);
		
		if(!(400 <= iModel <= 611)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
		}
		else if(IsATrain(iModel)) {
			SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
		}
		else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
		}
		else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(iIterator >= 49) {
			return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum limit of 50 spawned vehicles has been reached.");
		}
		else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

			new
				Float: fVehPos[4];

			new fVW = GetPlayerVirtualWorld(playerid);
			GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
			GetPlayerFacingAngle(playerid, fVehPos[3]);
			CreatedCars[iIterator] = CreateVehicle(iModel, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
			VehicleFuel[CreatedCars[iIterator]] = 100.0;
			Vehicle_ResetData(CreatedCars[iIterator]);
			LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
			SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
			return SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
	return 1;
}
Line 59254
Код:
iModel = strval(iVehicle);
Line 59257
Код:
iModel = GetVehicleIDByName(iVehicle);
Line 59259
Код:
if(!(400 <= iModel <= 611)) {
Line 59265
Код:
else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
Код:
(59254) : warning 204: symbol is assigned a value that is never used: "iModel"
(59257) : error 017: undefined symbol "iModel"
(59257) : error 017: undefined symbol "iVehicle"
(59259) : error 017: undefined symbol "iModel"
(59262) : error 017: undefined symbol "iModel"
(59265) : error 017: undefined symbol "iColors"
(59265) : error 029: invalid expression, assumed zero
(59265) : warning 215: expression has no effect
(59265) : error 001: expected token: ";", but found "]"
(59265) : fatal error 107: too many error messages on one line
Reply
#2

This:

PHP код:
else if(!(<= iColors[0] <= 255 && <= iColors[1] <= 255)) { 
is not valid syntax, try this.

PHP код:
else if(!(<= iColors[0] && iColors[0] <= 255 && <= iColors[1] && iColors[1] <= 255)) { 
Reply
#3

I saw horrors on the code
Try this one and don't forget to remove the comments

Код:
CMD:veh(playerid, params[]) {
	if(PlayerInfo[playerid][pAdmin] >= 4) 
	{
	
		new
			iVehicle[32], iModel, iColors[2];

		if(sscanf(params, "s[32]ii", iVehicle, iColors[0], iColors[1])) 
		{
			return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /veh [model ID/vehicle name] [color 1] [color 2]");
		}

		if(IsNumeric(iVehicle)) { // <-- this one was missing
		    iModel = strval(iVehicle);
		}
		else { // <-- this too was missing
			iModel = GetVehicleIDByName(iVehicle);
		} // <-- and of course this.
		
		if(!(400 <= iModel <= 611)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
		}
		else if(IsATrain(iModel)) {
			SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
		}
		else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
		}
		else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(iIterator >= 49) {
			return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum limit of 50 spawned vehicles has been reached.");
		}
		else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

			new
				Float: fVehPos[4];

			new fVW = GetPlayerVirtualWorld(playerid);
			GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
			GetPlayerFacingAngle(playerid, fVehPos[3]);
			CreatedCars[iIterator] = CreateVehicle(iModel, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
			VehicleFuel[CreatedCars[iIterator]] = 100.0;
			Vehicle_ResetData(CreatedCars[iIterator]);
			LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
			SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
			return SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
	return 1;
}
Reply
#4

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
This:

PHP код:
else if(!(<= iColors[0] <= 255 && <= iColors[1] <= 255)) { 
is not valid syntax, try this.

PHP код:
else if(!(<= iColors[0] && iColors[0] <= 255 && <= iColors[1] && iColors[1] <= 255)) { 
Quote:
Originally Posted by JesterlJoker
Посмотреть сообщение
I saw horrors on the code
Try this one and don't forget to remove the comments

Код:
CMD:veh(playerid, params[]) {
	if(PlayerInfo[playerid][pAdmin] >= 4) 
	{
	
		new
			iVehicle[32], iModel, iColors[2];

		if(sscanf(params, "s[32]ii", iVehicle, iColors[0], iColors[1])) 
		{
			return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /veh [model ID/vehicle name] [color 1] [color 2]");
		}

		if(IsNumeric(iVehicle)) { // <-- this one was missing
		    iModel = strval(iVehicle);
		}
		else { // <-- this too was missing
			iModel = GetVehicleIDByName(iVehicle);
		} // <-- and of course this.
		
		if(!(400 <= iModel <= 611)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid model specified (model IDs start at 400, and end at 611).");
		}
		else if(IsATrain(iModel)) {
			SendClientMessageEx(playerid, COLOR_GREY, "Trains cannot be spawned during runtime.");
		}
		else if(!(0 <= iColors[0] <= 255 && 0 <= iColors[1] <= 255)) {
			SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid color specified (IDs start at 0, and end at 255).");
		}
		else for(new iIterator; iIterator < sizeof(CreatedCars); iIterator++) if(iIterator >= 49) {
			return SendClientMessageEx(playerid, COLOR_GRAD1, "The maximum limit of 50 spawned vehicles has been reached.");
		}
		else if(CreatedCars[iIterator] == INVALID_VEHICLE_ID) {

			new
				Float: fVehPos[4];

			new fVW = GetPlayerVirtualWorld(playerid);
			GetPlayerPos(playerid, fVehPos[0], fVehPos[1], fVehPos[2]);
			GetPlayerFacingAngle(playerid, fVehPos[3]);
			CreatedCars[iIterator] = CreateVehicle(iModel, fVehPos[0], fVehPos[1], fVehPos[2], fVehPos[3], iColors[0], iColors[1], -1);
			VehicleFuel[CreatedCars[iIterator]] = 100.0;
			Vehicle_ResetData(CreatedCars[iIterator]);
			LinkVehicleToInterior(CreatedCars[iIterator], GetPlayerInterior(playerid));
			SetVehicleVirtualWorld(CreatedCars[iIterator], fVW);
			return SendClientMessageEx(playerid, COLOR_GREY, "Vehicle spawned!");
		}
	}
	else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
	return 1;
}
Thanks to both of you it is now fixed
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)