Advertisement
th3w1zard1

OnPlayerAction function

Feb 5th, 2012
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.96 KB | None | 0 0
  1.  
  2.  
  3.  
  4.  
  5. action = {}
  6.  
  7.  
  8.  
  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.     local interaction = readdword(getplayer(player), 0x24) -- Are they interacting with anything
  107.     local actionkey = readbit(m_object, 0x208, 1) -- 1 when the action key is pressed
  108.     local actionkey2 = readbit(m_object, 0x209, 5) -- e press
  109.     if interaction ~= 0xFFFFFFFF and interaction ~= 0 and (actionkey == 1 or actionkey2 == 1) then
  110.         action[id] = OnPlayerAction(player, m_playerObjId)
  111.     elseif getobject(readdword(m_object, 0x11C)) ~= nil and (actionkey == 1 or actionkey2 == 1) then
  112.         action[id] = OnPlayerAction(player, m_playerObjId)
  113.     end
  114.  
  115.     -- Code for blocking actions here, don't modify
  116.     if action[id] == 0 then
  117.         writebit(m_object, 0x208, 1, 0) -- will block using the action key (syncs (i think))
  118.         writebit(m_object, 0x209, 5, 0)
  119.     end
  120. end
  121.  
  122. -- Called when a player interacts with an object
  123. -- It can be called while attempting to pick the object up
  124. -- It is also called when standing above an object so can be called various times quickly
  125. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  126.     return 1
  127. end
  128.  
  129. -- Called when a player attempts to reload their weapon.
  130. -- A value must be returned. The return value indicates whether or not the player is allowed to reload.
  131. -- Notes: If player is -1 then the weapon being reload wasn't located (it could be a vehicle's weapon)
  132. function OnWeaponReload(player, weapon)
  133.     return 1
  134. end
  135.  
  136. -- Called when a player attempts to enter a vehicle.
  137. --The return value indicates whether or not the player is allowed to enter.
  138. function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat)
  139.     return 1
  140. end
  141.  
  142. -- Called when a player is being ejected from their vehicle
  143. -- Return 1 or 0 to allow/block it.
  144. function OnVehicleEject(player, forceEject)
  145.     return 1
  146. end
  147.  
  148.  
  149. -- Called when damage is being done to an object.
  150. -- This doesn't always need to be a player.
  151. -- Do not return a value
  152. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  153. end
  154.  
  155. -- Called when a player is being assigned a weapon (usually when they spawn)
  156. -- 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.
  157. -- Notes:   This is called for all weapon spawns the player has
  158. --          This is also called with player 255 when vehicles are being assigned weapons.
  159. --          This is only considered if in gametype, the weapon set is 'generic' if not this has no effect.
  160. function OnWeaponAssignment(player, object, count, tag)
  161. end
  162.  
  163. -- Called when an object is created
  164. -- Do not return a value.
  165. function OnObjectCreation(m_objectId, player_owner, tag)
  166. end
  167.  
  168. -- Called when the player does an action by pressing E (picking up weapons, entering/exiting vehicles)
  169. -- This function can be blocked, return 0.
  170. -- This action syncs with certain actions, but not others.
  171. function OnPlayerAction(player, m_playerObjId)
  172.     return 1
  173. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement