Anti Deathmatch system
#1

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
Reply
#2

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:
pawn Code:
stock IsDeathmatch(playerid, targetid)
{
      if(RecentlyKilledBy[playerid] != targetid && GetPlayerWantedLevel(targetid) == 0 && // bla bla
      {
           return 1;
      }
      else return 0;
}
Then you can do something like:
pawn Code:
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;
}
Reply
#3

Quote:
Originally Posted by Abagail
View Post
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:
pawn Code:
stock IsDeathmatch(playerid, targetid)
{
      if(RecentlyKilledBy[playerid] != targetid && GetPlayerWantedLevel(targetid) == 0 && // bla bla
      {
           return 1;
      }
      else return 0;
}
Then you can do something like:
pawn Code:
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?

pawn Code:
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?
Reply
#4

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.

pawn Code:
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)
Reply
#5

Quote:
Originally Posted by Abagail
View Post
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.

pawn Code:
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.

pawn Code:
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
Reply
#6

Yes, that example should work fine. Another example:

pawn Code:
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
Reply


Forum Jump:


Users browsing this thread: