SA-MP Forums Archive
Vehicle spawn help - 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)
+--- Thread: Vehicle spawn help (/showthread.php?tid=497776)



Vehicle spawn help - Vasu99 - 28.02.2014

Hi,

Thanks for taking your time reading this topic. I'm currently attempting to start up my own server, but have bumped into quite a weird problem. I created a vehicle spawning command for admins, although the vehicle seems to return to it's original spawning point as the vehicle is driven and then exited. I will post the command below, but I doubt there's anything weird in there as I've gone through it a couple of items.

Код:
CMD:aveh(playerid,params[])
{
new car;
new string[128];
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
if(PlayerInfo[playerid][Level] < 2) return SendClientMessage(playerid,0xF69521AA, "You cannot use this command!");//Checking if the player has admin level 2, if not it sends him a message.
if(sscanf(params,"i", car)) return SendClientMessage(playerid,0xF69521AA,"USAGE: /aveh <vehicle id (400-611)>");
if (!(400 <= car <= 611)) return SendClientMessage(playerid,0xF69521AA,"Please specify a vehicle ID between 400 and 611");
{
    Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);
    format(string, sizeof(string), "You have successfully spawned vehicle id %i!",car);
    SendClientMessage(playerid, 0xF69521AA, string);
}
return 1;
}
Cheers!


Re: Vehicle spawn help - Konstantinos - 28.02.2014

The above command is setlevel not about spawning vehicles. Well, the respawn delay is the key here. If you set it to 1 while creating the vehicle and it's unoccupied (a player exits from it), it will respawn the vehicle after 1 second.


Re: Vehicle spawn help - Vasu99 - 28.02.2014

I'm not quite sure what you mean, although I edited the script to the vehicle spawning command, sorry for the mistake haha. Anyhow, could you try explaining once again?


Re: Vehicle spawn help - Konstantinos - 28.02.2014

Vehicle[playerid] = CreateVehicle(car, X, Y, Z + 2.0, 0, -1, -1, 1);

Parameters: modelid, x, y, z, angle, color1, color2, respawn_delay

As you can see, you set the respawn_delay to 1. That means that it will respawn the vehicle (to the coordinates it was first created) after 1 second (after exiting the vehicle). Use -1 instead if you don't want to respawn the vehicles after exiting them or make it higher (for example, every minute (60)).


Re: Vehicle spawn help - Vasu99 - 28.02.2014

Thanks for explaining it so well mate, you're awesome!