SA-MP Forums Archive
Spawning a vehicle at current location - 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: Spawning a vehicle at current location (/showthread.php?tid=106112)



Spawning a vehicle at current location - Freddy_Manchez - 01.11.2009

Hello, i am currently trying to create a /spawnvehicle id command that spawns a vehicle with the id of your choice at your current location.
I have tryed to create it myself already, but i do not get any farther than this, because its giving me some errors:

Код:
if(strcmp(cmd, "/spawnvehicle", true) == 0)
{
GetPlayerPos(playerid, x, y, z);
AddStaticVehicle(vehicleid, x+random(5), y+random(5), z+random(5), 12, 0, 0);
}
return 1;
}



Re: Spawning a vehicle at current location - Sergei - 01.11.2009

pawn Код:
COMMAND:spawnvehicle(playerid,params[])
{
  new vehid,Float:x,Float:y,Float:z,Float:angle;
  GetPlayerPos(playerid,x,y,z);
  GetPlayerFacingAngle(playerid,angle);
  if(sscanf(params,"d",vehid)) SendClientMessage(playerid,WHITE,"SERVER: /spawnvehicle [modelid]";
      else if(400 > vehid => 612) SendClientMessage(playerid,WHITE,"SERVER: Invliad model id (400-612)";
  else {
    CreateVehicle(vehid, x+random(5), y+random(5), x+random(z), angle, -1, -1, -1);
      SendClientMessage(playerid,WHITE,"SERVER: Vehicle created!";
  }
  return 1;
}
Command using zcmd + sscanf.


Re: Spawning a vehicle at current location - Peter_Corneile - 01.11.2009

pawn Код:
if(strcmp(cmd, "/spawnvehicle", true) == 0)
{
new Float:X,Float:Y,Float:Z,Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
CreateVehicle(vehicleid,X+1,Y,Z,A,color1,color2,30000);
return 1;
}



Re: Spawning a vehicle at current location - Sergei - 01.11.2009

Quote:
Originally Posted by ►Peter Corneile◄ [ideal-host.co.uk
]
pawn Код:
if(strcmp(cmd, "/spawnvehicle", true) == 0)
{
new Float:X,Float:Y,Float:Z,Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
CreateVehicle(vehicleid,X+1,Y,Z,A,color1,color2,30000);
return 1;
}
Yeah and vehicleid is air ..


Re: Spawning a vehicle at current location - Peter_Corneile - 01.11.2009

Quote:
Originally Posted by $ЂЯĢ
Quote:
Originally Posted by ►Peter Corneile◄ [ideal-host.co.uk
]
pawn Код:
if(strcmp(cmd, "/spawnvehicle", true) == 0)
{
new Float:X,Float:Y,Float:Z,Float:A;
GetPlayerPos(playerid, X,Y,Z);
GetPlayerFacingAngle(playerid,A);
CreateVehicle(vehicleid,X+1,Y,Z,A,color1,color2,30000);
return 1;
}

Yeah and vehicleid is air ..
Huh , what do you mean ?


Re: Spawning a vehicle at current location - Correlli - 01.11.2009

Quote:
Originally Posted by ►Peter Corneile◄ [ideal-host.co.uk
]
Huh , what do you mean ?
Quote:
Originally Posted by ►Peter Corneile◄ [ideal-host.co.uk
]
pawn Код:
CreateVehicle(vehicleid,X+1,Y,Z,A,color1,color2,30000);
'vehicleid' isn't defined.


Re: Spawning a vehicle at current location - Peter_Corneile - 01.11.2009

Quote:
Originally Posted by Don Correlli
Quote:
Originally Posted by ►Peter Corneile◄ [ideal-host.co.uk
]
Huh , what do you mean ?
Quote:
Originally Posted by ►Peter Corneile◄ [ideal-host.co.uk
]
pawn Код:
CreateVehicle(vehicleid,X+1,Y,Z,A,color1,color2,30000);
'vehicleid' isn't defined.
Oh lol sorry


Re: Spawning a vehicle at current location - Freddy_Manchez - 02.11.2009

I used the one from Peter Corneile as i do not have zcmd and sscanf, but when i type /spawnvehicle 512 (as example) in game nothing happens.
Code:

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmd, "/spawnvehicle", true) == 0)
{
new vehicleid,Float:x,Float:y,Float:z,Float:A;
GetPlayerPos(playerid, x,y,z);
GetPlayerFacingAngle(playerid,A);
CreateVehicle(vehicleid,x+random(5),y+random(5),x+random(z), A,0,0,-1);
}
return 1;
}
I dont see any wrong things in this at the first place.


Re: Spawning a vehicle at current location - Correlli - 02.11.2009

Of course it doesn't.. 'vehicleid' is defined as 0 and there isn't such Model-ID for vehicles.

You need to put a Model-ID.


Re: Spawning a vehicle at current location - Freddy_Manchez - 02.11.2009

Quote:
Originally Posted by Don Correlli
Of course it doesn't.. 'vehicleid' is defined as 0 and there isn't such Model-ID for vehicles.

Use this instead:
pawn Код:
new
    vehicleid;

vehicleid = GetPlayerVehicleID(playerid);
That still does not work, still the same problem.