#1

How can I do so that Team 1 can not hurt Team 2? As if the two teams were one.
Reply
#2

someone?
Reply
#3

Set them to the same team.

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

Quote:

Players can not damage/kill players on the same team unless they use a knife to slit their throat. As of SA-MP 0.3x, players are also unable to damage vehicles driven by a player from the same team. This can be enabled with EnableVehicleFriendlyFire.

Reply
#4

That's what I do not want, I want to do that only damage can not be done. I do not want to put them on the same team.

I know it's possible, if it were not possible, how do they do on the servers "protect the president" that I played? In which the minitro, the vice president, security, swat, president, etc. They can not hurt themselves.
Reply
#5

I think that what are you trying to find ?
Code:
public OnPlayerTakeDamage (playerid, issuerid, Float:amount, weaponid, bodypart)
{
    //Do something
}
You will take the issuerid and check if he is from team1 and check if playerid(who took the shot) from team2
If this statement is true you will set the playerid's health to 100(or his health before shot).
Reply
#6

Like Threshold said, you should use SetPlayerTeam but not for the "teams" itself but for the factions who can't damage each other
For the teams itself, you need to use an additional array
Something like that
PHP Code:
native SetPlayerFaction(playeridFactionfactionid) = SetPlayerTeam;
native FactionGetPlayerFaction(playerid) = GetPlayerTeam;
new 
TeamgTeam[MAX_PLAYERS];
#define SetPlayerTeam(%0,%1) (gTeam[%0] = %1)
#define GetPlayerTeam(%0) gTeam[%0] 
Example PTP:

PHP Code:
enum Faction {
    
F_NONE,
    
F_DEFEND// T_PRESIDENT, T_BODYGUARD, T_POLICE
    
F_ATTACK// T_TERRORIST
    
F_NEUTRAL // T_CIVILIAN
};
enum Team {
    
T_NONE,
    
T_PRESIDENT,
    
T_BODYGUARD,
    
T_POLICE,
    
T_TERRORIST,
    
T_CIVILIAN
};
// OnPlayerRequestClass
switch(classid) {
    case 
0: { // lets pretend this is the president class
        
SetPlayerFaction(playeridF_DEFEND);
        
SetPlayerTeam(playeridT_PRESIDENT);
    }
    
// and so on

Reply
#7

Ok.. But how do I do so that the police can not harm the president (who belongs to another team)?

If you choose the president team, then it will be SetPlayerTeam (playerid, Team_President);

and if you choose the police team, then it will be SetPlayerTeam (playerid, Team_Police); Therefore, there are 2 different teams and at the moment of shooting they will damage themselves.

If you have ever played "protect the president" you will see that the police team is blue and have their own spawn apart, and the president's team is white and have their own spawn and different from the police. But when they shoot at each other, no harm is done, and that's why I think putting them on the same team is going to wrap the whole script around the separate positions, colors and weapons.

I really need a little help with this, or a good clarification on how to do it.
Reply
#8

Unless your script specifically uses 'GetPlayerTeam' to define what team or faction a player is using, then you won't have any issues. You need to mentally unassign 'SetPlayerTeam' being tied with the player's actual team.

You are linking SetPlayerTeam with the faction they've chosen, which is untrue. It does not correspond to their choice of faction at all despite it changing their 'Team'. This is an illusion in your mind that you need to work around.

Nero_3D has given you a perfect example of how to accomplish this. Read over his post again, slowly, until you work out a solution.
Reply
#9

Does it mean that I should not use 'SetPlayerTeam' for each team?

This is what I have in my script, is it wrong?:

PHP Code:
//Command
ShowPlayerDialog(playeridDialog_PTPDIALOG_STYLE_LIST"PTP - TEAMS""President\nPolice\nTerrorist""Select""Close");
//OnDialogResponse
case Dialog_PTP:
{
    if(
response)
    {
        switch(
listitem)
        {
            case 
0:
            {
                
SetPlayerTeam(playeridTeam_President); // team 0
            
                
new index random(sizeof(Ptp_Pos[])), team GetPlayerTeam(playerid);
                
SetPlayerPos(playeridPtp_Pos[team][index][0], Ptp_Pos[team][index][1], Ptp_Pos[team][index][2]);
                
SetPlayerFacingAngle(playeridPtp_Pos[team][index][3]);
                
                
//other codes
            
}
            case 
1:
            {
                
SetPlayerTeam(playeridTeam_Police); // team 1
                
                
new index random(sizeof(Ptp_Pos[])), team GetPlayerTeam(playerid);
                
SetPlayerPos(playeridPtp_Pos[team][index][0], Ptp_Pos[team][index][1], Ptp_Pos[team][index][2]);
                
SetPlayerFacingAngle(playeridPtp_Pos[team][index][3]);
                
                
//other codes
            
}
            case 
2:
            {
                
SetPlayerTeam(playeridTeam_Terrorist); // team 2
                
                
new index random(sizeof(Ptp_Pos[])), team GetPlayerTeam(playerid);
                
SetPlayerPos(playeridPtp_Pos[team][index][0], Ptp_Pos[team][index][1], Ptp_Pos[team][index][2]);
                
SetPlayerFacingAngle(playeridPtp_Pos[team][index][3]);
                
                
//other codes
            
}
        }
    }
    return 
1;

Reply
#10

Quote:
Originally Posted by SapMan
View Post
Does it mean that I should not use 'SetPlayerTeam' for each team?

This is what I have in my script, is it wrong?:
It is not wrong if you only have teams but in your case we need teams and factions (several teams grouped together)

Just put these 5 lines in an include files and include it or put them before the first SetPlayerTeam / GetPlayerTeam in your code
This code simply defines SetPlayerFaction and GetPlayerFaction, nothing more nothing less
PHP Code:
native SetPlayerFaction(playeridFactionfactionid) = SetPlayerTeam;
native FactionGetPlayerFaction(playerid) = GetPlayerTeam;
new 
gTeam[MAX_PLAYERS];
#define SetPlayerTeam(%0,%1) (gTeam[%0] = %1)
#define GetPlayerTeam(%0) gTeam[%0] 
In your code you just need to use them
PHP Code:
// somewhere before your first usage
enum Faction {
    
Faction_Defend// President, Police
    
Faction_Attack // Terrorist
};
//OnDialogResponse
case Dialog_PTP:
{
    if(
response)
    {
        switch(
listitem)
        {
            case 
0:
            {
                
SetPlayerFaction(playeridFaction_Defend);
                
SetPlayerTeam(playeridTeam_President);
                
                
//other codes
            
}
            case 
1:
            {
                
SetPlayerFaction(playeridFaction_Defend);
                
SetPlayerTeam(playeridTeam_Police);
                
                
//other codes
            
}
            case 
2:
            {
                
SetPlayerFaction(playeridFaction_Attack);
                
SetPlayerTeam(playeridTeam_Terrorist);
                
//other codes
            
}
        }
    }
    return 
1;

Maybe you will notice the similarity to the code from before
Reply
#11

Oh, now if I understand, it's something like this:

PHP код:
gTeam[playerid] = Team_Police;
SetPlayerTeam(playeridTeam_Defend);
SetPlayerPos(playeridPtp_PosgTeam[playerid] ][index][0], Ptp_PosgTeam[playerid] ][index][1], Ptp_PosgTeam[playerid] ][index][2]); 
Reply
#12

Quote:
Originally Posted by SapMan
Посмотреть сообщение
Oh, now if I understand, it's something like this:

PHP код:
//CODE 
Exactly, I just added wrappers for easier usage and understanding but it is up to you how you implement it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)