Advertisement
th3w1zard1

OnWeaponSwitch Function

Feb 5th, 2012
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.73 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. function GetRequiredVersion()
  8.     return 10058
  9. end
  10.  
  11. -- called when the script is loaded
  12. function OnScriptLoad(process)
  13. end
  14.  
  15. -- called when the script is unloaded
  16. -- Do not return a value
  17. function OnScriptUnload()
  18. end
  19.  
  20. -- called when a game is starting (before any players join)
  21. -- Do not return a value.
  22. function OnNewGame(map)
  23. end
  24.  
  25. -- called when a game is ending
  26. -- Do not return a value.
  27. function OnGameEnd(mode)
  28.     -- mode 1 = score menu (F1) is being displayed to clients, they are still ingame
  29.     -- mode 2 = post game menu appeared
  30.     -- mode 3 = players can quit via the post game score card
  31. end
  32.  
  33. -- Called when there is chat within the server
  34. -- It must return a value which indicates whether or not the chat is sent.
  35. function OnServerChat(player, chattype, message)
  36.     return 1
  37. end
  38.  
  39. -- Called when a server command is being executed
  40. -- It must return a value which indicates whether or not the command should be processed
  41. -- Note: It is only called when an authenticated (and allowed) player attempts to use the command.
  42. --       player is -1 when being executed via the server console.
  43. function OnServerCommand(player, command)
  44.     return 1
  45. end
  46.  
  47. -- Called when a player's team is being chosen as the join the server.
  48. -- It must return a value which indicates the team the player is to be put on.
  49. -- Note: this function being called doesn't guarantee that the player will be able to successfully join.
  50. function OnTeamDecision(cur_team)
  51.     return cur_team
  52. end
  53.  
  54. -- Called when a player joins the server.
  55. -- Do not return a value.
  56. function OnPlayerJoin(player, team)
  57. end
  58.  
  59. -- Called when a player the server.
  60. -- Do not return a value.
  61. function OnPlayerLeave(player, team)
  62. end
  63.  
  64. -- called when a player kills another, 'killer' is the index of the killing player, 'victim' is the index of the dead player
  65. -- Do not return a value.
  66. function OnPlayerKill(killer, victim, mode)
  67. end
  68.  
  69. -- called when a player gets a double kill, killing spree etc
  70. -- see Phasor documentation for multiplier values
  71. function OnKillMultiplier(player, multiplier)
  72. end
  73.  
  74. -- Called when a player s (after object is created, before players are notified)
  75. -- Do not return a value
  76. function OnPlayerSpawn(player, m_objectId)
  77. end
  78.  
  79. -- Called after clients have been notified of a player spawn
  80. -- Do not return a value
  81. function OnPlayerSpawnEnd(player, m_objectId)
  82.  
  83. end
  84.  
  85. -- Called when a player is attempting to .
  86. -- A value must be returned. The return value indicates whether or not the player is allowed the change team.
  87. -- Notes: If relevant is 1 the return value is considered, if it's 0 then the return value is ignored.
  88. function OnTeamChange(relevant, player, team, dest_team)
  89.     return 1
  90. end
  91.  
  92. -- This is called when a client sends the server an update packet.
  93. -- This includes things such as movement vectors, camera positions, button presses etc.
  94. -- This function is called frequently so care should be taken to keep processing
  95. -- to a minimum.
  96. -- Do not return a value
  97. function OnClientUpdate(player, m_objectId)
  98.  
  99.     local m_object = getobject(m_objectId)
  100.     local m_playerObjId = getplayerobjectid(player)
  101.  
  102.     local cur_weap = readword(m_object, 0x2F2) -- Current weapon slot
  103.     local next_weap = readword(m_object, 0x2F4) -- Weapon slot the player is trying to change to
  104.     if cur_weap ~= next_weap and cur_weap ~= 65535 then
  105.         local cur_weap_id = readdword(m_object, 0x118) -- Current weapon ID
  106.         local next_weap_id = readdword(m_object, 0x2F8 + (next_weap*4)) -- Weapon ID the player is trying to change to
  107.         OnWeaponSwitch(player, m_playerObjId, cur_weap_id, next_weap_id) -- Call the function, i haven't made a way to block it yet.
  108.     end
  109.  
  110. end
  111.  
  112. -- Called when a player interacts with an object
  113. -- It can be called while attempting to pick the object up
  114. -- It is also called when standing above an object so can be called various times quickly
  115. function OnObjectInteraction(player, m_ObjectId, tagType, tagName)
  116.     return 1
  117. end
  118.  
  119. -- Called when a player attempts to reload their weapon.
  120. -- A value must be returned. The return value indicates whether or not the player is allowed to reload.
  121. -- Notes: If player is -1 then the weapon being reload wasn't located (it could be a vehicle's weapon)
  122. function OnWeaponReload(player, weapon)
  123.     return 1
  124. end
  125.  
  126. -- Called when a player attempts to enter a vehicle.
  127. --The return value indicates whether or not the player is allowed to enter.
  128. function OnVehicleEntry(relevant, player, vehicleId, vehicle_tag, seat)
  129.     return 1
  130. end
  131.  
  132. -- Called when a player is being ejected from their vehicle
  133. -- Return 1 or 0 to allow/block it.
  134. function OnVehicleEject(player, forceEject)
  135.     return 1
  136. end
  137.  
  138.  
  139. -- Called when damage is being done to an object.
  140. -- This doesn't always need to be a player.
  141. -- Do not return a value
  142. function OnDamageLookup(receiving_obj, causing_obj, tagdata, tagname)
  143. end
  144.  
  145. -- Called when a player is being assigned a weapon (usually when they spawn)
  146. -- 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.
  147. -- Notes:   This is called for all weapon spawns the player has
  148. --          This is also called with player 255 when vehicles are being assigned weapons.
  149. --          This is only considered if in gametype, the weapon set is 'generic' if not this has no effect.
  150. function OnWeaponAssignment(player, object, count, tag)
  151. end
  152.  
  153. -- Called when an object is created
  154. -- Do not return a value.
  155. function OnObjectCreation(m_objectId, player_owner, tag)
  156. end
  157.  
  158. function OnWeaponSwitch(player, m_playerObjId, cur_weapId, next_weapId)
  159.  
  160. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement