[Tutorial] Difference between CreateVehicle and AddStaticVehicle(Ex)
#1

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

Nice! I cant say anything negative so 10/10
Reply
#3

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

Reply
#4

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

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

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

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

Good Tutorial.
Reply
#8

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)