Advertisement
Combreal

OnPlayerScore.lua

Mar 30th, 2014
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. -- CTF OnPlayerScore function, inspired from Kennan work --
  2.  
  3. scores = {}
  4.  
  5. function GetRequiredVersion() return 200 end
  6.  
  7. function OnScriptLoad(processId, game, persistent)
  8.     gametype_game = readbyte(0x671340 + 0x30)
  9.     team_play = readbyte(0x671340 + 0x34)
  10. end
  11.  
  12. function OnPlayerJoin(player)
  13.     scores[gethash(player)] = 0
  14. end
  15.  
  16. function OnTeamChange(player, old_team, new_team, relevant)
  17.     scores[gethash(player)] = 0
  18. end
  19.  
  20. function OnPlayerScore(player, score, gametype)
  21.     local name = getname(player)
  22.     local team = getteam(player)
  23.     privatesay(player, "Welldone !")
  24.     if team == 1 then
  25.         say(name .. " just scored, good job blue team")
  26.     else
  27.         say(name .. " just scored, good job red team")
  28.     end
  29. end
  30.  
  31.  
  32. function OnClientUpdate(player)
  33.     if gethash(player) then
  34.         local score = getscore(player)
  35.         if score > scores[gethash(player)] then
  36.             OnPlayerScore(player, score, gametype_game)
  37.             scores[gethash(player)] = score
  38.         end
  39.     end
  40. end
  41.  
  42. function getscore(player)
  43.     local score = 0
  44.     local timed = false
  45.     if gametype_game == 1 then
  46.         score = readword(getplayer(player) + 0xC8)
  47.     end
  48.     if timed == true then
  49.         score = math.floor(score / 30)
  50.     end
  51.     return score
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement