Anti-Team attack thing
#1

I've tried doing this several times, but never succeeded ;__;
Here's the script I've currently got:
(Ignore the first part)
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        if(gTeam[issuerid] != gTeam[playerid])
        {
            PlayerPlaySound(issuerid,17802,0.0,0.0,0.0);
        }
    }
    if(gTeam[issuerid] == gTeam[playerid])
    {
        if(issuerid != INVALID_PLAYER_ID)
        {
            if( !InGG{ issuerid } || !InWZ{ issuerid } || !InDuel{ issuerid } )
            {
                if( !AdminDuty{  issuerid } || !AdminDuty{ playerid } )
                {
                    GameTextForPlayer(issuerid, "~r~Don't team-attack!", 3500, 3);
                    /*new Float:health, Float:newhealth;
                    health = GetPlayerHealth(playerid, health);
                    newhealth = health -= amount;
                    SetPlayerHealth(playerid, newhealth);
                    new Float:armour, Float:newarmour;
                    armour = GetPlayerArmour(playerid, armour);
                    armour = armour -= amount;
                    SetPlayerArmour(playerid, newarmour);*/

                }
            }
        }
    }
//Rest of script here
I tried with the "newhealth = health" bla bla, but due to it it made the armour be removed, and health be set to 5 or something D:
Reply
#2

What are you exactly trying to do? Heal the player after he has been attacked by a player of his own team? Damage the attacker by the same amount of damage he did to his team mate?

Why don't you use SetPlayerTeam instead which prevents damage among players of same teams?

Or return 0 at OnPlayerWeaponShot ...

Код:
newhealth = health -= amount;
Shouldn't that be

Код:
newhealth = health - amount;
?
Reply
#3

too complicated, use this.
https://sampforum.blast.hk/showthread.php?pid=937824#pid937824
Reply
#4

I don't recommend the use of an include which relies on camera functions (Which is, infact, way more complicated than OnPlayerTakeDamage and is open to fake positives) when you've got a perfectly working native that doesn't take extra resources and is practically error free.
Reply
#5

@CuervO: That was a script i found somewhere via ******(samp forums)
https://sampforum.blast.hk/showthread.php?tid=442872 --- Post #3.
I tried editing it, making so the Armour isn't removable, but it didn't work.

I'm trying to team-attackers can't damage their teammates.
Reply
#6

CuervO gave you the best option already...

https://sampwiki.blast.hk/wiki/SetPlayerTeam
Reply
#7

Alternatively I've made a DamagePlayer function which does armour calculation:

http://pastebin.com/H1RprMXU

Remove the adminduty thingy, it was directly taken from a gamemode i've scripted.
Reply
#8

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
CuervO gave you the best option already...

https://sampwiki.blast.hk/wiki/SetPlayerTeam
Eh, i use gTeam ;_;

@CuervO: will try that one out xd
Reply
#9

Quote:
Originally Posted by Kyance
Посмотреть сообщение
Eh, i use gTeam ;_;

@CuervO: will try that one out xd
Код:
public OnPlayerSpawn(playerid)
{
      SetPlayerTeam(playerid, gTeam[playerid]);
      return 1;
}
Variables can be used among with natives.
Reply
#10

Quote:
Originally Posted by CuervO
Посмотреть сообщение
Код:
public OnPlayerSpawn(playerid)
{
      SetPlayerTeam(playerid, gTeam[playerid]);
      return 1;
}
Variables can be used among with natives.
That has seemed to work, thank you, and everyone else!
EDIT: You must spread some Reputation around before giving it to CuervO again.
,__,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)