SA-MP Forums Archive
[Tutorial] Difference between CreateVehicle and AddStaticVehicle(Ex) - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] Difference between CreateVehicle and AddStaticVehicle(Ex) (/showthread.php?tid=261581)



Difference between CreateVehicle and AddStaticVehicle(Ex) - Kwarde - 14.06.2011

Hi, here's another tutorial made by me.
I think this could be usefull to beginners, because in the beginning, I didn't know what the difference was between those functions (except that the names are different and some parameters are different).

AddStaticVehicle
This function will only work in the OnGameModeInit and OnFilterScriptInit. As the function name says: "Add Static Vehicle". You can't add vehicle (eg. a vehicle spawner) with this function.
With this function you can add trains, which is impossible with CreateVehicle. The respawn time for vehicles with this function is (as far as I know, I ever read it somewhere) 15 minutes.

AddStaticVehicleEx
This function is almost the same as AddStaticVehicle. The only difference is that you can give the respawn time yourself.
This is the most usefull for RP servers, because you can set the respawn time to '-1'. That means that it won't be respawned untill it'll die (exploded, in water etc.). [It's non-RP that it respawns o_O]

CreateVehicle
This one can be called at any time. For a vehicle spawner you must use this one, otherwise it won't work. The only bad thing of this function is that train's won't work.

Conclusion
AddStaticVehicle is usefull for trains, but can only be used in On[GameMode/FilterScript]Init. CreateVehicle can be called at any time, but doesn't support trains and trams

Well, it's short, but that doesn't matter. That's only easier to read

Regards,
Kevin


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - Jack_Rocker - 14.06.2011

Nice! I cant say anything negative so 10/10


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - xalith - 14.06.2011

thanks i didnt know the whole
Quote:

set the respawn time to '-1'. That means that it won't be respawned untill it'll die (exploded, in water etc.).




Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - Kwarde - 15.06.2011

Well, I'm happy that my tutorial helped atleast one person - That's the intention of it.


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - IllidanS46 - 20.06.2011

CreateVehicle can be used for trams and Freight Box Trailer (590)


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - eDz0r - 20.06.2011

Quote:
Originally Posted by xalith
View Post
thanks i didnt know the whole
Me too i just set it to 0


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - Donya - 27.06.2011

why can't there just be one function.. >.<

Good Tutorial.


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - Mean - 29.06.2011

For trains, maybe this would work (didn't test): create them at some random position no one uses, and use SetVehiclePos.


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - Ash. - 30.06.2011

Erm, AddStaticVehicle(Ex) does work in commands...

pawn Code:
dcmd_veh(playerid, params[])
{
    HMOD_CHECK;
    if(!strlen(params)) return SendClientMessage(playerid, COLOUR_RED, "Usage: /veh [model]");
    if(strval(params) < 400 || strval(params) > 611) return SendClientMessage(playerid, COLOUR_RED, "Models start from 400 and end at 611");
    if(strval(params) == 432 || strval(params) == 425 || strval(params) == 520)
    {
        ASH_CHECK;
    }
    new Float:xx, Float:yy, Float:zz;
    GetPlayerPos(playerid, xx, yy, zz);
    SpawnedVehicles[LastSpawn] = AddStaticVehicleEx(strval(params), xx+2.5, yy+2.5, zz, 0.0, -1, -1, -1);
    LastSpawn++;
    return 1;
}
(Ignore the _CHECK bits, they're just defines for permissions checks)

That command spawns every vehicle on the game, with no issues.


Re: Difference between CreateVehicle and AddStaticVehicle(Ex) - [NoV]LaZ - 30.06.2011

Conclusion for the first post; AddStaticVehicle(Ex) is used to add vehicles via OnGameModeInit or OnFilterScriptInit, and it's used to add trains. CreateVehicle is ONLY used to add vehicles during gameplay, unlike the other two mentioned functions.