Advertisement
superzilla

CnR8.1

May 12th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.87 KB | None | 0 0
  1.  
  2. clan = "[CnR]"
  3. server = "Police Chase"
  4. --By: Soap, Superzilla
  5. --Some contributions by Wizard, or taken from his scripts
  6.  
  7. hide_speed = 5
  8. clan_tags = {}
  9. hidden = {}
  10. muted = {}
  11. falldamage = 0
  12. vehidamage = 0
  13. messages = {}
  14. weapontotal = 3
  15.  
  16.  
  17. function GetRequiredVersion()
  18.     return 10057
  19. end
  20.  
  21.  
  22. function OnScriptLoad(process)
  23.  
  24.     registertimer(10, "hide")
  25.     registertimer(1000*60*1, "servertimer")
  26.     registertimer(500, "HprintTimer")
  27.  
  28. end
  29.  
  30.  
  31. function OnScriptUnload()
  32. end
  33.  
  34.  
  35. function OnNewGame(map)
  36. end
  37.  
  38.  
  39. function OnGameEnd(mode)
  40.  
  41. end
  42.  
  43.  
  44. function OnServerChat(player, chattype, message)
  45.  
  46.     local response = 1
  47.     local hash = gethash(player)
  48.     local name = getname(player)
  49.  
  50.     local first_character = string.sub(message, 1, 1)
  51.  
  52.     if first_character == "@" then -- public commands
  53.  
  54.         local message = string.sub(message, 2)
  55.         local count = gettokencount(message, " ")
  56.         t = {}
  57.  
  58.         for i=1,count do
  59.             local word = gettoken(message, " ", i - 1)
  60.             word = string.lower(word)
  61.             word = word:gsub('"', "")
  62.             table.insert(t, word)
  63.         end
  64.  
  65.         if t[1] == "rules" then
  66.             privateSay(player, "============================ CnR Rules ============================")
  67.             privateSay(player, " The CnR rules and info are sperated into sections below. Type the section command to look at each one.")
  68.             privateSay(player, "    - For rules on crouching, type @crouch.")
  69.             privateSay(player, "    - For rules on jail, type @jail.")
  70.             privateSay(player, "    - For general rules, type @general.")
  71.             privateSay(player, "    - For joining information, type @join.")
  72.         elseif t[1] == "crouch" then
  73.             privateSay(player, "============================ CnR Crouch Rules ============================")
  74.             privateSay(player, "Rule #1 - Do not crouch kill.")
  75.             privateSay(player, "    - Whenever a player crouches, this means that they surrender.")
  76.             privateSay(player, "    - After a player surrenders, they must go to the other team's jail.")
  77.             privateSay(player, "Rule #2 - Do not fake crouch.")
  78.             privateSay(player, "    - This means that you can not hurt or kill anybody while crouched.")
  79.             privateSay(player, "    - Once you crouch, there is no turning back.")
  80.         elseif t[1] == "jail" then
  81.             privateSay(player, "============================ CnR Jail Rules ============================")
  82.             privateSay(player, "Rule #3 - Do not jail kill.")
  83.             privateSay(player, "    - The jail is located under the flag. A player goes to jail after they crouch.")
  84.             privateSay(player, "    - The player in jail cannot be killed unless they step out of jail or escape.")
  85.             privateSay(player, "Rule #4 - Do not guard kill.")
  86.             privateSay(player, "    - Everytime you go to jail, you have to be guarded by guards of the opisite team.")
  87.             privateSay(player, "    - You can only escape jail for two reasons: all the guards leave, or if all your")
  88.             privateSay(player, "    buds come to break you out.")
  89.         elseif t[1] == "general" then
  90.             privateSay(player, "============================ CnR General Rules ============================")
  91.             privateSay(player, "Rule #5 - Do not swear, cuss, or curse.")
  92.             privateSay(player, "    - There is a swear filter in the server. Do not try to bypass it.")
  93.             privateSay(player, "    - You have 3 warnings till you are kicked.")
  94.             privateSay(player, "Rule #6 - Respect the CnR Server, all players, recruits, members, and admins.")
  95.             privateSay(player, "    - Don't test a admin. They will kick you if you make them mad.")
  96.             privateSay(player, "Rule #7 - Do not use caps.")
  97.             privateSay(player, "    - This represents yelling in the server and will not be tolerated.")
  98.         elseif t[1] == "join" then
  99.             privateSay(player, "You may become a CnR Recruit, and wear recruit tags ingame if you go to: http://www.cnrclan.net")
  100.         elseif t[1] == "suicide" then
  101.             kill(player)
  102.         end
  103.  
  104.         response = 0
  105.  
  106.     elseif first_character == "/" then -- admin commands
  107.  
  108.         if string.sub(message, 2, player) ~= "reloadscripts" then
  109.             svcmd("sv_" .. string.sub(message, 2), player)
  110.         else
  111.             hprintf("You cannot use this command.")
  112.         end
  113.  
  114.         response = 0
  115.  
  116.     end
  117.  
  118.  
  119.  
  120.     return response
  121. end
  122.  
  123.  
  124. function OnServerCommand(player, command)
  125.  
  126.     local response = 1
  127.     local hash = gethash(player)
  128.     local name = getname(player)
  129.  
  130.     local toksize = getcmdtokencount(command)
  131.     local cmd = getcmdtoken(command, 0)
  132.     local count = gettokencount(command, " ")
  133.     t = {}
  134.  
  135.     -- insert the tokens into a table
  136.     for i=1,count do
  137.         local word = gettoken(command, " ", i - 1)
  138.         word = string.lower(word)
  139.         word = word:gsub('"', "")
  140.         table.insert(t, word)
  141.     end
  142.  
  143.     if t[1] == "sv_hide" then
  144.  
  145.         if hidden[hash] == nil then
  146.  
  147.             local id = resolveplayer(player)
  148.             local m_objectId = getplayerobjectid(player)
  149.             local m_object = getobject(m_objectId)
  150.  
  151.             for i=1,weapontotal do -- change if you have 3-weap mod
  152.  
  153.                 local weaps = {0x2F8, 0x2FC, 0x300, 0x304}
  154.                 local ammo = {}
  155.                 local weap_id = readdword(m_object, weaps[i])
  156.                 local weap_obj = getobject(weap_id)
  157.  
  158.                 if weap_obj ~= nil then
  159.  
  160.                     ammo[i] = {
  161.                     readdword(weap_obj, 0x2B6),
  162.                     readdword(weap_obj, 0x2B8),
  163.                     readdword(weap_obj, 0x2C2),
  164.                     readdword(weap_obj, 0x2C4),
  165.                     }
  166.  
  167.                     writedword(weap_obj, 0x2B6, 0)
  168.                     writedword(weap_obj, 0x2B8, 0)
  169.                     writedword(weap_obj, 0x2C2, 0)
  170.                     writedword(weap_obj, 0x2C4, 0)
  171.  
  172.                 end
  173.  
  174.                 updateammo(weap_id)
  175.  
  176.             end
  177.  
  178.             -- store player coords for later use
  179.             hidden[hash] = {readfloat(m_object, 0x5C), readfloat(m_object, 0x60), readfloat(m_object, 0x64)}
  180.  
  181.             setspeed(player, hide_speed)
  182.  
  183.             privateSay(player, "*** YOU ARE NOW COMPLETELY INVISIBLE ***")
  184.             privateSay(player, "Do not kill or disrupt the flow of the game while hidden.")
  185.             privateSay(player, "Failure to use the hide command responsibly will result in your admin being suspended.")
  186.  
  187.         end
  188.  
  189.         response = 0
  190.  
  191.  
  192.  
  193.     elseif t[1] == "sv_unhide" then
  194.  
  195.         if hidden[hash] ~= nil then
  196.  
  197.             local id = resolveplayer(player)
  198.             local m_objectId = getplayerobjectid(player)
  199.             local m_object = getobject(m_objectId)
  200.  
  201.             for i=1,2 do -- change if you have 3-weap mod
  202.  
  203.                 local weaps = {0x2F8, 0x2FC, 0x300, 0x304}
  204.                 local weap_id = readdword(m_object, weaps[i])
  205.                 local weap_obj = getobject(weap_id)
  206.  
  207.                 if weap_obj ~= nil then
  208.                     writedword(weap_obj, 0x2B6, 45)
  209.                     writedword(weap_obj, 0x2B8, 0)
  210.                     writedword(weap_obj, 0x2C2, 45)
  211.                     writedword(weap_obj, 0x2C4, 0)
  212.                 end
  213.  
  214.                 updateammo(weap_id)
  215.  
  216.             end
  217.  
  218.         end
  219.  
  220.         setspeed(player, 1)
  221.  
  222.         -- teleport player back to original location
  223.         svcmd("sv_teleport " .. player + 1 .. " " .. hidden[hash][1] .. " " .. hidden[hash][2] .. " " .. hidden[hash][3])
  224.  
  225.         -- clear data
  226.         hidden[hash] = nil
  227.  
  228.         hprintf("You have been unhidden, and teleported back to your original location!")
  229.  
  230.         response = 0
  231.  
  232.     elseif t[1] == "sv_sayrules" then
  233.  
  234.         registertimer(2000, "rules")
  235.         response = 0
  236.  
  237.     elseif t[1] == "sv_myobj" then
  238.         local m_player = getplayer(player)
  239.         local m_objectId = getplayerobjectid(player)
  240.         local m_object = getobject(m_objectId)
  241.         Say(m_player)
  242.         Say(m_objectId)
  243.         Say(m_object)
  244.     end
  245.  
  246.     return response
  247. end
  248.  
  249.  
  250. function OnTeamDecision(cur_team)
  251.  
  252.     if getteamsize(0) >= getteamsize(1) then
  253.         return 1
  254.     else
  255.         return 0
  256.     end
  257.  
  258. end
  259.  
  260.  
  261. function OnPlayerJoin(player, team)
  262. end
  263.  
  264.  
  265. function OnPlayerLeave(player, team)
  266. end
  267.  
  268.  
  269. function OnPlayerKill(killer, victim, mode)
  270. end
  271.  
  272.  
  273. function OnKillMultiplier(player, multiplier)
  274. end
  275.  
  276.  
  277. function OnPlayerSpawn(player, m_objectId)
  278. end
  279.  
  280.  
  281. function OnPlayerSpawnEnd(player, m_objectId)
  282.  
  283.     if weapontotal == 3 then
  284.         local weapobj3 = createobject("weap", "weapons\\plasma pistol\\plasma pistol", 0, 0, false, 0, 0, 0)
  285.         assignweapon(player, weapobj3)
  286.     end
  287.  
  288. end
  289.  
  290. function OnTeamChange(relevant, player, team, dest_team)
  291.     return 1
  292. end
  293.  
  294. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  295.  
  296.     Say(tagName)
  297.  
  298.     local hash = gethash(player)
  299.     local response = 1
  300.  
  301.     if tagType == "weap" then
  302.         if tagName == "weapons\\flag\\flag" then
  303.             response = 0
  304.         end
  305.     end
  306.  
  307.     return response
  308. end
  309.  
  310.  
  311. function OnWeaponReload(player, weapon)
  312.     return 1
  313. end
  314.  
  315.  
  316. function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat)
  317.  
  318.     local hash = gethash(player)
  319.     local response = 1
  320.  
  321.     if hidden[hash] ~= nil then
  322.         response = 0
  323.     end
  324.  
  325.     return response
  326. end
  327.  
  328.  
  329. function OnVehicleEject(player, forceEject)
  330.     return 1
  331. end
  332.  
  333.  
  334. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  335.     if causing_obj ~= -1 and causing_obj ~= nil then
  336.         if tagname == "globals\\falling" then
  337.             if falldamage == 0 then
  338.                 local min_dmg = readfloat(tagdata, 0x1D0)
  339.                 local max_dmg_min = readfloat(tagdata, 0x1D4)
  340.                 local max_dmg_max = readfloat(tagdata, 0x1D8)
  341.                 writefloat(tagdata, 0x1D0, min_dmg * 0.00001)
  342.                 writefloat(tagdata, 0x1D4, max_dmg_min * 0.00001)
  343.                 writefloat(tagdata, 0x1D8, max_dmg_max * 0.00001)
  344.             end
  345.         end
  346.         if tagname == "globals\\vehicle_collision" or
  347.             tagname == "globals\\vehicle_kiled_unit" then
  348.                 if vehidamage == 0 then
  349.                     writefloat(tagdata, 0x1D0, 0)
  350.                     writefloat(tagdata, 0x1D4, 0)
  351.                     writefloat(tagdata, 0x1D8, 0)
  352.                 end
  353.         end
  354.         Say(readword(causing_obj, 0x43E))
  355.     end
  356. end
  357.  
  358.  
  359. function OnWeaponAssignment(player, object, count, tag)
  360. end
  361.  
  362.  
  363. function OnObjectCreation(m_objectId, player_owner, tag)
  364. end
  365.  
  366. function hide(id, count)
  367.  
  368.     for player = 0, 15 do
  369.  
  370.         local hash = gethash(player)
  371.  
  372.         if hidden[hash] ~= nil then
  373.  
  374.             local m_player = getplayer(player)
  375.             local m_objectId = getplayerobjectid(player)
  376.             local m_object = getobject(m_objectId)
  377.  
  378.             local x = 0.678638
  379.             local y = -164.587585
  380.             local z = 15.038022
  381.  
  382.             writefloat(m_player, 0xF8, 9999) -- Moves the visibility of the player somewhere else
  383.             writefloat(m_player, 0xFC, 9999) -- Moves the visibility of the player somewhere else
  384.             writefloat(m_player, 0x100, 9999) -- Moves the visibility of the player somewhere else
  385.  
  386.             writefloat(m_object, 0x170, x) -- Moves the coords that the player will be damaged to
  387.             writefloat(m_object, 0x174, y) -- Moves the coords that the player will be damaged to
  388.             writefloat(m_object, 0x178, z) -- Moves the coords that the player will be damaged to
  389.  
  390.         end
  391.  
  392.     end
  393.  
  394.     return 1
  395. end
  396.  
  397. function servertimer(id, count)
  398.  
  399.     svcmd("sv_teams_balance")
  400.     if count % 2 == 0 then svcmd("sv_sayrules") end
  401.  
  402.     return 1
  403. end
  404.  
  405. function rules(id, count)
  406.  
  407.     if count == 1 then
  408.         Say("Reds are robbers. Blues are cops. No swearing.")
  409.         return 1
  410.     elseif count == 2 then
  411.         Say("Crouch to surrender. Jails are located in bases.")
  412.         return 1
  413.     elseif count == 3 then
  414.         Say("Do not kill crouched players, do not kill while crouched.")
  415.         return 1
  416.     elseif count == 4 then
  417.         Say("Do not kill prisoners, do not kill while a prisoner.")
  418.         return 0
  419.     end
  420.  
  421. end
  422.  
  423. Say = function(message) -- Made by Wizard
  424.     message = message or "EPIC FAIL"
  425.     for i = 0,15 do
  426.         if getplayer(i) ~= nil then
  427.             privateSay(i, message)
  428.         end
  429.     end
  430. end
  431.  
  432. privateSay = function(player, message, time) -- Made by Wizard
  433.  
  434.     time = time or 5
  435.     local hash = gethash(player)
  436.     if hash ~= nil then
  437.         if messages[hash] == nil then messages[hash] = {} end
  438.         table.insert(messages[hash], {["message"] = message, ["time"] = time})
  439.     end
  440. end
  441.  
  442. HprintTimer = function(id, count) -- Made by Wizard
  443.  
  444.     if messages ~= {} then
  445.         for k,v in pairs(messages) do
  446.             if messages[k] ~= {} then
  447.                 for key,value in ipairs(messages[k]) do
  448.                     messages[k][key].time = messages[k][key].time - 0.5
  449.                     if messages[k][key].time < 0 then
  450.                         table.remove(messages[k], key)
  451.                     end
  452.                 end
  453.             end
  454.         end
  455.  
  456.         for k,v in pairs(messages) do
  457.             if #messages[k] > 0 then
  458.                 local player = hashToPlayer(k)
  459.                 for i = 1, 30 do
  460.                     hprintf(" ", player)
  461.                 end
  462.                 for key,value in ipairs(messages[k]) do
  463.                     hprintf(messages[k][key].message, player)
  464.                 end
  465.             end
  466.         end
  467.     end
  468.  
  469.     return 1
  470. end
  471.  
  472. hashToPlayer = function(hash) -- Made by wizard
  473.  
  474.     for i = 0, 15 do
  475.         if gethash(i) == hash then
  476.             return i
  477.         end
  478.     end
  479.  
  480.     return nil
  481. end
  482.  
  483. -- Function created by Chalonic
  484. function getobjecttag(m_objId)
  485.  
  486.     local m_object = getobject(m_objId)
  487.     local object_map_id = readdword(m_object, 0x0)
  488.  
  489.     local map_pointer = 0x460678
  490.     local map_base = readdword(map_pointer, 0x0)
  491.     local map_tag_count = todec(endian(map_base, 0xC, 0x3))
  492.     local tag_table_base = map_base + 0x28
  493.     local tag_table_size = 0x20
  494.  
  495.     for i = 0, (map_tag_count - 1) do
  496.         local tag_id = todec(endian(tag_table_base, 0xC + (tag_table_size * i), 0x3))
  497.  
  498.         if tag_id == object_map_id then
  499.             local tag_class = readstring(tag_table_base, (tag_table_size * i), 0x3, 1)
  500.             local tag_name_address = endian(tag_table_base, 0x10 + (tag_table_size * i), 0x3)
  501.             local tag_name = readtagname("0x" .. tag_name_address)
  502.  
  503.             return tag_class, tag_name
  504.         end
  505.     end
  506. end
  507.  
  508. -- The following functions were created by Smiley
  509.  
  510. function readstring(address, offset, length, endian)
  511.  
  512.     local char_table = {}
  513.     local string = ""
  514.     for i=0,length do
  515.         if readbyte(address, (offset + (0x1 * i))) ~= 0 then
  516.             table.insert(char_table, string.char(readbyte(address, (offset + (0x1 * i)))))
  517.         end
  518.     end
  519.     for k,v in pairs(char_table) do
  520.         if endian == 1 then
  521.             string = v .. string
  522.         else
  523.             string = string .. v
  524.         end
  525.     end
  526.  
  527.     return string
  528. end
  529.  
  530. function readtagname(address)
  531.  
  532.     local char_table = {}
  533.     local i = 0
  534.     local string = ""
  535.     while readbyte(address, (0x1 * i)) ~= 0 do
  536.         table.insert(char_table, string.char(readbyte(address, (0x1 * i))))
  537.         i = i + 1
  538.     end
  539.     for k,v in pairs(char_table) do
  540.         string = string .. v
  541.     end
  542.  
  543.     return string
  544. end
  545.  
  546. function endian(address, offset, length)
  547.  
  548.     local data_table = {}
  549.     local data = ""
  550.     for i=0,length do
  551.         local hex = string.format("%X", readbyte(address, offset + (0x1 * i)))
  552.         if tonumber(hex, 16) < 16 then
  553.             hex = 0 .. hex
  554.         end
  555.         table.insert(data_table, hex)
  556.     end
  557.     for k,v in pairs(data_table) do
  558.         data = v .. data
  559.     end
  560.  
  561.     return data
  562. end
  563.  
  564. function todec(number)
  565.  
  566.     return tonumber(number, 16)
  567.  
  568. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement