Advertisement
th3w1zard1

OnGrenadeToss function

Feb 5th, 2012
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.35 KB | None | 0 0
  1. -- This function is required for scripts to run on Phasor (including and after 01.00.03.104)
  2. -- You should return the minimum required version of Phasor
  3. -- Official releases:
  4. --   01.00.03.104 - 3104
  5. --   01.00.10.057 - 10057
  6.  
  7. tossAnimation = {}
  8. nade = {}
  9.  
  10. function GetRequiredVersion()
  11.     return 10058
  12. end
  13.  
  14. -- called when the script is loaded
  15. function OnScriptLoad(process)
  16. end
  17.  
  18. -- called when the script is unloaded
  19. -- Do not return a value
  20. function OnScriptUnload()
  21. end
  22.  
  23. -- called when a game is starting (before any players join)
  24. -- Do not return a value.
  25. function OnNewGame(map)
  26. end
  27.  
  28. -- called when a game is ending
  29. -- Do not return a value.
  30. function OnGameEnd(mode)
  31.     -- mode 1 = score menu (F1) is being displayed to clients, they are still ingame
  32.     -- mode 2 = post game menu appeared
  33.     -- mode 3 = players can quit via the post game score card
  34. end
  35.  
  36. -- Called when there is chat within the server
  37. -- It must return a value which indicates whether or not the chat is sent.
  38. function OnServerChat(player, chattype, message)
  39.     return 1
  40. end
  41.  
  42. -- Called when a server command is being executed
  43. -- It must return a value which indicates whether or not the command should be processed
  44. -- Note: It is only called when an authenticated (and allowed) player attempts to use the command.
  45. --       player is -1 when being executed via the server console.
  46. function OnServerCommand(player, command)
  47.     return 1
  48. end
  49.  
  50. -- Called when a player's team is being chosen as the join the server.
  51. -- It must return a value which indicates the team the player is to be put on.
  52. -- Note: this function being called doesn't guarantee that the player will be able to successfully join.
  53. function OnTeamDecision(cur_team)
  54.     return cur_team
  55. end
  56.  
  57. -- Called when a player joins the server.
  58. -- Do not return a value.
  59. function OnPlayerJoin(player, team)
  60. end
  61.  
  62. -- Called when a player the server.
  63. -- Do not return a value.
  64. function OnPlayerLeave(player, team)
  65. end
  66.  
  67. -- called when a player kills another, 'killer' is the index of the killing player, 'victim' is the index of the dead player
  68. -- Do not return a value.
  69. function OnPlayerKill(killer, victim, mode)
  70. end
  71.  
  72. -- called when a player gets a double kill, killing spree etc
  73. -- see Phasor documentation for multiplier values
  74. function OnKillMultiplier(player, multiplier)
  75. end
  76.  
  77. -- Called when a player s (after object is created, before players are notified)
  78. -- Do not return a value
  79. function OnPlayerSpawn(player, m_objectId)
  80. end
  81.  
  82. -- Called after clients have been notified of a player spawn
  83. -- Do not return a value
  84. function OnPlayerSpawnEnd(player, m_objectId)
  85.  
  86. end
  87.  
  88. -- Called when a player is attempting to .
  89. -- A value must be returned. The return value indicates whether or not the player is allowed the change team.
  90. -- Notes: If relevant is 1 the return value is considered, if it's 0 then the return value is ignored.
  91. function OnTeamChange(relevant, player, team, dest_team)
  92.     return 1
  93. end
  94.  
  95. -- This is called when a client sends the server an update packet.
  96. -- This includes things such as movement vectors, camera positions, button presses etc.
  97. -- This function is called frequently so care should be taken to keep processing
  98. -- to a minimum.
  99. -- Do not return a value
  100. function OnClientUpdate(player, m_objectId)
  101.  
  102.     local id = resolveplayer(player)
  103.     local m_object = getobject(m_objectId)
  104.     local m_playerObjId = getplayerobjectid(player)
  105.  
  106.     if getobject(readdword(m_object, 0x11C)) == nil then
  107.  
  108.         local rph = readbit(m_object, 0x209, 2) -- right mouse press and hold
  109.         local rph2 = readbit(m_object, 0x209, 3) -- right mouse press and hold
  110.         local frags = readbyte(m_object, 0x31E) -- Confirmed.
  111.         local plasmas = readbyte(m_object, 0x31F) -- Confirmed.
  112.         local bool = true
  113.         if frags == 0 and plasmas == 0 then
  114.             bool = false
  115.         end
  116.         if (rph == 1 or rph2 == 1) and tossAnimation[id] == nil and bool then
  117.             nade[id] = OnGrenadeToss(player, cur_nadetype)
  118.             tossAnimation[id] = registertimer(1300, "nadeAnimation", id)
  119.         end
  120.     end
  121.  
  122.     -- Code for blocking actions here, don't modify
  123.     if nade[id] == 0 then
  124.         writebit(m_object, 0x209, 2, 0) -- will block grenading (action will still happen, no grenade will be thrown)
  125.         writebit(m_object, 0x209, 3, 0) -- will block grenading (action will still happen, no grenade will be thrown)
  126.     end
  127. end
  128.  
  129. -- Called when a player interacts with an object
  130. -- It can be called while attempting to pick the object up
  131. -- It is also called when standing above an object so can be called various times quickly
  132. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  133.     return 1
  134. end
  135.  
  136. -- Called when a player attempts to reload their weapon.
  137. -- A value must be returned. The return value indicates whether or not the player is allowed to reload.
  138. -- Notes: If player is -1 then the weapon being reload wasn't located (it could be a vehicle's weapon)
  139. function OnWeaponReload(player, weapon)
  140.     return 1
  141. end
  142.  
  143. -- Called when a player attempts to enter a vehicle.
  144. --The return value indicates whether or not the player is allowed to enter.
  145. function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat)
  146.     return 1
  147. end
  148.  
  149. -- Called when a player is being ejected from their vehicle
  150. -- Return 1 or 0 to allow/block it.
  151. function OnVehicleEject(player, forceEject)
  152.     return 1
  153. end
  154.  
  155.  
  156. -- Called when damage is being done to an object.
  157. -- This doesn't always need to be a player.
  158. -- Do not return a value
  159. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  160. end
  161.  
  162. -- Called when a player is being assigned a weapon (usually when they spawn)
  163. -- A value must be returned. The return value is the id of the weapon they're to spawn with. Return zero if the weapon shouldn't change.
  164. -- Notes:   This is called for all weapon spawns the player has
  165. --          This is also called with player 255 when vehicles are being assigned weapons.
  166. --          This is only considered if in gametype, the weapon set is 'generic' if not this has no effect.
  167. function OnWeaponAssignment(player, object, count, tag)
  168. end
  169.  
  170. -- Called when an object is created
  171. -- Do not return a value.
  172. function OnObjectCreation(m_objectId, player_owner, tag)
  173. end
  174.  
  175. function nadeAnimation(id, count, ID)
  176.     tossAnimation[ID] = nil
  177.     return 0
  178. end
  179.  
  180. -- Called when a grenade is tossed
  181. -- Nadetype is the type of grenade; 0 for frag, 1 for plasma
  182. -- This action can be blocked
  183. function OnGrenadeToss(player, nadetype)
  184.     return 1
  185. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement