SetPlayerTeam - question related this
#1

So, I have a question related to https://sampwiki.blast.hk/wiki/SetPlayerTeam

It writes that "Players on the same team can not kill each other unless they use a knife. "

Can I disable this so players in the team x can kill players from the same team? And in wich way I can disable this.

Thank you for helping =)
Reply
#2

Well team kill won't work if you use SetPlayerTeam.

You can try using this include (OnPlayerShootPlayer):

https://sampforum.blast.hk/showthread.php?pid=937824#pid937824

And if playerid is aiming / shooting at targetid (on your own team), set targetid's health to zero.
Reply
#3

Or drop the SetPlayerTeam function and use some other variable for defining teams.
Reply
#4

What variable I could use if not the SetPlayerTeam for setting the team of the player?
Reply
#5

I'd suggest PVars.

You can define your teams like
Код:
#define TEAM_X 0
#define TEAM_Y 1
#define TEAM_Z 2
then you can use this for setting teams
Код:
SetPVarInt(playerid, "team", TEAM_X);
and for checking team
Код:
if(GetPVarInt(playerid, "team") == TEAM_X)
I prefer PVars to normal variables because the ease of use (no need to define them) and they can also be reached from filterscripts + they are reseted automatically on disconnect, just what we want in this case. But this is just one example, there are many many ways of setting teams.
Reply
#6

ok thank you very much =)
Reply
#7

Oh yes, one more question, how can I make the default spawn and skin for this team?
Reply
#8

https://sampwiki.blast.hk/wiki/AddPlayerClass

Or if you want it team based

https://sampwiki.blast.hk/wiki/OnPlayerSpawn
https://sampwiki.blast.hk/wiki/SetPlayerPos
https://sampwiki.blast.hk/wiki/SetPlayerSkin
Reply
#9

so something like this:

if(GetPVarInt(playerid, "team") == TEAM_X)
and here then the SetPlayerSkin ?
Reply
#10

You could do that, yes. A switch would probably be better though.

pawn Код:
switch(GetPVarInt(playerid, "team"))
{
    case TEAM_X:
    {
        SetPlayerPos(playerid, x, y, z);
        SetPlayerFacingAngle(playerid, a);
        SetPlayerInterior(playerid, int);
    }
    case TEAM_Y:
    {
        SetPlayerPos(playerid, x, y, z);
        SetPlayerFacingAngle(playerid, a);
        SetPlayerInterior(playerid, int);
    }
    case TEAM_Z:
    {
        SetPlayerPos(playerid, x, y, z);
        SetPlayerFacingAngle(playerid, a);
        SetPlayerInterior(playerid, int);
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)