Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clan = "[CnR]"
- server = "Police Chase"
- --By: Soap, Superzilla
- --Some contributions by Wizard, or taken from his scripts
- hide_speed = 5
- clan_tags = {}
- hidden = {}
- muted = {}
- falldamage = 0
- vehidamage = 0
- messages = {}
- weapontotal = 3
- function GetRequiredVersion()
- return 10057
- end
- function OnScriptLoad(process)
- registertimer(10, "hide")
- registertimer(1000*60*1, "servertimer")
- registertimer(500, "HprintTimer")
- end
- function OnScriptUnload()
- end
- function OnNewGame(map)
- end
- function OnGameEnd(mode)
- end
- function OnServerChat(player, chattype, message)
- local response = 1
- local hash = gethash(player)
- local name = getname(player)
- local first_character = string.sub(message, 1, 1)
- if first_character == "@" then -- public commands
- local message = string.sub(message, 2)
- local count = gettokencount(message, " ")
- t = {}
- for i=1,count do
- local word = gettoken(message, " ", i - 1)
- word = string.lower(word)
- word = word:gsub('"', "")
- table.insert(t, word)
- end
- if t[1] == "rules" then
- privateSay(player, "============================ CnR Rules ============================")
- privateSay(player, " The CnR rules and info are sperated into sections below. Type the section command to look at each one.")
- privateSay(player, " - For rules on crouching, type @crouch.")
- privateSay(player, " - For rules on jail, type @jail.")
- privateSay(player, " - For general rules, type @general.")
- privateSay(player, " - For joining information, type @join.")
- elseif t[1] == "crouch" then
- privateSay(player, "============================ CnR Crouch Rules ============================")
- privateSay(player, "Rule #1 - Do not crouch kill.")
- privateSay(player, " - Whenever a player crouches, this means that they surrender.")
- privateSay(player, " - After a player surrenders, they must go to the other team's jail.")
- privateSay(player, "Rule #2 - Do not fake crouch.")
- privateSay(player, " - This means that you can not hurt or kill anybody while crouched.")
- privateSay(player, " - Once you crouch, there is no turning back.")
- elseif t[1] == "jail" then
- privateSay(player, "============================ CnR Jail Rules ============================")
- privateSay(player, "Rule #3 - Do not jail kill.")
- privateSay(player, " - The jail is located under the flag. A player goes to jail after they crouch.")
- privateSay(player, " - The player in jail cannot be killed unless they step out of jail or escape.")
- privateSay(player, "Rule #4 - Do not guard kill.")
- privateSay(player, " - Everytime you go to jail, you have to be guarded by guards of the opisite team.")
- privateSay(player, " - You can only escape jail for two reasons: all the guards leave, or if all your")
- privateSay(player, " buds come to break you out.")
- elseif t[1] == "general" then
- privateSay(player, "============================ CnR General Rules ============================")
- privateSay(player, "Rule #5 - Do not swear, cuss, or curse.")
- privateSay(player, " - There is a swear filter in the server. Do not try to bypass it.")
- privateSay(player, " - You have 3 warnings till you are kicked.")
- privateSay(player, "Rule #6 - Respect the CnR Server, all players, recruits, members, and admins.")
- privateSay(player, " - Don't test a admin. They will kick you if you make them mad.")
- privateSay(player, "Rule #7 - Do not use caps.")
- privateSay(player, " - This represents yelling in the server and will not be tolerated.")
- elseif t[1] == "join" then
- privateSay(player, "You may become a CnR Recruit, and wear recruit tags ingame if you go to: http://www.cnrclan.net")
- elseif t[1] == "suicide" then
- kill(player)
- end
- response = 0
- elseif first_character == "/" then -- admin commands
- if string.sub(message, 2, player) ~= "reloadscripts" then
- svcmd("sv_" .. string.sub(message, 2), player)
- else
- hprintf("You cannot use this command.")
- end
- response = 0
- end
- return response
- end
- function OnServerCommand(player, command)
- local response = 1
- local hash = gethash(player)
- local name = getname(player)
- local toksize = getcmdtokencount(command)
- local cmd = getcmdtoken(command, 0)
- local count = gettokencount(command, " ")
- t = {}
- -- insert the tokens into a table
- for i=1,count do
- local word = gettoken(command, " ", i - 1)
- word = string.lower(word)
- word = word:gsub('"', "")
- table.insert(t, word)
- end
- if t[1] == "sv_hide" then
- if hidden[hash] == nil then
- local id = resolveplayer(player)
- local m_objectId = getplayerobjectid(player)
- local m_object = getobject(m_objectId)
- for i=1,weapontotal do -- change if you have 3-weap mod
- local weaps = {0x2F8, 0x2FC, 0x300, 0x304}
- local ammo = {}
- local weap_id = readdword(m_object, weaps[i])
- local weap_obj = getobject(weap_id)
- if weap_obj ~= nil then
- ammo[i] = {
- readdword(weap_obj, 0x2B6),
- readdword(weap_obj, 0x2B8),
- readdword(weap_obj, 0x2C2),
- readdword(weap_obj, 0x2C4),
- }
- writedword(weap_obj, 0x2B6, 0)
- writedword(weap_obj, 0x2B8, 0)
- writedword(weap_obj, 0x2C2, 0)
- writedword(weap_obj, 0x2C4, 0)
- end
- updateammo(weap_id)
- end
- -- store player coords for later use
- hidden[hash] = {readfloat(m_object, 0x5C), readfloat(m_object, 0x60), readfloat(m_object, 0x64)}
- setspeed(player, hide_speed)
- privateSay(player, "*** YOU ARE NOW COMPLETELY INVISIBLE ***")
- privateSay(player, "Do not kill or disrupt the flow of the game while hidden.")
- privateSay(player, "Failure to use the hide command responsibly will result in your admin being suspended.")
- end
- response = 0
- elseif t[1] == "sv_unhide" then
- if hidden[hash] ~= nil then
- local id = resolveplayer(player)
- local m_objectId = getplayerobjectid(player)
- local m_object = getobject(m_objectId)
- for i=1,2 do -- change if you have 3-weap mod
- local weaps = {0x2F8, 0x2FC, 0x300, 0x304}
- local weap_id = readdword(m_object, weaps[i])
- local weap_obj = getobject(weap_id)
- if weap_obj ~= nil then
- writedword(weap_obj, 0x2B6, 45)
- writedword(weap_obj, 0x2B8, 0)
- writedword(weap_obj, 0x2C2, 45)
- writedword(weap_obj, 0x2C4, 0)
- end
- updateammo(weap_id)
- end
- end
- setspeed(player, 1)
- -- teleport player back to original location
- svcmd("sv_teleport " .. player + 1 .. " " .. hidden[hash][1] .. " " .. hidden[hash][2] .. " " .. hidden[hash][3])
- -- clear data
- hidden[hash] = nil
- hprintf("You have been unhidden, and teleported back to your original location!")
- response = 0
- elseif t[1] == "sv_sayrules" then
- registertimer(2000, "rules")
- response = 0
- elseif t[1] == "sv_myobj" then
- local m_player = getplayer(player)
- local m_objectId = getplayerobjectid(player)
- local m_object = getobject(m_objectId)
- Say(m_player)
- Say(m_objectId)
- Say(m_object)
- end
- return response
- end
- function OnTeamDecision(cur_team)
- if getteamsize(0) >= getteamsize(1) then
- return 1
- else
- return 0
- end
- end
- function OnPlayerJoin(player, team)
- end
- function OnPlayerLeave(player, team)
- end
- function OnPlayerKill(killer, victim, mode)
- end
- function OnKillMultiplier(player, multiplier)
- end
- function OnPlayerSpawn(player, m_objectId)
- end
- function OnPlayerSpawnEnd(player, m_objectId)
- if weapontotal == 3 then
- local weapobj3 = createobject("weap", "weapons\\plasma pistol\\plasma pistol", 0, 0, false, 0, 0, 0)
- assignweapon(player, weapobj3)
- end
- end
- function OnTeamChange(relevant, player, team, dest_team)
- return 1
- end
- function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
- Say(tagName)
- local hash = gethash(player)
- local response = 1
- if tagType == "weap" then
- if tagName == "weapons\\flag\\flag" then
- response = 0
- end
- end
- return response
- end
- function OnWeaponReload(player, weapon)
- return 1
- end
- function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat)
- local hash = gethash(player)
- local response = 1
- if hidden[hash] ~= nil then
- response = 0
- end
- return response
- end
- function OnVehicleEject(player, forceEject)
- return 1
- end
- function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
- if causing_obj ~= -1 and causing_obj ~= nil then
- if tagname == "globals\\falling" then
- if falldamage == 0 then
- local min_dmg = readfloat(tagdata, 0x1D0)
- local max_dmg_min = readfloat(tagdata, 0x1D4)
- local max_dmg_max = readfloat(tagdata, 0x1D8)
- writefloat(tagdata, 0x1D0, min_dmg * 0.00001)
- writefloat(tagdata, 0x1D4, max_dmg_min * 0.00001)
- writefloat(tagdata, 0x1D8, max_dmg_max * 0.00001)
- end
- end
- if tagname == "globals\\vehicle_collision" or
- tagname == "globals\\vehicle_kiled_unit" then
- if vehidamage == 0 then
- writefloat(tagdata, 0x1D0, 0)
- writefloat(tagdata, 0x1D4, 0)
- writefloat(tagdata, 0x1D8, 0)
- end
- end
- Say(readword(causing_obj, 0x43E))
- end
- end
- function OnWeaponAssignment(player, object, count, tag)
- end
- function OnObjectCreation(m_objectId, player_owner, tag)
- end
- function hide(id, count)
- for player = 0, 15 do
- local hash = gethash(player)
- if hidden[hash] ~= nil then
- local m_player = getplayer(player)
- local m_objectId = getplayerobjectid(player)
- local m_object = getobject(m_objectId)
- local x = 0.678638
- local y = -164.587585
- local z = 15.038022
- writefloat(m_player, 0xF8, 9999) -- Moves the visibility of the player somewhere else
- writefloat(m_player, 0xFC, 9999) -- Moves the visibility of the player somewhere else
- writefloat(m_player, 0x100, 9999) -- Moves the visibility of the player somewhere else
- writefloat(m_object, 0x170, x) -- Moves the coords that the player will be damaged to
- writefloat(m_object, 0x174, y) -- Moves the coords that the player will be damaged to
- writefloat(m_object, 0x178, z) -- Moves the coords that the player will be damaged to
- end
- end
- return 1
- end
- function servertimer(id, count)
- svcmd("sv_teams_balance")
- if count % 2 == 0 then svcmd("sv_sayrules") end
- return 1
- end
- function rules(id, count)
- if count == 1 then
- Say("Reds are robbers. Blues are cops. No swearing.")
- return 1
- elseif count == 2 then
- Say("Crouch to surrender. Jails are located in bases.")
- return 1
- elseif count == 3 then
- Say("Do not kill crouched players, do not kill while crouched.")
- return 1
- elseif count == 4 then
- Say("Do not kill prisoners, do not kill while a prisoner.")
- return 0
- end
- end
- Say = function(message) -- Made by Wizard
- message = message or "EPIC FAIL"
- for i = 0,15 do
- if getplayer(i) ~= nil then
- privateSay(i, message)
- end
- end
- end
- privateSay = function(player, message, time) -- Made by Wizard
- time = time or 5
- local hash = gethash(player)
- if hash ~= nil then
- if messages[hash] == nil then messages[hash] = {} end
- table.insert(messages[hash], {["message"] = message, ["time"] = time})
- end
- end
- HprintTimer = function(id, count) -- Made by Wizard
- if messages ~= {} then
- for k,v in pairs(messages) do
- if messages[k] ~= {} then
- for key,value in ipairs(messages[k]) do
- messages[k][key].time = messages[k][key].time - 0.5
- if messages[k][key].time < 0 then
- table.remove(messages[k], key)
- end
- end
- end
- end
- for k,v in pairs(messages) do
- if #messages[k] > 0 then
- local player = hashToPlayer(k)
- for i = 1, 30 do
- hprintf(" ", player)
- end
- for key,value in ipairs(messages[k]) do
- hprintf(messages[k][key].message, player)
- end
- end
- end
- end
- return 1
- end
- hashToPlayer = function(hash) -- Made by wizard
- for i = 0, 15 do
- if gethash(i) == hash then
- return i
- end
- end
- return nil
- end
- -- Function created by Chalonic
- function getobjecttag(m_objId)
- local m_object = getobject(m_objId)
- local object_map_id = readdword(m_object, 0x0)
- local map_pointer = 0x460678
- local map_base = readdword(map_pointer, 0x0)
- local map_tag_count = todec(endian(map_base, 0xC, 0x3))
- local tag_table_base = map_base + 0x28
- local tag_table_size = 0x20
- for i = 0, (map_tag_count - 1) do
- local tag_id = todec(endian(tag_table_base, 0xC + (tag_table_size * i), 0x3))
- if tag_id == object_map_id then
- local tag_class = readstring(tag_table_base, (tag_table_size * i), 0x3, 1)
- local tag_name_address = endian(tag_table_base, 0x10 + (tag_table_size * i), 0x3)
- local tag_name = readtagname("0x" .. tag_name_address)
- return tag_class, tag_name
- end
- end
- end
- -- The following functions were created by Smiley
- function readstring(address, offset, length, endian)
- local char_table = {}
- local string = ""
- for i=0,length do
- if readbyte(address, (offset + (0x1 * i))) ~= 0 then
- table.insert(char_table, string.char(readbyte(address, (offset + (0x1 * i)))))
- end
- end
- for k,v in pairs(char_table) do
- if endian == 1 then
- string = v .. string
- else
- string = string .. v
- end
- end
- return string
- end
- function readtagname(address)
- local char_table = {}
- local i = 0
- local string = ""
- while readbyte(address, (0x1 * i)) ~= 0 do
- table.insert(char_table, string.char(readbyte(address, (0x1 * i))))
- i = i + 1
- end
- for k,v in pairs(char_table) do
- string = string .. v
- end
- return string
- end
- function endian(address, offset, length)
- local data_table = {}
- local data = ""
- for i=0,length do
- local hex = string.format("%X", readbyte(address, offset + (0x1 * i)))
- if tonumber(hex, 16) < 16 then
- hex = 0 .. hex
- end
- table.insert(data_table, hex)
- end
- for k,v in pairs(data_table) do
- data = v .. data
- end
- return data
- end
- function todec(number)
- return tonumber(number, 16)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement