SA-MP Forums Archive
Anti Deathmatch system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti Deathmatch system (/showthread.php?tid=563767)



Anti Deathmatch system - FunnyBear - 16.02.2015

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


Re: Anti Deathmatch system - Abagail - 16.02.2015

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;
}



Re: Anti Deathmatch system - FunnyBear - 16.02.2015

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?


Re: Anti Deathmatch system - Abagail - 16.02.2015

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)


Re: Anti Deathmatch system - FunnyBear - 16.02.2015

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


Re: Anti Deathmatch system - Abagail - 16.02.2015

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