Combreal icon

OnPlayerScore.lua

Combreal | PRO | 03/30/14 05:47:15 PM UTC | 0 ⭐ | 1362 👁️ | Never ⏰ | []
Lua |

1.17 KB

|

None

|

0 👍

/

0 👎

-- CTF OnPlayerScore function, inspired from Kennan work --
 
scores = {}
 
function GetRequiredVersion() return 200 end
 
function OnScriptLoad(processId, game, persistent)
    gametype_game = readbyte(0x671340 + 0x30)
    team_play = readbyte(0x671340 + 0x34)
end
 
function OnPlayerJoin(player)
    scores[gethash(player)] = 0
end
 
function OnTeamChange(player, old_team, new_team, relevant)
    scores[gethash(player)] = 0
end
 
function OnPlayerScore(player, score, gametype)
    local name = getname(player)
    local team = getteam(player)
    privatesay(player, "Welldone !")
    if team == 1 then
        say(name .. " just scored, good job blue team")
    else
        say(name .. " just scored, good job red team")
    end
end
 
 
function OnClientUpdate(player)
    if gethash(player) then
        local score = getscore(player)
        if score > scores[gethash(player)] then
            OnPlayerScore(player, score, gametype_game)
            scores[gethash(player)] = score
        end
    end
end
 
function getscore(player)
    local score = 0
    local timed = false
    if gametype_game == 1 then
        score = readword(getplayer(player) + 0xC8)
    end
    if timed == true then
        score = math.floor(score / 30)
    end
    return score
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎