SA-MP Forums Archive
[SOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dcmd) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dcmd) (/showthread.php?tid=116706)



[SOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dcmd) - KnooL - 29.12.2009

I added the GetVehicleModelFromID thing,
pawn Code:
dcmd_veh(playerid,params[])
{
  new vehid = GetVehicleModelIDFromName(tmp);
  if(sscanf(params,"d",vehid)) {
    SendClientMessage(playerid,GREEN,"[USAGE] /veh [VEHID]");
  }
  else if(vehid < 400 || vehid > 611) {
    SendClientMessage(playerid,RED,"[ERROR] VehicleID can't be below 400 or above 611 or false name given.");
  }
  else {
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInAnyVehicle(playerid) == 1) {
      GetXYInFrontOfPlayer(playerid, x, y, 8);
    }
    else {
      GetXYInFrontOfPlayer(playerid, x, y, 5);
    }
    new i = GetPlayerInterior(playerid);
    new v = CreateVehicle(vehid, x, y, z, a+90, -1, -1, 0);
    LinkVehicleToInterior(v, i);
    new string[100];
    format(string, sizeof(string), "Car with id %s has been spawned", aVehicleNames[vehid - 400]);
    SendClientMessage(playerid, GREEN, string);
  }
  return 1;
}
It doesn't work.. Error at line:
new vehid = GetVehicleModelIDFromName(tmp);

(C:\server\gamemodes\beta.pwn(83 : error 017: undefined symbol "tmp")

Original topic:
http://forum.sa-mp.com/index.php?topic=62210.0


Re: from strmp to dcmd - [HiC]TheKiller - 29.12.2009

Quote:
Originally Posted by KnooL
I added the GetVehicleModelFromID thing,
pawn Code:
dcmd_veh(playerid,params[])
{
  new vehid = GetVehicleModelIDFromName(tmp);
  if(sscanf(params,"d",vehid)) {
    SendClientMessage(playerid,GREEN,"[USAGE] /veh [VEHID]");
  }
  else if(vehid < 400 || vehid > 611) {
    SendClientMessage(playerid,RED,"[ERROR] VehicleID can't be below 400 or above 611 or false name given.");
  }
  else {
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInAnyVehicle(playerid) == 1) {
      GetXYInFrontOfPlayer(playerid, x, y, 8);
    }
    else {
      GetXYInFrontOfPlayer(playerid, x, y, 5);
    }
    new i = GetPlayerInterior(playerid);
    new v = CreateVehicle(vehid, x, y, z, a+90, -1, -1, 0);
    LinkVehicleToInterior(v, i);
    new string[100];
    format(string, sizeof(string), "Car with id %s has been spawned", aVehicleNames[vehid - 400]);
    SendClientMessage(playerid, GREEN, string);
  }
  return 1;
}
It doesn't work.. Error at line:
new vehid = GetVehicleModelIDFromName(tmp);

(C:\server\gamemodes\beta.pwn(83 : error 017: undefined symbol "tmp")

Original topic:
http://forum.sa-mp.com/index.php?topic=62210.0
tmp should be params .


Re: from strmp to dcmd - KnooL - 29.12.2009

thank you


Re: from strmp to dcmd - KnooL - 30.12.2009

I tried it IG, and it didn't work out. Can someone fix it for me?

(IG: I tried; /veh sultan, didn't spawn anything, just gave me the message like you didn't enter something after '/veh' (sscanf) and after that I had something that it gave me Server: Unknown Command instead of my own created message. Either the ID and Modelname didn't work)

thing I want:
http://pastebin.com/f5070d164 if you can make this working to dcmd, i'd be happy

thanks in advance


Re: from strmp to dcmd - [HiC]TheKiller - 30.12.2009

Oh, I thought you meant using the ID. Here is the version using the name
pawn Code:
dcmd_veh(playerid,params[])
{
  new vehid[56] = GetVehicleModelIDFromName(params);
  if(sscanf(params,"s",vehid)) return SendClientMessage(playerid,GREEN,"[USAGE] /veh [Vehicle Name]");
  else
  {
    new Float:x, Float:y, Float:z, Float:a;
    GetPlayerFacingAngle(playerid, a);
    GetPlayerPos(playerid, x, y, z);
    if(IsPlayerInAnyVehicle(playerid) == 1) {
      GetXYInFrontOfPlayer(playerid, x, y, 8);
    }
    else {
      GetXYInFrontOfPlayer(playerid, x, y, 5);
    }
    new i = GetPlayerInterior(playerid);
    new v = CreateVehicle(vehid, x, y, z, a+90, -1, -1, 0);
    LinkVehicleToInterior(v, i);
    new string[100];
    format(string, sizeof(string), "Car with id %s has been spawned", aVehicleNames[vehid - 400]);
    SendClientMessage(playerid, GREEN, string);
  }
  return 1;
}
All you really needed is to change it to a string.


Re: from strmp to dcmd - KnooL - 30.12.2009

when I c&p:

C:\gta\gamemodes\beta.pwn(870) : error 008: must be a constant expression; assumed zero
C:\gta\gamemodes\beta.pwn(884) : error 035: argument type mismatch (argument 1)
C:\gta\gamemodes\beta.pwn(887) : error 033: array must be indexed (variable "vehid")

on lines:
new vehid[56] = GetVehicleModelIDFromName(params);
new v = CreateVehicle(vehid, x, y, z, a+90, -1, -1, 0);
format(string, sizeof(string), "Car with id %s has been spawned", aVehicleNames[vehid - 400]);


Re: [UNSOLVED] from strmp to dcmd - KnooL - 30.12.2009

!bump


Re: [UNSOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dc - KnooL - 31.12.2009

!bump


Re: [UNSOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dc - M4S7ERMIND - 31.12.2009

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.


Re: [UNSOLVED] /veh command with vehiclename or vehid in dcmd (from strcmp to dc - KnooL - 01.01.2010

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;
}