C_far icon

DEV SAMP - Vidéo - TDM

C_far | PRO | 08/07/16 08:23:31 PM UTC | 0 ⭐ | 7547 👁️ | Never ⏰ | []
Pawn |

3.49 KB

|

None

|

0 👍

/

0 👎

#include <a_samp>
 
#define COLOR_RED       0xFF0000FF
#define COLOR_GREEN     0x33AA33FF
 
//-------------------------------
 
main(){}
 
//-------------------------------
 
enum Team
{
    BALLAS,
    GROVE
}
 
enum e_Player
{
    pName[MAX_PLAYER_NAME],
    
    Team:pTeam,
    
    pKills,
    pDeaths,
    
    bool:pFirstSpawn
}
 
//-------------------------------
 
stock
    members[Team],
    pInfo[MAX_PLAYERS][e_Player];
    
stock const
    Float:spawns[Team][][] =
    {
        {
            {-92.5665, -359.0368, 1.4297, 284.8226},
            {-91.7508, -355.1365, 1.4297, 284.8226},
            {-91.1126, -349.8121, 1.4297, 284.8226}
        },
        
        {
            {-6.6407, -320.0028, 5.4297, 90.5539},
            {-7.4725, -317.0150, 5.4297, 90.5539},
            {-8.2477, -314.3397, 5.4297, 90.5539}
        }
    };
 
//-------------------------------
 
stock AddPlayerToTeam(playerid, Team:teamid)
{
    pInfo[playerid][pTeam] = teamid;
    members[teamid]++;
    
    SetPlayerTeam(playerid, _:teamid);
    
    static const
        skins[Team][3] =
        {
            {102, 103, 104},
            {105, 106, 107}
        };
        
    SetPlayerSkin(playerid, skins[teamid][random(3)]);
    
    return 1;
}
 
//-------------------------------
 
public OnPlayerConnect(playerid)
{
    GetPlayerName(playerid, pInfo[playerid][pName], MAX_PLAYER_NAME);
    
    //------------------
    
    pInfo[playerid][pFirstSpawn] = true;
 
    return 1;
}
 
public OnPlayerDisconnect(playerid, reason)
{
    static const 
        reasonMsg[][] = 
        {
            "Crash",
            "Déconnexion",
            "Kick/Ban"
        };
        
    //----------------------
 
    new
        str[64];
        
    format(str, sizeof(str), "%s a quitté le serveur. (%s)", pInfo[playerid][pName], reasonMsg[reason]);
    SendClientMessageToAll(-1, str);
    
    //----------------------
    
    members[ pInfo[playerid][pTeam] ]--;
    
    //----------------------
    
    static const
        eBlank[e_Player];
        
    pInfo[playerid] = eBlank;
    
    return 1;
}
 
public OnPlayerSpawn(playerid)
{
    if(pInfo[playerid][pFirstSpawn])
    {
        pInfo[playerid][pFirstSpawn] = false;
        
        if(members[BALLAS] > members[GROVE]) 
            AddPlayerToTeam(playerid, GROVE);
            
        else if(members[BALLAS] < members[GROVE])
            AddPlayerToTeam(playerid, BALLAS);
            
        else
            AddPlayerToTeam(playerid, Team:random(_:Team));
    }
    
    //----------------------
    
    GivePlayerWeapon(playerid, WEAPON_DEAGLE, 500);
    
    new
        Team:teamid = pInfo[playerid][pTeam],
        rand = random( sizeof(spawns[]) );
        
    SetPlayerPos(playerid, spawns[teamid][rand][0], spawns[teamid][rand][1], spawns[teamid][rand][2]);
 
    return 1;
}
 
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid == INVALID_PLAYER_ID) return 1;
    
    //----------------------
    
    pInfo[playerid][pDeaths]++;
    pInfo[killerid][pKills]++;
    
    //----------------------
    
    new
        str[2][64],
        Team:teamid = pInfo[playerid][pTeam];
        
    format(str[0], sizeof(str[]), "Un allié (%s) a été tué.", pInfo[playerid][pName]);
    format(str[1], sizeof(str[]), "Un adversaire a été tué par %s.", pInfo[killerid][pName]);
    
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        
        if(teamid == pInfo[i][pTeam])
        {
            if(playerid == i) continue;
            SendClientMessage(i, COLOR_RED, str[0]);
        }
        
        else
        {
            if(killerid == i) continue;
            SendClientMessage(i, COLOR_GREEN, str[1]);
        }
    }
    
    format(str[0], sizeof(str[]), "Vous avez été tué par %s.", pInfo[killerid][pName]);
    SendClientMessage(playerid, -1, str[0]);
    
    format(str[0], sizeof(str[]), "Vous avez tué %s.", pInfo[playerid][pName]);
    SendClientMessage(killerid, -1, str[0]);
 
    return 1;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎