Note: This script needs GoldenEye Source Beta 3.1 to run. Also make sure you save it as Unicode not UTF8
g_bInWarmup = true; g_bStartedRound = false; g_bWaitingForPlayers = true;
iPlayersLevel = {}; iAlivePlayers = {};
weapList = {“golden_pp7”, “golden_gun”, “ar33”, “rcp90”, “d5k”, “phantom”, “zmg”, “kf7”, “auto_shotgun”, “shotgun”, “cmag”, “sniper_rifle”, “pp7”, “klobb”, “knife_throwing”, “grenade”, “knife”};
iMaxLevel = 17;
warmUp = 0;
function round2(num, idp)
return tonumber(string.format("%." .. (idp or 0) .. "f", num))
end
–========================================================================–
function OnLoadGamePlay()
CreateCVar(“gg_avglevel”, “1”, “Give new players average level on join”);
CreateCVar("gg_warmup", "45", "The warm up time in seconds"); CreateCVar("gg_deathmatch", "0", "Enable DeathMatch"); LoadConfig();
for i=1,32 do iPlayersLevel[[i]] = 0; end
warmUp = GetTime() + tonumber( GetCVar("gg_warmup") );
end
–========================================================================–
function GetGameDescription()
if IsTeamplay() then return "Team Gun Game"; else return "Gun Game"; end
end
–========================================================================–
function PlayerConnect(player)
if (GetCVar(“gg_avglevel”) ~= “0” and g_bInWarmup == false) then
iPlayersLevel[[player]] = AvgLevel(); else iPlayersLevel[[player]] = 1; end
iAlivePlayers[[player]] = false;
ClientPrintPlayer(player, HUD_PRINTTALK, “�%s1 Gun Game”, “#GES_GP_INTRO”);
ClientPrintPlayer(player, HUD_PRINTTALK, "�%s1", "#GES_GP_HELP");
end
–========================================================================–
function PlayerDisconnect(player)
iPlayersLevelplayer = 0;
iAlivePlayers[[player]]=false;
end
–========================================================================–
function PlayerKilled( victim, killer, weapId )
if ( g_bStartedRound == false ) then Msg("Pre Round!"); return; end
iAlivePlayers[[victim]] = false;
if (victim == killer) then
if (iPlayersLevelkiller > 1) then
AddToPlayerScore( killer, -1 ); iPlayersLevel[[killer]] = iPlayersLevel[[killer]]-1; end
elseif ( IsTeamplay() and GetPlayerTeam(killer) == GetPlayerTeam(victim) ) then
if (iPlayersLevelkiller > 1) then
AddToPlayerScore( killer, -1 ); iPlayersLevel[[killer]] = iPlayersLevel[[killer]]-1; end
elseif (WeaponName(weapId) == weapList[iPlayersLevel[killer]] or WeaponName(weapId) == “knife” or WeaponName(weapId) == “slappers”) then
if (WeaponName(weapId) == “knife” and iPlayersLevelvictim > 1) then
iPlayersLevel[[victim]] = iPlayersLevel[[victim]] - 1; AddToPlayerScore( victim, -1 ); ClientPrintAll(HUD_PRINTTALK, "�%s1 �was knifed and Lost a level.", PlayerName(victim)); end
if (WeaponName(weapId) == "slappers") then
if (iPlayersLevel[[victim]] > 1) then iPlayersLevel[[victim]] = iPlayersLevel[[victim]] - 1; AddToPlayerScore( victim, -1 ); ClientPrintAll(HUD_PRINTTALK, "�%s1 �was slapped and lost a level and �%s2 �gained armor!", PlayerName(victim), PlayerName(killer)); else ClientPrintAll(HUD_PRINTTALK, "�%s1 �was slapped to death and �%s2 �gained armor!", PlayerName(victim), PlayerName(killer)); end
PlayerSetArmor( killer, GE_MAX_ARMOR ); end
AddToTeamScore( GetPlayerTeam(killer), 1 );
AddToPlayerScore( killer, 1 );
iPlayersLevelkiller = iPlayersLevelkiller+1;
PrintCurLevel(killer);
if (iPlayersLevelkiller > iMaxLevel) then
SetPlayerWinner(killer); EndMatch(); else GivePlayerWeapons(killer); end end
end
–========================================================================–
function PlayerSay( player, text )
if (text == “!help”) then
PrintHelp( player );
return true;
elseif (text == “!level”) then
PrintCurLevel( player );
return true;
elseif (text == “!weapons”) then
PrintWeapons( player );
return true;
elseif (text == “!commands”) then
PrintCommands( player ); return true;
else return false; end
return false; end
–========================================================================–
function CanPlayerHaveWeapon( player, weapId )
if ( WeaponName(weapId) == weapList[iPlayersLevel[player]] or WeaponName(weapId) == “knife” or WeaponName(weapId) == “slappers”) then
return true; end
return false;
end
–========================================================================–
function PreRoundBegin()
DisableRoundTimer();
DisableWeaponSpawns(); DisableAmmoSpawns(); DisableArmorSpawns();
ResetAllPlayersScores(); end
–========================================================================–
function PostRoundBegin()
local leadPlayer = 1; local tie = false;
for i=1,32 do if (IsValidPlayer(i) and GetPlayerTeam(i) ~= TEAM_SPECTATOR) then if (iPlayersLevel[[i]] > iPlayersLevel[[leadPlayer]]) then leadPlayer = i; tie = false; elseif (iPlayersLevel[[i]] == iPlayersLevel[[leadPlayer]]) then tie = true; end end end
if (IsValidPlayer(leadPlayer) and iPlayersLevelleadPlayer > 1 ) then
if (tie == true) then ClientPrintAll(HUD_PRINTTALK, "�Current Leader: �Tie on Level " .. iPlayersLevel[[leadPlayer]] ); else ClientPrintAll(HUD_PRINTTALK, "�Current Leader: �" .. PlayerName(leadPlayer) .. " �(Level " .. iPlayersLevel[[leadPlayer]] .. ")" ); end end
for i=1,32 do if ( iPlayersLevel[[i]] ~= 0 ) then AddToPlayerScore( i, iPlayersLevel[[i]] ); iAlivePlayers[[i]] = true; PrintCurLevel(i); GivePlayerWeapons(i); end end
if ( g_bInWarmup == false ) then g_bStartedRound = true; end
end
–========================================================================–
function CanPlayerRespawn(plyr)
if (g_bStartedRound == false) then
return true; end
if (GetCVar("gg_deathmatch") == "0") then return iAlivePlayers[[plyr]]; else return true; end
end
–========================================================================–
function CanMatchEnd()
local level = 0;
for i=1,32 do if (IsValidPlayer(i) and GetPlayerTeam(i) ~= TEAM_SPECTATOR and iPlayersLevel[[i]] > level) then level = iPlayersLevel[[i]]; end end
if (level > (iMaxLevel - 3) and level < iMaxLevel) then return false; else return true; end
end
–========================================================================–
function CalcFinalScores()
for i=1,32 do if (IsValidPlayer(i) and GetPlayerTeam(i) ~= TEAM_SPECTATOR) then SetPlayerFinalScore(i, iPlayersLevel[[i]]); end end
end
–========================================================================–
function Think()
if (warmUp ~= 0 and GetTime() > warmUp) then
if (GetNumActivePlayers() < 2) then ClientPrintAll( HUD_PRINTCENTER, "Waiting For Players ..." ); return; end
g_bInWarmup = false; EndRound(false); warmUp = 0;
elseif (warmUp ~= 0 ) then ClientPrintAll( HUD_PRINTCENTER, "Warmup: " .. round2((warmUp - GetTime()), 0) ); return;
else
if ( GetNumActivePlayers() < 2 ) then g_bStartedRound = false; g_bWaitingForPlayers = true; return; else g_bWaitingForPlayers = false; end
if ( g_bWaitingForPlayers ) then g_bWaitingForPlayers = false; warmUp = GetTime() + 30; g_bInWarmup = true; end
end
if (GetCVar("gg_deathmatch") ~= "0") then return; end
local iMI6PlayersLeft = 0; local iJanusPlayersLeft = 0; local iAlivePlayers = 0;
for i=0,31 do if(IsValidPlayer(i) and IsPlayerDead(i) == false and GetPlayerTeam(i) ~= TEAM_SPECTATOR) then if (GetPlayerTeam(i) == TEAM_MI6) then iMI6PlayersLeft = iMI6PlayersLeft + 1; elseif (GetPlayerTeam(i) == TEAM_JANUS) then iJanusPlayersLeft = iJanusPlayersLeft + 1; end end end
iAlivePlayers = iMI6PlayersLeft + iJanusPlayersLeft;
if (iAlivePlayers == 1) then for i=0,31 do
if (IsValidPlayer(i) and IsPlayerDead(i) == false and GetPlayerTeam(i) ~= TEAM_SPECTATOR) then SetPlayerWinner(i); end end end
if (IsTeamplay() == true) then
if ( (iMI6PlayersLeft == 0) and (iJanusPlayersLeft == 0) ) then
EndRound(); g_bStartedRound = false;
elseif ( iMI6PlayersLeft == 0 and iJanusPlayersLeft > 0 ) then
AddToTeamScore( TEAM_JANUS, 10 ); SetTeamWinner( TEAM_JANUS ); EndRound(); g_bStartedRound = false;
elseif ( iJanusPlayersLeft == 0 and iMI6PlayersLeft > 0 ) then
AddToTeamScore( TEAM_MI6, 10 ); SetTeamWinner( TEAM_MI6 ); EndRound(); g_bStartedRound = false;
end else
if ( GetNumAlivePlayers() ⇐ 1 ) then
EndRound(); g_bStartedRound = false;
end
end
end
–========================================================================–
function PostPlayerSpawn( player )
if (iPlayersLevelplayer == 0) then
iPlayersLevel[[player]] = 1; end
GivePlayerWeapons(player);
end
–========================================================================–
function PrintCurLevel( player )
if (player ⇐ 0 or player > 32) then
return; end
if (iPlayersLevelplayer > 0) then
ClientPrintPlayer(player, HUD_PRINTTALK, "%s1 %s2", "�Level " .. iPlayersLevel[[player]] .. ": ", WeaponPrintName(weapList[iPlayersLevel[player]])); else ClientPrintPlayer(player, HUD_PRINTTALK, "�You are currently not playing" ); end
end
–========================================================================–
function GivePlayerWeapons( player )
if ( IsPlayerDead(player) == true or iPlayersLevelplayer == 0 ) then
return; end
StripAllWeapons(player);
GiveNamedWeapon(player, “slappers”, 0);
GiveNamedWeapon(player, "knife", 0);
if (iPlayersLevelplayer ~= iMaxLevel) then
if (weapList[iPlayersLevel[player]] == "grenade") then GiveNamedWeapon(player, weapList[iPlayersLevel[player]], 1); else GiveNamedWeapon(player, weapList[iPlayersLevel[player]], 90); end
SwitchToWeapon( player, weapList[iPlayersLevel[player]] ); else SwitchToWeapon( player, "knife" );
end
end
–========================================================================–
function AvgLevel()
local level = 0; local count = 0;
for i=1,32 do if (IsValidPlayer(i) and GetPlayerTeam(i) ~= TEAM_SPECTATOR) then level = level + iPlayersLevel[[i]]; count = count + 1; end end
if (count == 0) then return 1; else level = level / count; return level; end;
end
–========================================================================–
function PrintHelp( player )
ClientPrintPlayer(player, HUD_PRINTTALK, “�——————————————————————”);
ClientPrintPlayer(player, HUD_PRINTTALK, " GES: %s1", "#GES_GP_GUNGAME_TITLE"); ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------"); ClientPrintPlayer(player, HUD_PRINTTALK, "%s1", "#GES_GP_GUNGAME_H1"); ClientPrintPlayer(player, HUD_PRINTTALK, "%s1", "#GES_GP_GUNGAME_H2"); ClientPrintPlayer(player, HUD_PRINTTALK, "%s1", "#GES_GP_GUNGAME_H3"); ClientPrintPlayer(player, HUD_PRINTTALK, "%s1", "#GES_GP_GUNGAME_H4"); ClientPrintPlayer(player, HUD_PRINTTALK, "�Type !commands for commands"); ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------");
end
–========================================================================–
function PrintWeapons( player )
ClientPrintPlayer(player, HUD_PRINTTALK, “�——————————————————————”);
ClientPrintPlayer(player, HUD_PRINTTALK, " GunGame Weapons Order"); ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------");
for i=1,iMaxLevel do ClientPrintPlayer(player, HUD_PRINTTALK, "%s1: %s2", i, WeaponPrintName(weapList[[i]])); end
ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------");
end
function PrintCommands( player )
ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------"); ClientPrintPlayer(player, HUD_PRINTTALK, " GunGame Commands"); ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------"); ClientPrintPlayer(player, HUD_PRINTTALK, "Type !help for help"); ClientPrintPlayer(player, HUD_PRINTTALK, "Type !level for current level"); ClientPrintPlayer(player, HUD_PRINTTALK, "Type !weapons for weapon order"); --ClientPrintPlayer(player, HUD_PRINTTALK, "Type !top10 for top 10 players"); ClientPrintPlayer(player, HUD_PRINTTALK, "�------------------------------------------------------------------");
end </lua>