Advertisement
Guest User

Untitled

a guest
Sep 14th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.18 KB | None | 0 0
  1. -- Gravity Rifle
  2.  
  3. -- Pick up vehicles by shooting them with your plasma rifle.  Shoot them again while they are suspended in front of you to fire them.  Kill people.
  4. -- If you have any questions or comments, PM me (Nuggets) at phasor.proboards.com.
  5.  
  6. gravity = {}
  7. vehicles = {}
  8. activetime = {}
  9.  
  10. function GetRequiredVersion()
  11.  
  12.     return 200
  13. end
  14.  
  15. function OnScriptLoad(processId, game, persistent)
  16.  
  17.    
  18. end
  19.  
  20. --[[
  21. function OnScriptUnload()
  22.  
  23.  
  24. end
  25. --]]
  26.  
  27. --[[
  28. function OnNewGame(map)
  29.  
  30.  
  31. end
  32. --]]
  33.  
  34. --[[
  35. function OnGameEnd(stage)
  36.  
  37.     -- stage 1: F1 Screen
  38.     -- stage 2: PGCR Appears
  39.     -- stage 3: Players may quit
  40. end
  41. --]]
  42.  
  43. --[[
  44. function OnServerChat(player, type, message)
  45.    
  46.     --return true, message, type
  47. end
  48. --]]
  49.  
  50. --[[
  51. function OnServerCommandAttempt(player, command, password)
  52.  
  53.     --return true
  54. end
  55. --]]
  56.  
  57. --[[
  58. function OnServerCommand(admin, command)
  59.  
  60.     --return true
  61. end
  62. --]]
  63.  
  64. --[[
  65. function OnNameRequest(hash, name)
  66.  
  67.     --return true, name
  68. end
  69. --]]
  70.  
  71. --[[
  72. function OnBanCheck(hash, ip)
  73.    
  74.     --return true
  75. end
  76. --]]
  77.  
  78. --[[
  79. function OnPlayerJoin(player)
  80.  
  81.  
  82. end
  83. --]]
  84.  
  85. function OnPlayerLeave(player)
  86.  
  87.     gravity[player] = nil
  88. end
  89.  
  90. function OnPlayerKill(killer, victim, mode)
  91.  
  92.     gravity[victim] = nil
  93. end
  94.  
  95. --[[
  96. function OnKillMultiplier(player, multiplier)
  97.  
  98.     -- Multipliers:
  99.     -- 7: Double Kill
  100.     -- 9: Triple Kill
  101.     -- 10: Killtacular
  102.     -- 11: Killing Spree
  103.     -- 12: Running Riot
  104.     -- 16: Double Kill w/ Score
  105.     -- 17: Triple Kill w/ Score
  106.     -- 14: Killtacular w/ Score
  107.     -- 18: Killing Spree w/ Score
  108.     -- 17: Running Riot w/ Score
  109. end
  110. --]]
  111.  
  112. --[[
  113. function OnPlayerSpawn(player)
  114.    
  115.  
  116. end
  117. --]]
  118. function OnPlayerSpawnEnd(player)
  119.     if getteam(player) == 1 then -- blue team
  120.         for i = 0,3 do
  121.             local m_objectId = getplayerobjectid(player)
  122.             local m_object = getobject(m_objectId)
  123.             if m_object then
  124.                 local weapID = readdword(m_object + 0x2F8 + i*4)
  125.                 local weap = getobject(weapID)
  126.                 if weap then
  127.                     destroyobject(weapID)
  128.                 end
  129.             end
  130.         end
  131.         local gun = createobject(gettagid("weap", "weapons\\shotgun\\shotgun"), 0, 1, false, 0, 0, 0)
  132.         if getobject(gun) then
  133.             assignweapon(player, gun)
  134.         end
  135.         registertimer(100, 'delay', player)
  136.     end
  137. end
  138.  
  139. function delay(id, count, player)
  140.  
  141.     if getplayer(player) then
  142.         takeammoaway(player)
  143.     end
  144.     return false
  145. end
  146.  
  147. function OnWeaponAssignment(player, objId, slot, weapId)
  148.    
  149.     if getteam(player) == 1 then -- blue team
  150.         return gettagid("weap", "weapons\\shotgun\\shotgun")
  151.     else
  152.         return gettagid("weap", "weapons\\plasma rifle\\plasma rifle")
  153.     end
  154. end
  155.  
  156. --[[
  157. function OnWeaponReload(player, weapId)
  158.  
  159.     --return true
  160. end
  161. --]]
  162.  
  163. --[[
  164. function OnObjectCreationAttempt(mapId, parentId, player)
  165.    
  166.     --return mapId
  167. end
  168. --]]
  169.  
  170. --[[
  171. function OnObjectCreation(objId)
  172.  
  173.  
  174. end
  175. --]]
  176.  
  177. --[[
  178. function OnObjectInteraction(player, objId, mapId)
  179.  
  180.  
  181. end
  182. --]]
  183.  
  184. --[[
  185. function OnTeamDecision(team)
  186.    
  187.     --return team
  188. end
  189. --]]
  190.  
  191. --[[
  192. function OnTeamChange(player, old_team, new_team, voluntary)
  193.    
  194.     --return true
  195. end
  196. --]]
  197.  
  198. function takeammoaway(player)
  199.     local m_objectId = getplayerobjectid(player)
  200.     local m_object = getobject(m_objectId)
  201.     if m_object then
  202.         for i = 0, 3 do
  203.             local m_weaponId = readdword(m_object + 0x2F8 + i*4)
  204.             if m_weaponId then
  205.                 local m_weapon = getobject(m_weaponId)
  206.                 if m_weapon then
  207.                     writeword(m_weapon + 0x2B6, 0)
  208.                     writeword(m_weapon + 0x2B8, 0)
  209.                     writefloat(m_weapon + 0x240, math.abs(0 - 1))
  210.                     updateammo(m_weaponId)
  211.                 end
  212.             end
  213.         end
  214.     end
  215. end
  216.  
  217. function OnDamageLookup(receiver, causer, mapId)
  218.    
  219.     local tagname = gettaginfo(mapId)
  220.     local rplayer, cplayer = nil, nil
  221.     if receiver ~= nil then
  222.         if getobject(receiver) then
  223.             if tonumber(receiver) then
  224.                 local rplayer = objectidtoplayer(receiver)
  225.             end
  226.         end
  227.     end
  228.     if causer ~= nil then
  229.         if getobject(causer) then
  230.             if tonumber(causer) then
  231.                 local cplayer = objectidtoplayer(causer)
  232.             end
  233.         end
  234.     end
  235.    
  236.     if cplayer and rplayer ~= nil then
  237.         if getteam(cplayer) == getteam(rplayer) then
  238.             return false
  239.         end
  240.     end
  241.    
  242.     if tagname == "weapons\\plasma rifle\\bolt" then
  243.         local player = objectidtoplayer(causer)
  244.         if player then
  245.             local m_causer = getobject(causer)
  246.             local m_receiver = getobject(receiver)
  247.             if m_receiver and m_causer then
  248.                 local mapId = readdword(m_receiver)
  249.                 local tagname, tagtype = gettaginfo(mapId)
  250.                 if tagtype == "vehi" then
  251.                     if gravity[player] then
  252.                         gravity[player] = nil
  253.                         writebit(m_receiver + 0x10, 5, 0)
  254.                         local x_aim = readfloat(m_causer, 0x230)
  255.                         local y_aim = readfloat(m_causer, 0x234)
  256.                         local z_aim = readfloat(m_causer, 0x238)
  257.                         local vel = 1
  258.                         writefloat(m_receiver, 0x68, vel * math.sin(x_aim))
  259.                         writefloat(m_receiver, 0x6C, vel * math.sin(y_aim))
  260.                         writefloat(m_receiver, 0x70, vel * math.sin(z_aim))
  261.                         registertimer(10, "ActiveVehicle", {receiver, player})
  262.                     else
  263.                         local bool
  264.                        
  265.                         for p,r in pairs(gravity) do
  266.                             if r == receiver then
  267.                                 bool = true
  268.                             end
  269.                         end
  270.                        
  271.                         if not bool then
  272.                             gravity[player] = receiver
  273.                             vehicles[receiver] = player
  274.                             writebit(m_receiver + 0x10, 5, 0)
  275.                             local m_player = getplayer(player)
  276.                             local xy_aim = readfloat(m_player, 0x138)
  277.                             local z_aim = readfloat(m_player, 0x13C)
  278.                             local dist = 4
  279.                             local x = readfloat(m_causer, 0x5C)
  280.                             local y = readfloat(m_causer, 0x60)
  281.                             local z = readfloat(m_causer, 0x64)
  282.                             writefloat(m_receiver, 0x5C, x + dist * math.cos(xy_aim))
  283.                             writefloat(m_receiver, 0x60, y + dist * math.sin(xy_aim))
  284.                             writefloat(m_receiver, 0x64, z + dist * math.sin(z_aim) + 0.5)
  285.                             writefloat(m_receiver, 0x68, 0)
  286.                             writefloat(m_receiver, 0x6C, 0)
  287.                             writefloat(m_receiver, 0x70, 0)
  288.                             local angular_velocity_x = readfloat(m_receiver, 0x8C)
  289.                             local angular_velocity_y = readfloat(m_receiver, 0x90)
  290.                             local angular_velocity_z = readfloat(m_receiver, 0x94)
  291.                             writefloat(m_receiver, 0x8C, .2)
  292.                             writefloat(m_receiver, 0x90, .3)
  293.                             writefloat(m_receiver, 0x94, .05)
  294.                         end
  295.                     end
  296.                 end
  297.             end
  298.         end
  299.    
  300.     elseif tagname == "globals\\vehicle_collision" then
  301.    
  302.         if vehicles[causer] then
  303.             local m_player = getplayer(vehicles[causer])
  304.             if m_player then
  305.                 local objId = readdword(m_player, 0x34)
  306.                 applydmgtag(receiver, gettagid("jpt!", "weapons\\rocket launcher\\explosion"), 500, objId)
  307.                 return false
  308.             end
  309.         end
  310.     end
  311. end
  312.  
  313. --[[
  314. function OnDamageApplication(receiver, causer, mapId, location, backtap)
  315.    
  316.     --return true
  317. end
  318. --]]
  319.  
  320. --[[
  321. function OnVehicleEntry(player, vehiId, seat, mapId, voluntary)
  322.    
  323.     --return true
  324. end
  325. --]]
  326.  
  327. --[[
  328. function OnVehicleEject(player, voluntary)
  329.  
  330.     --return true
  331. end
  332. --]]
  333.  
  334. function OnClientUpdate(player)
  335.  
  336.     local vehiId = gravity[player]
  337.     if vehiId then
  338.         local m_player = getplayer(player)
  339.         local objId = readdword(m_player, 0x34)
  340.         local m_object = getobject(objId)
  341.         local m_vehicle = getobject(vehiId)
  342.         local x_aim = readfloat(m_object, 0x230)
  343.         local y_aim = readfloat(m_object, 0x234)
  344.         local z_aim = readfloat(m_object, 0x238)
  345.         local x = readfloat(m_object, 0x5C)
  346.         local y = readfloat(m_object, 0x60)
  347.         local z = readfloat(m_object, 0x64)
  348.         local dist = 4
  349.         writefloat(m_vehicle, 0x5C, x + dist * math.sin(x_aim))
  350.         writefloat(m_vehicle, 0x60, y + dist * math.sin(y_aim))
  351.         writefloat(m_vehicle, 0x64, z + dist * math.sin(z_aim) + 0.5)
  352.         writefloat(m_vehicle, 0x68, 0)
  353.         writefloat(m_vehicle, 0x6C, 0)
  354.         writefloat(m_vehicle, 0x70, 0.01285)
  355.     end
  356. end
  357.  
  358. function ActiveVehicle(id, count, info)
  359.  
  360.     local vehiId = info[1]
  361.     local player = info[2]
  362.     local m_vehicle = getobject(vehiId)
  363.     if m_vehicle then
  364.         if vehicles[vehiId] == player then
  365.             if getplayer(player) then
  366.                 local vx = readfloat(m_vehicle, 0x68)
  367.                 local vy = readfloat(m_vehicle, 0x6C)
  368.                 local vz = readfloat(m_vehicle, 0x70)
  369.                 local velocity = math.sqrt(vx ^ 2 + vy ^ 2 + vz ^ 2)
  370.                 if velocity == 0 then
  371.                     activetime[vehiId] = activetime[vehiId] or 100 - 1
  372.                     if activetime[vehiId] <= 0 then
  373.                         vehicles[vehiId] = nil
  374.                         return false
  375.                     end
  376.                 end
  377.             end
  378.         else
  379.             return false
  380.         end
  381.     end
  382.    
  383.     return true
  384. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement