Seatbelt.. - 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: Seatbelt.. (
/showthread.php?tid=501999)
Seatbelt.. -
Lajko1 - 21.03.2014
Why this reduces player's health only for like 5 HP points.. How can I make it it will reduce players health based on how much damage vehicle recieved at crash?
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
if(SeatBelt[playerid] ==0)
{
new Float:phealth;
new Float:vhealth;
GetPlayerHealth(playerid, phealth);
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, vhealth);
SetPlayerHealth(playerid, phealth - vhealth /168);
}
return 1;
}
Re: Seatbelt.. -
]Rafaellos[ - 21.03.2014
Save it somewhere and compare it.
Re: Seatbelt.. -
Lajko1 - 21.03.2014
How?
Re: Seatbelt.. -
Matess - 21.03.2014
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
if(SeatBelt[playerid] ==0)
{
new Float:phealth;
new Float:vhealth;
GetPlayerHealth(playerid, phealth);
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, vhealth);
SetPlayerHealth(playerid, phealth - vhealth /168);//Vehicle got 1000HP so 1000/168 = 5.95 and this is your problem
}
return 1;
}
Re: Seatbelt.. -
Lajko1 - 21.03.2014
Quote:
Originally Posted by Matess
pawn Код:
public OnVehicleDamageStatusUpdate(vehicleid, playerid) { if(SeatBelt[playerid] ==0) { new Float:phealth; new Float:vhealth; GetPlayerHealth(playerid, phealth); new veh = GetPlayerVehicleID(playerid); GetVehicleHealth(veh, vhealth); SetPlayerHealth(playerid, phealth - vhealth /168);//Vehicle got 1000HP so 1000/168 = 5.95 and this is your problem } return 1; }
|
Lowered it to 50 and it's somehow better but it's always same damage how can I make it based on how much vehicle received damage ? and if someone can show a code or something I wasn't scripting with those things yet ^^
Re: Seatbelt.. -
Lajko1 - 22.03.2014
Can someone show code how can I make that player receive damage based on how much vehicle took damage at crash? Please
Re: Seatbelt.. -
caki - 22.03.2014
Quote:
Originally Posted by Lajko1
Can someone show code how can I make that player receive damage based on how much vehicle took damage at crash? Please
|
Use this under OnPlayerUpdate or change it and use it OnVehicleDamageStatusUpdate
pawn Код:
if(IsPlayerInAnyVehicle(playerid) == 1 && Seatbelt[playerid] == 0 && !IsBicycle(vehicleid))
{
new Float:TempCarHealth;
GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
{
Difference = floatdiv(Difference, 10.0);
new Float:OldHealth;
GetPlayerHealth(playerid, OldHealth);
SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
}
CarHealth[playerid] = TempCarHealth;
}
else
{
CarHealth[playerid] = 0.0; //To aviod that a player dies when he enters a vehicle
}
return 1;
}