Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Conquest 1.03
- -- Change these to whatever you want
- base_radius = 5.75 -- Radius of sphere (centered about the flag) of which players must be inside of to affect the control percentages
- red_starting_percent = 100 -- Amount of control Red Team has over their own base at the beginning of the game
- blue_starting_percent = 100 -- Amount of control Blue Team has over their own base at the beginning of the game
- red_max_percent = 100 -- Maximum amount of control Red Team can have over their own base
- blue_max_percent = 100 -- Maximum amount of control Blue Team can have over their own base
- -- Don't mess with these
- red_base = {}
- blue_base = {}
- red_conquest = false
- blue_conquest = false
- red_base_contested = false
- blue_base_contested = false
- red_empty = true
- blue_empty = true
- red_percent = red_starting_percent
- blue_percent = blue_starting_percent
- messages = {}
- command_execute = false
- function GetRequiredVersion()
- return 10057
- end
- function OnScriptLoad(process)
- end
- function OnScriptUnload()
- end
- function OnNewGame(map)
- redzone = registertimer(10, "PlayersInRedZone")
- bluezone = registertimer(10, "PlayersInBlueZone")
- scoretimer = registertimer(500, "ScoreTimer")
- end
- function OnGameEnd(mode)
- if mode == 1 then
- removetimer(redzone)
- removetimer(bluezone)
- elseif mode == 2 then
- removetimer(scoretimer)
- end
- end
- function OnServerChat(player, chattype, message)
- return 1
- end
- function OnServerCommand(player, command)
- local hash = gethash(player)
- if hash then
- if not command_execute then
- command_execute = true
- local str = svcmd(command, player)
- messages[hash].str = str
- messages[hash].time = 10
- return 0
- end
- end
- command_execute = false
- return 1
- end
- function OnTeamDecision(team)
- return team
- end
- function OnPlayerJoin(player, team)
- local hash = gethash(player)
- messages[hash] = {}
- end
- function OnPlayerLeave(player, team)
- local hash = gethash(player)
- messages[hash] = {}
- end
- function OnPlayerKill(killer, victim, mode)
- end
- function OnKillMultiplier(player, multiplier)
- end
- function OnPlayerSpawn(player, m_objId)
- end
- function OnPlayerSpawnEnd(player, m_objId)
- end
- function OnTeamChange(relevant, player, cur_team, dest_team)
- return 1
- end
- function OnObjectCreation(m_objId, player, tagName)
- if tagName == "weapons\\flag\\flag" then
- local m_object = getobject(m_objId)
- local team = readbyte(m_object, 0xB8)
- if team == 0 then
- red_base = pack(getobjectcoords(m_objId))
- else
- blue_base = pack(getobjectcoords(m_objId))
- end
- end
- end
- function OnObjectInteraction(player, m_objId, tagType, tagName)
- if tagName == "weapons\\flag\\flag" then
- return 0
- end
- return 1
- end
- function OnWeaponAssignment(player, m_objId, slot, tagName)
- return 0
- end
- function OnWeaponReload(player, m_weapId)
- return 1
- end
- function OnDamageLookup(receiver, causer, tagData, tagName)
- end
- function OnVehicleEntry(relevant, player, m_vehicleId, tagName, seat)
- return 1
- end
- function OnVehicleEject(player, forced)
- return 1
- end
- function OnClientUpdate(player, m_objId)
- end
- function pack(...)
- return {...}
- end
- function inSphere(m_objId, x, y, z, r)
- local ox, oy, oz = getobjectcoords(m_objId)
- local x_dist = x - ox
- local y_dist = y - oy
- local z_dist = z - oz
- local dist = math.sqrt(x_dist ^ 2 + y_dist ^ 2 + z_dist ^ 2)
- if dist <= r then
- return true
- end
- end
- function PlayersInRedZone(id, count)
- local x, y, z = unpack(red_base)
- if x then
- local reds = 0
- local blues = 0
- for i = 0,15 do
- if gethash(i) then
- local team = getteam(i)
- local m_player = getplayer(i)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- if inSphere(m_objId, x, y, z, base_radius) then
- if team == 1 then
- blues = blues + 1
- else
- reds = reds + 1
- end
- end
- end
- end
- end
- if blues > 0 and reds == 0 then
- blue_conquest = true
- red_base_contested = false
- red_empty = false
- red_percent = red_percent - 0.05
- if math.ceil(red_percent) <= 0 then
- red_percent = 0
- say("Blue Team wins!")
- svcmd("sv_map_next")
- return 0
- end
- elseif blues > 0 and reds > 0 then
- blue_conquest = false
- red_base_contested = true
- red_empty = false
- elseif reds > 0 and blues == 0 then
- blue_conquest = false
- red_base_contested = false
- red_empty = false
- if red_percent < red_max_percent then
- red_percent = red_percent + 0.05
- else
- red_percent = red_max_percent
- end
- elseif reds == 0 and blues == 0 then
- blue_conquest = false
- red_base_contested = false
- red_empty = true
- end
- end
- return 1
- end
- function PlayersInBlueZone(id, count)
- local x, y, z = unpack(blue_base)
- if x then
- local blues = 0
- local reds = 0
- for i = 0,15 do
- if gethash(i) then
- local team = getteam(i)
- local m_player = getplayer(i)
- local m_objId = readdword(m_player, 0x34)
- local m_object = getobject(m_objId)
- if m_object then
- if inSphere(m_objId, x, y, z, base_radius) then
- if team == 0 then
- reds = reds + 1
- else
- blues = blues + 1
- end
- end
- end
- end
- end
- if reds > 0 and blues == 0 then
- red_conquest = true
- blue_base_contested = false
- blue_empty = false
- blue_percent = blue_percent - 0.05
- if math.ceil(blue_percent) <= 0 then
- blue_percent = 0
- say("Red Team wins!")
- svcmd("sv_map_next")
- return 0
- end
- elseif reds > 0 and blues > 0 then
- red_conquest = false
- blue_base_contested = true
- blue_empty = false
- elseif blues > 0 and reds == 0 then
- red_conquest = false
- blue_base_contested = false
- blue_empty = false
- if blue_percent < blue_max_percent then
- blue_percent = blue_percent + 0.05
- else
- blue_percent = blue_max_percent
- end
- elseif blues == 0 and reds == 0 then
- red_conquest = false
- blue_base_contested = false
- blue_empty = true
- end
- end
- return 1
- end
- function ScoreTimer(id, count)
- for i = 0,15 do
- local hash = gethash(i)
- if hash then
- local newlines = ""
- for x = 1,30 do
- newlines = newlines .. " \n"
- end
- hprintf(newlines, i)
- local red_message = "Red Base Control: " .. math.round(red_percent, 2) .. "%"
- local blue_message = "Blue Base Control: " .. math.round(blue_percent, 2) .. "%"
- if blue_conquest then
- red_message = "- " .. red_message
- end
- if red_conquest then
- blue_message = "- " .. blue_message
- end
- if red_base_contested then
- red_message = red_message .. " (Contested)"
- end
- if blue_base_contested then
- blue_message = blue_message .. " (Contested)"
- end
- if not blue_conquest and not red_base_contested and red_percent < red_max_percent and not red_empty then
- red_message = "+ " .. red_message
- end
- if not red_conquest and not blue_base_contested and blue_percent < blue_max_percent and not blue_empty then
- blue_message = "+ " .. blue_message
- end
- if messages[hash].str then
- messages[hash].time = messages[hash].time - 0.5
- if messages[hash].time > 0 then
- hprintf(messages[hash].str, i)
- else
- messages[hash].str = nil
- messages[hash].time = nil
- end
- end
- hprintf(red_message, i)
- hprintf(blue_message, i)
- end
- end
- return 1
- end
- function math.round(input, precision)
- return math.floor(input * (10 ^ precision) + 0.5) / (10 ^ precision)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement