[Tutorial] How to make an anti-teamkill -Easy- (with OPSP)
#1

Hi everyone,

You may have searched in this forum for an anti teamkill system...
as you can notice, there are not so many anti teamkill systems, and nor are there any anti-teamkill system that really makes the shooter NOT BEING ABLE to kill the target.

So I wanted to make this little tutorial : )

So how does it work?
Well, when a player shoots a player from its own team, then the shooter will die and get a message that teamkilling is not allowed. however, the target will regain the damage he lost by a teamkill-attempt, so that the victim of teamkilling doesn't have to die immediately...

Note: u are only going to be able to use this script, if u already worked with teams in your GM/Filterscript, otherwise U are going to get errors...

So, how are we going to do this?


STEP 1

First of all we will need a little include, made by wups, and it can be downloaded here:
http://forum.sa-mp.com/showthread.ph...highlight=OPSP

To install, u have to click the version u want, then copy the pastebin material, paste in notepad and save as OPSP.inc

then move it to the folder: pawno/include
and just paste it there...
next u wanna add
PHP Code:
#include <OPSP> 
at the top of your GM, or the script u wanna make our little anti-teamkill thing in.
Paste it under
PHP Code:
#include <a_samp> 
Ok, then add this somewhere in your Script:

PHP Code:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    return 
1;

STEP 2

now we are going to start to script.

so we have
PHP Code:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
    return 
1;

now add this under the first { bracket:

PHP Code:
if ( Shooter != INVALID_PLAYER_ID 
    { 
        if ( 
GetPlayerTeamTarget ) == GetPlayerTeamShooter ) ) // check if the victim is from the same team as the shooter. 
        

            new 
Float:hp;
    
GetPlayerHealth(Targethp);
            
SetPlayerHealth(Targethp HealthLost);
            
SetPlayerHealthShooter);
            
SendClientMessageShooterCOLOR_RED"Team killing is not allowed!" ); 
            
GivePlayerMoneyShooter, - 5000 ); 
    }

So, we will get this:

PHP Code:
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLost,Float:ArmourLost)
{
   if ( 
Shooter != INVALID_PLAYER_ID 
    { 
        if ( 
GetPlayerTeamTarget ) == GetPlayerTeamShooter ) ) // check if the victim is from the same team as the shooter. 
        

 
            new 
Float:hp;
            
GetPlayerHealth(Targethp);
            
SetPlayerHealth(Targethp HealthLost);
            
SetPlayerHealthShooter);
            
SendClientMessageShooterCOLOR_RED"Team killing is not allowed!" ); 
            
GivePlayerMoneyShooter, - 5000 ); 
        }
    }
    return 
1;

Just compile the script, save it and u don't have problems with teamkilling in your server anymore!
enjoy your Teamkilling-free server

Bye
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)