Need help
#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


Messages In This Thread
Need help - by Shadow0707 - 03.02.2017, 00:20
Re: Need help - by BiosMarcel - 03.02.2017, 07:34
Re: Need help - by JesterlJoker - 03.02.2017, 08:16
Re: Need help - by Shadow0707 - 03.02.2017, 22:58

Forum Jump:


Users browsing this thread: 1 Guest(s)