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

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
Reply
#2

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 .
Reply
#3

thank you
Reply
#4

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
Reply
#5

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.
Reply
#6

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]);
Reply
#7

!bump
Reply
#8

!bump
Reply
#9

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.
Reply
#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


Forum Jump:


Users browsing this thread: 4 Guest(s)