Advertisement
th3w1zard1

OnPlayerCrouch function

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