[SOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dcmd)
#10

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...);
You'll need IsNumeric function for this.
thank you I couldn't have this solved without this post.
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;
}
Reply


Messages In This Thread
[SOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dcmd) - by KnooL - 29.12.2009, 22:11
Re: from strmp to dcmd - by [HiC]TheKiller - 29.12.2009, 22:13
Re: from strmp to dcmd - by KnooL - 29.12.2009, 22:17
Re: from strmp to dcmd - by KnooL - 30.12.2009, 00:36
Re: from strmp to dcmd - by [HiC]TheKiller - 30.12.2009, 00:46
Re: from strmp to dcmd - by KnooL - 30.12.2009, 13:09
Re: [UNSOLVED] from strmp to dcmd - by KnooL - 30.12.2009, 22:06
Re: [UNSOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dc - by KnooL - 31.12.2009, 11:23
Re: [UNSOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dc - by M4S7ERMIND - 31.12.2009, 11:50
Re: [UNSOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dc - by KnooL - 01.01.2010, 03:59

Forum Jump:


Users browsing this thread: 3 Guest(s)