Advertisement
Combreal

MeleeFlag.lua

Aug 1st, 2014
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.66 KB | None | 0 0
  1. -- Slow down peeps holding the flag --
  2.  
  3. scores = {}
  4. holding = {}
  5.  
  6. function GetRequiredVersion() return 200 end
  7.  
  8. function OnScriptLoad(processId, game, persistent)
  9.     gametype_game = readbyte(0x671340 + 0x30)
  10.     team_play = readbyte(0x671340 + 0x34)
  11. end
  12.  
  13. function OnPlayerJoin(player)
  14.     scores[gethash(player)] = 0
  15.     holding[gethash(player)] = 0
  16. end
  17.  
  18. function OnTeamChange(player, old_team, new_team, relevant)
  19.     scores[gethash(player)] = 0
  20.     holding[gethash(player)] = 0
  21. end
  22.  
  23. function OnPlayerScore(player, score, gametype)
  24.     local name = getname(player)
  25.     local team = getteam(player)
  26.     privatesay(player, "Welldone !")
  27.     if team == 1 then
  28.         say(name .. " just scored, good job blue team")
  29.     else
  30.         say(name .. " just scored, good job red team")
  31.     end
  32. end
  33.  
  34.  
  35. function OnClientUpdate(player)
  36.     if gethash(player) then
  37.         local score = getscore(player)
  38.         if score > scores[gethash(player)] then
  39.             OnPlayerScore(player, score, gametype_game)
  40.             scores[gethash(player)] = score
  41.         end
  42.         if isHoldingFlag(player) then
  43.             setspeed(player, 0.7)
  44.         else
  45.             setspeed(player, 1)
  46.         end
  47.     end
  48. end
  49.  
  50. function getscore(player)
  51.     local score = 0
  52.     local timed = false
  53.     if gametype_game == 1 then
  54.         score = readword(getplayer(player) + 0xC8)
  55.     end
  56.     if timed == true then
  57.         score = math.floor(score / 30)
  58.     end
  59.     return score
  60. end
  61.  
  62. function isHoldingFlag(player)
  63.     local redflag = readdword(0x639B98 + 0x0)
  64.     local blueflag = readdword(0x639B98 + 0x4)
  65.     local m_object = getobject(getplayerobjectid(player))
  66.     for i = 0,3 do
  67.         local weapId = readdword(m_object + 0x2F8 + i*4)
  68.         if weapId == redflag or weapId == blueflag then
  69.             return true
  70.         end
  71.     end
  72.     return false
  73. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement