Advertisement
th3w1zard1

OnPlayerJump function

Feb 5th, 2012
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.75 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. jump = {}
  8.  
  9. function GetRequiredVersion()
  10.     return 10058
  11. end
  12.  
  13. -- called when the script is loaded
  14. function OnScriptLoad(process)
  15. end
  16.  
  17. -- called when the script is unloaded
  18. -- Do not return a value
  19. function OnScriptUnload()
  20. end
  21.  
  22. -- called when a game is starting (before any players join)
  23. -- Do not return a value.
  24. function OnNewGame(map)
  25. end
  26.  
  27. -- called when a game is ending
  28. -- Do not return a value.
  29. function OnGameEnd(mode)
  30.     -- mode 1 = score menu (F1) is being displayed to clients, they are still ingame
  31.     -- mode 2 = post game menu appeared
  32.     -- mode 3 = players can quit via the post game score card
  33. end
  34.  
  35. -- Called when there is chat within the server
  36. -- It must return a value which indicates whether or not the chat is sent.
  37. function OnServerChat(player, chattype, message)
  38.     return 1
  39. end
  40.  
  41. -- Called when a server command is being executed
  42. -- It must return a value which indicates whether or not the command should be processed
  43. -- Note: It is only called when an authenticated (and allowed) player attempts to use the command.
  44. --       player is -1 when being executed via the server console.
  45. function OnServerCommand(player, command)
  46.     return 1
  47. end
  48.  
  49. -- Called when a player's team is being chosen as the join the server.
  50. -- It must return a value which indicates the team the player is to be put on.
  51. -- Note: this function being called doesn't guarantee that the player will be able to successfully join.
  52. function OnTeamDecision(cur_team)
  53.     return cur_team
  54. end
  55.  
  56. -- Called when a player joins the server.
  57. -- Do not return a value.
  58. function OnPlayerJoin(player, team)
  59. end
  60.  
  61. -- Called when a player the server.
  62. -- Do not return a value.
  63. function OnPlayerLeave(player, team)
  64. end
  65.  
  66. -- called when a player kills another, 'killer' is the index of the killing player, 'victim' is the index of the dead player
  67. -- Do not return a value.
  68. function OnPlayerKill(killer, victim, mode)
  69. end
  70.  
  71. -- called when a player gets a double kill, killing spree etc
  72. -- see Phasor documentation for multiplier values
  73. function OnKillMultiplier(player, multiplier)
  74. end
  75.  
  76. -- Called when a player s (after object is created, before players are notified)
  77. -- Do not return a value
  78. function OnPlayerSpawn(player, m_objectId)
  79. end
  80.  
  81. -- Called after clients have been notified of a player spawn
  82. -- Do not return a value
  83. function OnPlayerSpawnEnd(player, m_objectId)
  84.  
  85. end
  86.  
  87. -- Called when a player is attempting to .
  88. -- A value must be returned. The return value indicates whether or not the player is allowed the change team.
  89. -- Notes: If relevant is 1 the return value is considered, if it's 0 then the return value is ignored.
  90. function OnTeamChange(relevant, player, team, dest_team)
  91.     return 1
  92. end
  93.  
  94. -- This is called when a client sends the server an update packet.
  95. -- This includes things such as movement vectors, camera positions, button presses etc.
  96. -- This function is called frequently so care should be taken to keep processing
  97. -- to a minimum.
  98. -- Do not return a value
  99. function OnClientUpdate(player, m_objectId)
  100.  
  101.     local id = resolveplayer(player)
  102.     local m_object = getobject(m_objectId)
  103.     local m_playerObjId = getplayerobjectid(player)
  104.  
  105.     if getobject(readdword(m_object, 0x11C)) == nil then
  106.  
  107.         local sph = readbit(m_object, 0x208, 6) -- space press and hold
  108.         local obj_airborne = readbyte(m_object, 0x4CC) -- Whether the person is in midair
  109.         if obj_airborne == 0 and sph == 1 and jump[id] == nil then
  110.             jump[id] = OnPlayerJump(player, m_playerObjId)
  111.         elseif sph == 0 then
  112.             jump[id] = nil
  113.         end
  114.     end
  115.  
  116.     -- Code for blocking actions here, don't modify
  117.     if jump[id] == 0 then
  118.         writebit(m_object, 0x208, 6, 0) -- will block jumping (doesn't sync)
  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. function OnPlayerJump(player, m_objectId)
  169.     return 1
  170. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement