01.01.2010, 03:59
Quote:
Originally Posted by Mастерминд
Remove sscanffrom veh command and add this
Code:
new vehid; if(IsNumeric(params)) vehid = strval(params); else vehid = GetVehicleModelIDFromName(params); if(vehid < 400 || vehid > 611) return SendClientMessage("Invalid vehicle...); |
After 15 mins of experimenting I got this in the end and with a working end result
pawn Code:
dcmd_veh(playerid,params[])
{
new vehid = GetVehicleModelIDFromName(params);
new vehicle = GetVehicleModelIDFromName(params);
if(!IsNumeric(params)) { // vehid = strval(params);
vehid = GetVehicleModelIDFromName(params);
}
if(IsNumeric(params)) vehid = strval(params);
if(vehid < 400 || vehid > 611) return SendClientMessage(playerid,RED,"[ERROR] VehicleID can't be below 400 or above 611 or false name given.");
new Float:x, Float:y, Float:z;
new Float:a,
string[128];
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInAnyVehicle(playerid) == 1) {
GetXYInFrontOfPlayer(playerid, x, y, 8);
}
else {
GetXYInFrontOfPlayer(playerid, x, y, 5);
}
new in = CreateVehicle(vehid, x, y, z, a+90, -1, -1, 0);
LinkVehicleToInterior(in, GetPlayerInterior(playerid));
if(!IsNumeric(params)) {
format(string, sizeof(string), "You have spawned a %s", aVehicleNames[vehicle - 400]);
SendClientMessage(playerid, GREEN, string);
}
if(IsNumeric(params)) {
format(string, sizeof(string), "You have spawned a %s", aVehicleNames[vehid - 400]);
SendClientMessage(playerid, GREEN, string);
}
return 1;
}