PDA

View Full Version : Anti Deathmatch system


FunnyBear
16/02/2015, 11:21 PM
Hey,

I've asked this question a while back, but I still don't have a clear idea on how to make an anti DM system. Is it possible if someone could explain and possibly give an example script.

Thanks,

FunnyBear

Abagail
16/02/2015, 11:31 PM
Well, you can check if the player is wanted, has been killed by the player recently, if they have done any [/me's](assuming it's a roleplay server), etc.

Example:

stock IsDeathmatch(playerid, targetid)
{
if(RecentlyKilledBy[playerid] != targetid && GetPlayerWantedLevel(targetid) == 0 && // bla bla
{
return 1;
}
else return 0;
}


Then you can do something like:

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(playerid != issuerid && IsDeathmatch(issuerid, playerid))
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
CallLocalFunction("OnPlayerDeathmatch", "ddd", playerid, issuerid, weaponid);
return 1;
}
return 1;
}

FunnyBear
16/02/2015, 11:36 PM
Well, you can check if the player is wanted, has been killed by the player recently, if they have done any [/me's](assuming it's a roleplay server), etc.

Example:

stock IsDeathmatch(playerid, targetid)
{
if(RecentlyKilledBy[playerid] != targetid && GetPlayerWantedLevel(targetid) == 0 && // bla bla
{
return 1;
}
else return 0;
}


Then you can do something like:

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(playerid != issuerid && IsDeathmatch(issuerid, playerid))
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
CallLocalFunction("OnPlayerDeathmatch", "ddd", playerid, issuerid, weaponid);
return 1;
}
return 1;
}

Would something like this work?

public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
if(playerid != issuerid && IsALawEnforcement(issuerid) || gTeam[playerid] == TEAM_CIV && GetPlayerWantedLevel(playerid) < 1 )
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
return 1;
}
return 1;
}

Are there any other examples?

Abagail
16/02/2015, 11:42 PM
So basically using your code you wish to disable law enforcers from giving damage? And CIV's with no wanted level can't take fall damage?

Here is another example that prevents players from shooting someone if they have less than the shooting / attacking player's score.


public OnPlayerTakeDamage(playerid, issuerid, weaponid, bodypart)
{
if(playerid != issuerid && GetPlayerScore(playerid) < GetPlayerScore(issuerid))
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
return 0;
}
return 1;
}

For reference,
playerid - The one taking damage
issuerid - The one issuing damage(to the other player/playerID)

FunnyBear
16/02/2015, 11:48 PM
So basically using your code you wish to disable law enforcers from giving damage? And CIV's with no wanted level can't take fall damage?

Here is another example that prevents players from shooting someone if they have less than the shooting / attacking player's score.


public OnPlayerTakeDamage(playerid, issuerid, weaponid, bodypart)
{
if(playerid != issuerid && GetPlayerScore(playerid) < GetPlayerScore(issuerid))
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
return 0;
}
return 1;
}

For reference,
playerid - The one taking damage
issuerid - The one issuing damage(to the other player/playerID)

Would this work? To stop law enforcement officers from shooting eachother.

public OnPlayerTakeDamage(playerid, issuerid, weaponid, bodypart)
{
if(playerid != issuerid && IsALawEnforcement(playerid) && IsALawEnforcement(issuerid) )
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
return 0;
}
return 1;
}

If you have any other examples, please post it.

Thanks

Abagail
16/02/2015, 11:52 PM
Yes, that example should work fine. Another example:


public OnPlayerTakeDamage(playerid, issuerid, weaponid, bodypart)
{
if(IsPlayerInRangeOfPoint(playerid, safeZoneRange, safeZoneX, safeZoneY, safeZoneY, safeZoneZ))
{
new Float: health;
GetPlayerHealth(playerid, health+amount);
SetPlayerHealth(playerid, health);
return 0;
}
return 1;
}

P:S: I miss the old PAWN BBCode syntax :(