SA-MP Forums Archive
Make Vehicles Spawn With Custom Health - 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: Make Vehicles Spawn With Custom Health (/showthread.php?tid=592838)



Make Vehicles Spawn With Custom Health - SupperRobin6394 - 30.10.2015

hey hey,

on my server i got a small army base in LS, to make it more realistic and more logical i want to make some vehicles (Rhino, Hunter, Hydra etc.) spawn with an amount of health that's not the default 1.000, like a Rhino will spawn with 10.000 health. Any ideas how this is possible?


Re: Make Vehicles Spawn With Custom Health - AbyssMorgan - 30.10.2015

PHP код:
public OnVehicleSpawn(vehicleid){
    
    new 
vehm GetVehicleModel(vehicleid);
    
    if(
vehm == 520 || vehm == 432 || vehm == 425){
        
SetVehicleHealth(vehicleid10000.0);
    }
    return 
1;




Re: Make Vehicles Spawn With Custom Health - SupperRobin6394 - 30.10.2015

Will that also work with vehicles that are spawned under OnGamemodeInit?


Re: Make Vehicles Spawn With Custom Health - AbyssMorgan - 30.10.2015

maybe

add under vehicles

PHP код:
public OnGameModeInit(){
    
//code
    
    
for(new 0<= MAX_VEHICLESi++){
        if(
IsValidVehicle(i)){
            new 
vehm GetVehicleModel(i);
            if(
vehm == 520 || vehm == 432 || vehm == 425){
                
SetVehicleHealth(i10000.0);
            }
        }
    }
    return 
1;




Re: Make Vehicles Spawn With Custom Health - SupperRobin6394 - 30.10.2015

I will try this when I am home, I think you can replace SetVehicleHealth wilth other things also (like AddVehicleComponent), so I can make a sultan spawn tuned?


Re: Make Vehicles Spawn With Custom Health - AbyssMorgan - 30.10.2015

yes.


Re: Make Vehicles Spawn With Custom Health - MP2 - 30.10.2015

OnVehicleSpawn is called when vehicles REspawn, not the first spawn. You'll need to hook CreateVehicle/AddStaticVehicle(Ex).


Re: Make Vehicles Spawn With Custom Health - AbyssMorgan - 30.10.2015

Quote:
Originally Posted by MP2
Посмотреть сообщение
OnVehicleSpawn is called when vehicles REspawn, not the first spawn. You'll need to hook CreateVehicle/AddStaticVehicle(Ex).
already I gave what to do

hook is unnecessary


Re: Make Vehicles Spawn With Custom Health - SupperRobin6394 - 30.10.2015

"error 017: undefined symbol "IsValidVehicle""

any idea?


Re: Make Vehicles Spawn With Custom Health - feartonyb - 30.10.2015

Place this under your includes

Код:
native IsValidVehicle(vehicleid);