SA-MP Forums Archive
Server Start BUG - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Server Start BUG (/showthread.php?tid=609323)



Server Start BUG - Kenway - 11.06.2016

I found out that when you start the server. The vehicle that created from OnGameModeInIt
doesn't go towards OnVehicleSpawn call back.


Re: Server Start BUG - Konstantinos - 11.06.2016

The name of OnVehicleSpawn callback is misleading. It is called when a vehicle re-spawns, not when it is created.

If you want to do stuff when a vehicle is created, hook the functions. An example with CreateVehicle:
Код:
stock HF_CreateVehicle(modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, respawn_delay, addsiren = 0)
{
    new
        vehicleid = CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay, addsiren);
	    
    Iter_Add(Vehicle, vehicleid);
    SetVehicleHealth(vehicleid, 999.0);
    return vehicleid;
}

#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif

#define CreateVehicle HF_CreateVehicle
Replace the red code with yours.


Re: Server Start BUG - Kenway - 11.06.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The name of OnVehicleSpawn callback is misleading. It is called when a vehicle re-spawns, not when it is created.

If you want to do stuff when a vehicle is created, hook the functions. An example with CreateVehicle:
Код:
stock HF_CreateVehicle(modelid, Float: x, Float: y, Float: z, Float: angle, color1, color2, respawn_delay, addsiren = 0)
{
    new
        vehicleid = CreateVehicle(modelid, x, y, z, angle, color1, color2, respawn_delay, addsiren);
	    
    Iter_Add(Vehicle, vehicleid);
    SetVehicleHealth(vehicleid, 999.0);
    return vehicleid;
}

#if defined _ALS_CreateVehicle
    #undef CreateVehicle
#else
    #define _ALS_CreateVehicle
#endif

#define CreateVehicle HF_CreateVehicle
Replace the red code with yours.
So What Can I Do when the vehicles with the function AddStaticVehicleEx?


Re: Server Start BUG - Konstantinos - 11.06.2016

Exactly the same, just replacing anywhere you see "CreateVehicle" with "AddStaticVehicleEx" at the code above. Their parameters are the same so you won't have to change anything else.


Re: Server Start BUG - Kenway - 11.06.2016

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Exactly the same, just replacing anywhere you see "CreateVehicle" with "AddStaticVehicleEx" at the code above. Their parameters are the same so you won't have to change anything else.
Like this is okay:

PHP код:

stock HF_AddStaticVehicleEX
(modelidFloatxFloatyFloatzFloatanglecolor1color2respawn_delayaddsiren 0)
{
    new
        
vehicleid AddStaticVehicleEX(modelidxyzanglecolor1color2respawn_delayaddsiren);
        
    
Vehicle_ResetData(vehicleid);
    return 
vehicleid;
}
#if defined _ALS_AddStaticVehicleEX
    #undef AddStaticVehicleEX
#else
    #define _ALS_AddStaticVehicleEX
#endif
#define AddStaticVehicleEX HF_AddStaticVehicleEX 



Re: Server Start BUG - Konstantinos - 11.06.2016

Yes, but it is "Ex" and not "EX".


Re: Server Start BUG - Kenway - 11.06.2016

Thanks you