Spawning a vehicle at current location
#1

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

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

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;
}
Reply
#4

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

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

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

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

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)