Posts: 617
Threads: 129
Joined: Feb 2014
So im trying to make all vehicles armoured vehicles used by law enforcers in my server health be more than 1000, now i made this code but its not working could someone tell me where i go wrong.. If you are posting a reply please ensure to explain it because im not only posting for the help but posting to learn as well..
PHP код:
for(new i = 0; i <= MAX_VEHICLES; i++)
{
if(IsValidVehicle(i))
{
new vehm = GetVehicleModel(i);
if(vehm == 427 || vehm == 470 || vehm == 447)
{
SetVehicleHealth(i, 2500.0);
}
}
}
Posts: 325
Threads: 14
Joined: Aug 2014
Reputation:
0
Where do you use this code?
Posts: 617
Threads: 129
Joined: Feb 2014
Quote:
Originally Posted by DarkSkull
Where do you use this code?
|
Ongamemodeinit and onvehiclespawn
Posts: 617
Threads: 129
Joined: Feb 2014
Quote:
Originally Posted by RIDE2DAY
You must run that code after you load/create the vehicles. Keep in mind that vehicle ids start at 1, not 0, so:
PHP код:
/* OnGameModeInit */
AddStaticVehicle(...);
AddStaticVehicle(...);
for(new i = 1, t = GetVehiclePoolSize(); i <= t; i++)
{
new v_model = GetVehicleModel(i);
if(v_model == 427 || v_model == 470 || v_model == 447)
{
SetVehicleHealth(i, 2500.0);
}
}
PHP код:
/* OnVehicleSpawn */
new v_model = GetVehicleModel(vehicleid);
if(v_model == 427 || v_model == 470 || v_model == 447)
{
SetVehicleHealth(vehicleid, 2500.0);
}
You can skip IsValidVehicle because GetVehicleModel returns 0 if the vehicle doesn't exist.
|
Do i have to use addstaticvehicle, cause for my scripts i used CreateVehicle
Posts: 325
Threads: 14
Joined: Aug 2014
Reputation:
0
No, It can be CreateVehicle as well.
Posts: 617
Threads: 129
Joined: Feb 2014
Quote:
Originally Posted by DarkSkull
No, It can be CreateVehicle as well.
|
Its not working
Posts: 617
Threads: 129
Joined: Feb 2014
Posts: 542
Threads: 14
Joined: Aug 2016
Reputation:
0
You shouldn't check by model because eventually it's gonna catch up on you, you should check by vehicle ids instead.
Posts: 325
Threads: 14
Joined: Aug 2014
Reputation:
0
Are you sure that the code Ride2Day gave you is run after all the vehicles are loaded in?