Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if defined _included_teamex
- #endinput
- #endif
- #define _included_teamex
- //---CONFIG
- #define MAX_TEAM_EX 500
- #define MIN_TEAM_EX 0
- #define NO_TEAM_EX -1
- //---VAR
- static
- PlayerTeam[MAX_PLAYERS],
- TeamKill[MAX_TEAM_EX],
- TeamDeath[MAX_TEAM_EX]
- ;
- //---FORWARD
- forward OnPlayerTeamChangeEx(playerid, newteam, oldteam);
- forward OnHealthTeamChangeEx(playerid, team, Float:newhealth);
- forward OnArmourTeamChangeEx(playerid, team, Float:newarmour);
- forward OnWeaponTeamChangeEx(playerid, team, weaponid, ammo);
- forward OnKillTeamChangeEx(playerid, team, kills);
- forward OnDeathTeamChangeEx(playerid, team, deaths);
- //---GET-FUNCTION
- stock GetPlayerTeamEx(playerid)
- return PlayerTeam[playerid];
- stock GetTeamKillEx(team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return -1;
- return TeamKill[team];
- }
- stock GetTeamDeathEx(team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return -1;
- return TeamDeath[team];
- }
- //---SET-FUNCTION
- stock SetPlayerTeamEx(playerid, team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- OnPlayerTeamChangeEx(playerid, team, PlayerTeam[playerid]);
- PlayerTeam[playerid] = team;
- return true;
- }
- stock SetAllPlayersTeamEx(team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- for(new i = 0; i < MAX_PLAYERS; ++ i)
- {
- if(!IsPlayerConnected(i)) continue;
- OnPlayerTeamChangeEx(i, team, PlayerTeam[i]);
- PlayerTeam[i] = team;
- }
- return true;
- }
- stock SetTeamHealthEx(team, Float:health)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- for(new i = 0 ; i < MAX_PLAYERS; ++ i)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerTeam[i] == team)
- {
- SetPlayerHealth(i, health);
- OnHealthTeamChangeEx(i, team, health);
- }
- }
- return true;
- }
- stock SetTeamArmourEx(team, Float:armour)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- for(new i = 0 ; i < MAX_PLAYERS; ++ i)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerTeam[i] == team)
- {
- SetPlayerArmour(i, armour);
- OnArmourTeamChangeEx(i, team, armour);
- }
- }
- return true;
- }
- stock SetTeamKillEx(team, kills)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- TeamKill[team] = kills;
- OnKillTeamChangeEx(INVALID_PLAYER_ID, team, kills);
- return true;
- }
- stock SetTeamDeathEx(team, deaths)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- TeamDeath[team] = deaths;
- OnDeathTeamChangeEx(INVALID_PLAYER_ID, team, deaths);
- return true;
- }
- stock SetTeamWeaponEx(team, weaponid, ammo)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- if(ammo < 1) return false;
- switch(weaponid)
- {
- case 0 .. 18, 22 .. 46:{}
- default: return false;
- }
- for(new i = 0 ; i < MAX_PLAYERS; ++ i)
- {
- if(!IsPlayerConnected(i)) continue;
- if(PlayerTeam[i] == team)
- {
- GivePlayerWeapon(i, weaponid, ammo);
- OnWeaponTeamChangeEx(i, team, weaponid, ammo);
- }
- }
- return true;
- }
- //---REMOVE-FUNCTION
- stock RemovePlayerTeamEx(playerid)
- {
- OnPlayerTeamChangeEx(playerid, NO_TEAM_EX, PlayerTeam[playerid]);
- PlayerTeam[playerid] = NO_TEAM_EX;
- return true;
- }
- stock RemoveAllPlayersTeamEx()
- {
- for(new i = 0; i < MAX_PLAYERS; ++ i)
- {
- if(!IsPlayerConnected(i)) continue;
- OnPlayerTeamChangeEx(i, NO_TEAM_EX, PlayerTeam[i]);
- PlayerTeam[i] = NO_TEAM_EX;
- }
- return true;
- }
- //---RESET-FUNCTION
- stock ResetTeamKillEx(team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- OnKillTeamChangeEx(INVALID_PLAYER_ID, team, 0);
- TeamKill[team] = 0;
- return true;
- }
- stock ResetTeamDeathEx(team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- OnDeathTeamChangeEx(INVALID_PLAYER_ID, team, 0);
- TeamDeath[team] = 0;
- return true;
- }
- stock ResetAllTeamKillEx()
- {
- for(new i = 0; i < MAX_TEAM_EX; ++ i)
- {
- OnKillTeamChangeEx(INVALID_PLAYER_ID, i, 0);
- TeamKill[i] = 0;
- }
- return true;
- }
- stock ResetAllTeamDeathEx()
- {
- for(new i = 0; i < MAX_PLAYERS; ++ i)
- {
- OnDeathTeamChangeEx(INVALID_PLAYER_ID, i, 0);
- TeamDeath[i] = 0;
- }
- return true;
- }
- stock ResetTeamKillDeathEx(team)
- {
- if(team < MIN_TEAM_EX || team > MAX_TEAM_EX) return false;
- OnKillTeamChangeEx(INVALID_PLAYER_ID, team, 0);
- TeamKill[team] = 0;
- OnDeathTeamChangeEx(INVALID_PLAYER_ID, team, 0);
- TeamDeath[team] = 0;
- return true;
- }
- stock ResetAllTeamKillDeathEx()
- {
- for(new i = 0; i < MAX_TEAM_EX; ++ i)
- {
- OnKillTeamChangeEx(INVALID_PLAYER_ID, i, 0);
- TeamKill[i] = 0;
- OnDeathTeamChangeEx(INVALID_PLAYER_ID, i, 0);
- TeamDeath[i] = 0;
- }
- return true;
- }
- //---CALLBACK
- public OnPlayerConnect(playerid)
- {
- PlayerTeam[playerid] = NO_TEAM_EX;
- #if defined TeamEx_OnPlayerConnect
- TeamEx_OnPlayerConnect(playerid);
- #endif
- return true;
- }
- #if defined _ALS_OnPlayerConnect
- #undef OnPlayerConnect
- #else
- #define _ALS_OnPlayerConnect
- #endif
- #define OnPlayerConnect TeamEx_OnPlayerConnect
- #if defined TeamEx_OnPlayerConnect
- forward TeamEx_OnPlayerConnect(playerid);
- #endif
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(killerid != INVALID_PLAYER_ID)
- {
- if(PlayerTeam[killerid] != NO_TEAM_EX)
- {
- if(PlayerTeam[killerid] != PlayerTeam[playerid])
- {
- ++TeamKill[PlayerTeam[killerid]];
- ++TeamDeath[PlayerTeam[playerid]];
- }
- OnKillTeamChangeEx(killerid, PlayerTeam[killerid], TeamKill[PlayerTeam[killerid]]);
- OnDeathTeamChangeEx(playerid, PlayerTeam[playerid], TeamDeath[PlayerTeam[playerid]]);
- }
- }
- else
- {
- if(PlayerTeam[playerid] != NO_TEAM_EX)
- {
- ++TeamDeath[PlayerTeam[playerid]];
- OnDeathTeamChangeEx(playerid, PlayerTeam[playerid], TeamDeath[PlayerTeam[playerid]]);
- }
- }
- #if defined TeamEx_OnPlayerDeath
- TeamEx_OnPlayerDeath(playerid, killerid, reason);
- #endif
- return true;
- }
- #if defined _ALS_OnPlayerDeath
- #undef OnPlayerDeath
- #else
- #define _ALS_OnPlayerDeath
- #endif
- #define OnPlayerDeath TeamEx_OnPlayerDeath
- #if defined TeamEx_OnPlayerDeath
- forward TeamEx_OnPlayerDeath(playerid, killerid, reason);
- #endif
Advertisement
Add Comment
Please, Sign In to add comment