Advertisement
th3w1zard1

OnGrenadeSwap function

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