Vehicle health, NOT WHEN HE'S ONLY INSIDE - 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: Vehicle health, NOT WHEN HE'S ONLY INSIDE (
/showthread.php?tid=469957)
Vehicle health, NOT WHEN HE'S ONLY INSIDE -
yaron0600 - 15.10.2013
Hey,wassup sorry to bother you guys, so listen:
The code works only when u're inside the car, but when u /fix it / you're outside the veh, its back to 1000 can I do it would be always the health I defined? How? Can u help me ? Ty :
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER && oldstate == PLAYER_STATE_ONFOOT)
{
new vehicle = GetPlayerVehicleID(playerid);
new model = GetVehicleModel(vehicle);
switch(model)
{
case 541: SetVehicleHealth(vehicle, 1500);
case 596: SetVehicleHealth(vehicle, 2000);
case 560: SetVehicleHealth(vehicle, 1500);
case 402: SetVehicleHealth(vehicle, 1500);
case 427: SetVehicleHealth(vehicle, 7500);
case 528: SetVehicleHealth(vehicle, 5000);
case 599: SetVehicleHealth(vehicle, 2000);
case 601: SetVehicleHealth(vehicle, 4000);
case 490: SetVehicleHealth(vehicle, 2500);
case 433: SetVehicleHealth(vehicle, 4000);
case 470: SetVehicleHealth(vehicle, 2500);
case 432: SetVehicleHealth(vehicle, 10000);
case 497: SetVehicleHealth(vehicle, 2500);
case 487: SetVehicleHealth(vehicle, 1500);
}
}
Re: Vehicle health, NOT WHEN HE'S ONLY INSIDE -
DanishHaq - 15.10.2013
For the command, you need to put that under the command, i.e.
pawn Код:
if(model == X) SetVehicleHP(...);
Show us the command first of all.
Secondly, if you want it to always have the set amount of HP, put it under OnVehicleSpawn, not under OnPlayerStateChange, like this:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new model = GetVehicleModel(vehicleid)
switch(model)
{
case 541: SetVehicleHealth(vehicleid, 1500);
case 596: SetVehicleHealth(vehicleid, 2000);
case 560: SetVehicleHealth(vehicleid, 1500);
case 402: SetVehicleHealth(vehicleid, 1500);
case 427: SetVehicleHealth(vehicleid, 7500);
case 528: SetVehicleHealth(vehicleid, 5000);
case 599: SetVehicleHealth(vehicleid, 2000);
case 601: SetVehicleHealth(vehicleid, 4000);
case 490: SetVehicleHealth(vehicleid, 2500);
case 433: SetVehicleHealth(vehicleid, 4000);
case 470: SetVehicleHealth(vehicleid, 2500);
case 432: SetVehicleHealth(vehicleid, 10000);
case 497: SetVehicleHealth(vehicleid, 2500);
case 487: SetVehicleHealth(vehicleid, 1500);
}
return 1;
}