06.10.2012, 20:41
Hello. I am scripting a spawncar command. I already made a dealership and vehicle ownership, however I can't seem to make the spawncar command. I keep getting invalid command, and the command does generally not work.
What I have is:
However if I type /spawncar it will tell me the usage, but it will never process the command if I type in any params.
What I have is:
pawn Код:
CMD:spawncar(playerid, params[])
{
new vehicleid = -1, vehicleslot = strval(params)-1, choice;
if(sscanf(params, "i", choice)) return SendClientMessage(playerid, -1, "USAGE: /spawncar [1-5]");
if(strval(params) < 1 || strval(params) > 5 ) return SendClientMessage(playerid, -1, "Valid slot numbers are 1-5.");
if(PlayerInfo[playerid][pVehicle][vehicleslot] == 0) return SendClientMessage(playerid, -1, "You don't have a vehicle in that slot.");
for(new x; x<MAX_VEHICLES; x++)
{
if(ownerofvehicle[x] == playerid)
{
vehicleid = x;
}
}
if(vehicleid != -1) return SendClientMessage(playerid, -1, "You already have a vehicle spawned.");
playerownedvehicle[vehicleid] = CreateVehicle(PlayerInfo[playerid][pVehicle][vehicleslot], PlayerInfo[playerid][pVehiclePosX][vehicleslot], PlayerInfo[playerid][pVehiclePosY][vehicleslot], PlayerInfo[playerid][pVehiclePosZ][vehicleslot], 0,0,0,0);
ownerofvehicle[vehicleid] = playerid;
return 1;
}