12.11.2011, 14:51
I try it but something wrong...
Player not go to front of vehicle.
pawn Код:
new Float:CarHealth[MAX_PLAYERS];
Funktsioon Damage()
{
foreach(Player,playerid) // foreach include in use :)
{
if(IsPlayerInAnyVehicle(playerid))
{
new Float:TempCarHealth;
new Veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(Veh, TempCarHealth);
new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,1.0) == 1))
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
new Float:Velocity[3];
GetVehicleVelocity(GetPlayerVehicleID(playerid), Velocity[0], Velocity[1], Velocity[2]);
SetPlayerPos(playerid,x+Velocity[0],y+Velocity[1],z+Velocity[2]);
Difference = floatdiv(Difference, 10.0);
new Float:OldHealth;
GetPlayerHealth(playerid, OldHealth);
SendClientMessage(playerid,-1,"You just crash");
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;
}