Originally Posted by TheOneThatOwnZ
You might be able to add onplayerupdate
if veh health is a certain thing then they die. it's possible. |
Originally Posted by Pixels^
I have this snippet in one of my gamemodes. Read the comments carefully, if you use this snippet, make sure you give credits to their rightful owners.
Код:
//Credits to Pixels^ and only Pixels^, and maybe some to Peter. enum SavePlayerPosEnum //Peter's Speedo Code { Float:LastX, //Peter's Speedo Code Float:LastY, //Peter's Speedo Code Float:LastZ //Peter's Speedo Code } //Peter's Speedo Code new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum]; //Peter's Speedo Code new lSpeed[MAX_PLAYERS]; //create an array that will store lastspeed. new cSpeed[MAX_PLAYERS]; //create an array that will store currentspeed. forward SpeedSystem(); //forward our public public SpeedSystem() { new Float:x, Float:y, Float:z, distance; for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) { if(GetPlayerState(i) == 3 || GetPlayerState(i) == 2) { lSpeed[i] = cSpeed[i]; //set last speed to current speed. // Peter's speedo code distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2)); // Peter's speedo code cSpeed[i] = floatround(distance * 5.4); //Set cSpeed to his current speed. SavePlayerPos[i][LastX] = x; // Peter's speedo code SavePlayerPos[i][LastY] = y; // Peter's speedo code SavePlayerPos[i][LastZ] = z; // Peter's speedo code if(lSpeed[i] <= 10 && (cSpeed[i] - lSpeed[i]) >= 20) //Check if the last speed is very low { //and the difference between currentspeed and lastspeed is really great. //Do the damage here //Of course you need to check if player is using the brake key //I'll let you do that yourself! } } } } |
Originally Posted by °ғαιιοцт°
here's my code
Код:
new Float:CarHealth[MAX_PLAYERS]; public OnPlayerUpdate(playerid) { if(IsPlayerInAnyVehicle(playerid) == 1) { 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; } |
C:\Program Files (x86)\Rockstar games\Gta San Andreas\dedicated server\filterscripts\carcrashes.pwn(31) : warning 213: tag mismatch C:\Program Files (x86)\Rockstar games\Gta San Andreas\dedicated server\filterscripts\carcrashes.pwn(51) : warning 217: loose indentation Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 2 Warnings.
// This is a comment // uncomment the line below if you want to write a filterscript #define FILTERSCRIPT #include <a_samp> #if defined FILTERSCRIPT enum SavePlayerPosEnum //Peter's Speedo Code { Float:LastX, //Peter's Speedo Code Float:LastY, //Peter's Speedo Code Float:LastZ //Peter's Speedo Code } //Peter's Speedo Code new SavePlayerPos[MAX_PLAYERS][SavePlayerPosEnum]; //Peter's Speedo Code new lSpeed[MAX_PLAYERS]; //create an array that will store lastspeed. new cSpeed[MAX_PLAYERS]; //create an array that will store currentspeed. forward SpeedSystem(playerid); //forward our public public SpeedSystem(playerid) { new Float:x, Float:y, Float:z, distance; new Float:CarHealth[MAX_PLAYERS]; for(new i=0; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) { if(GetPlayerState(i) == 3 || GetPlayerState(i) == 2) { lSpeed[i] = cSpeed[i]; //set last speed to current speed. // Peter's speedo code distance = floatsqroot(floatpower(floatabs(floatsub(x,SavePlayerPos[i][LastX])),2)+floatpower(floatabs(floatsub(y,SavePlayerPos[i][LastY])),2)+floatpower(floatabs(floatsub(z,SavePlayerPos[i][LastZ])),2)); // Peter's speedo code cSpeed[i] = floatround(distance * 5.4); //Set cSpeed to his current speed. SavePlayerPos[i][LastX] = x; // Peter's speedo code SavePlayerPos[i][LastY] = y; // Peter's speedo code SavePlayerPos[i][LastZ] = z; // Peter's speedo code if(lSpeed[i] <= 10 && (cSpeed[i] - lSpeed[i]) >= 20) //Check if the last speed is very low { //and the difference between currentspeed and lastspeed is really great. 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; }