Anti-Team attack thing -
Kyance - 15.02.2014
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:
Re: Anti-Team attack thing -
CuervO - 15.02.2014
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;
?
Re: Anti-Team attack thing -
Vanter - 15.02.2014
too complicated, use this.
https://sampforum.blast.hk/showthread.php?pid=937824#pid937824
Re: Anti-Team attack thing -
CuervO - 15.02.2014
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.
Re: Anti-Team attack thing -
Kyance - 16.02.2014
@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.
Re: Anti-Team attack thing -
Scenario - 16.02.2014
CuervO gave you the best option already...
https://sampwiki.blast.hk/wiki/SetPlayerTeam
Re: Anti-Team attack thing -
CuervO - 16.02.2014
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.
Re: Anti-Team attack thing -
Kyance - 16.02.2014
Quote:
Originally Posted by RealCop228
|
Eh, i use gTeam ;_;
@CuervO: will try that one out xd
Re: Anti-Team attack thing -
CuervO - 16.02.2014
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.
Re: Anti-Team attack thing -
Kyance - 16.02.2014
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.
,__,