10.03.2012, 09:00
Quote:
pawn Code:
This script is old of 0.3c and i don't used OnPlayerTakeDamage... |
pawn Code:
This script is old of 0.3c and i don't used OnPlayerTakeDamage... |
That's err...pretty simple to make. Or better yet, you could check if the player is streamed in to the player.
pawn Code:
|
If it's not, it's a fake kill. As I said before, the code was more proof-of-concept and I made it in a rush, so the if statements are effectively the wrong way around.
|
if(GetPlayerWeapon != reason)
so the if statements are effectively the wrong way around. |
new LastDeath[ MAX_PLAYERS ];
new DeathSpam[ MAX_PLAYERS char ];
public OnPlayerDeath(playerid, killerid, reason)
{
new time = gettime( );
switch( time - LastDeath[ playerid ] )
{
case 0 .. 3:
{
DeathSpam{ playerid }++;
if( DeathSpam{ playerid } == 3 )
{
BanEx( playerid, "Fake-kill" );
return 1;
}
}
default: DeathSpam{ playerid } = 0;
}
LastDeath[ playerid ] = time;
return 1;
}
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys)
{
if(HOLDING(KEY_FIRE))
{
SetPVarInt(playerid,"firing",1);
}
else
{
DeletePVar(playerid,"firing");
}
return 1;
}
new lastShotTime;
new lastAmmo;
new lastWeapon;
public OnPlayerUpdate(playerid)
{
if(GetPVarInt(playerid,"firing"))
{
if(lastWeapon == GetPlayerWeapon(playerid) && GetPlayerAmmo(playerid) < lastAmmo)
{
printf("%d %d %d",lastWeapon,lastAmmo - GetPlayerAmmo(playerid),GetTickCount() - lastShotTime);
lastShotTime = GetTickCount();
}
lastAmmo = GetPlayerAmmo(playerid);
lastWeapon = GetPlayerWeapon(playerid);
}
return 1;
}
If Last_Health > MaxDamage[reason] * Leniency[reason] * PlayersAttacking[playerid]
variable HealthLimit Loop Through Players { if itteration shot player and time shot is less than X (I'd say about 2 seconds) { increase HealthLimit to MaxDamage weapon used to damage * Leniency of weapon used } } if Last_Health > HealthLimit something seems a little suspicious
GetVehicleHealth(GetPVarInt(playerid,"vehicleid"),Health);
if(Health > 250.0)
{
//possible car jack bug
}
new PlayerDamagedPlayer[MAX_PLAYERS][MAX_PLAYERS] = { 255, ... };//sets default Value to 255 (unknown) this variable will store the weaponid used to attack
new PlayerDamagedPlayerTime[MAX_PLAYERS][MAX_PLAYERS];//this will store the time in seconds when the player was attacked
new Float:LastPlayerHealthUpdate[MAX_PLAYERS];
//PlayerDamagedPlayer will be in the format of [damagerid][victimid]
public OnPlayerSpawn(playerid)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
//reset the variables when they respawn or after the checks in OPD
PlayerDamagedPlayer[playerid][i] = 255;
PlayerDamagedPlayer[i][playerid] = 255;
}
}
stock Float:GetMaxWeaponDamage(weaponid)
{
switch(weaponid)
{
case 22: return 8.25;//9mm
case 23: return 13.20;//silencer
case 24: return 46.20;//deagle
}
return 255.0;//just because it safely exceeds 200 (100 health + 100 armour)
}
//returns ticks inbetween each shot fired
stock GetWeaponFiringRate(weaponid)
{
switch(weaponid)
{
case 22: return 100;//9mm
case 23: return 250;//silencer
case 24: return 600;//deagle
}
}
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
PlayerDamagedPlayer[issuerid][playerid] = weaponid;
PlayerDamagedPlayerTime[issuerid][playerid] = gettime();
}
public OnPlayerGiveDamage(playerid, damagedid, Float:amount, weaponid)
{
PlayerDamagedPlayer[playerid][damagedid] = weaponid;
PlayerDamagedPlayerTime[playerid][damagedid] = gettime();
}
public OnPlayerUpdate(playerid)
{
new Float:health;
GetPlayerHealth(playerid,health);
LastPlayerHealthUpdate[playerid] = health;
}
public OnPlayerDeath(playerid,killerid,reason)
{
new Float:TotalMaxDamage = 0.0;
new CurrentTime = gettime();
if(killerid != INVALID_PLAYERID)//killed by another player
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(PlayerDamagePlayer[i][playerid] != 255 && PlayerDamagePlayerTime[i][playerid] + 2 > CurrentTime)
{
new Float:MaxDamageFromPlayer = 0.0;
MaxDamageFromplayer = GetMaxWeaponDamage(PlayerDamagePlayer[i][playerid]);
switch(GetWeaponFiringRate(PlayerDamagePlayer[i][playerid]))
{
case 0 .. 100:
{
MaxDamageFromPlayer *= 4;
}
case 101 .. 200:
{
MaxDamageFromPlayer *= 2;
}
}
TotalMaxDamage += MaxDamageFromPlayer;
}
}
if(LastPlayerHealthUpdate[playerid] > TotalMaxDamage)
{
new Float:VehicleHealth;
GetVehicleHealth(GetPlayerVehicleID(vehicleid),VehicleHealth);
if(!IsPlayerInAnyVehicle(playerid) || VehicleHealth > 250.0)
{
//posible fake kill
}
}
}
}