Advertisement
th3w1zard1

OnPlayerSmack function

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