exports.scoreboard:scoreboardAddColumn("Points")
exports.scoreboard:scoreboardAddColumn("Rank")
ranks = {}
ranks[1] = {0,"Beginner lvl 1"}
ranks[2] = {10,"Beginner lvl 2"}
ranks[3] = {20,"Good Player"}
ranks[4] = {30,"Nice Player"}
ranks[5] = {40,"Pro Player"}
function addPoints(ammo, attacker, weapon, bodypart)
local points = getElementData(attacker, "Points")
if attacker and attacker ~= source then
setElementData(attacker, "Points", tonumber(points) + 1)
outputChatBox(getPlayerName(attacker).." killed "..getPlayerName(source).." and gained 1 point.", getRootElement(), 255, 255, 0, false)
end
end
addEventHandler("onPlayerWasted", getRootElement(), addPoints)
function onRankChanged(dataName)
if ( dataName == "Points" ) then
local playerPoints = getElementData( source, "Points" )
for i,rank in ipairs(ranks) do
if ( playerPoints => rank[i][1] ) then
setElementData(source, "Rank", rank[i][2])
end
end
end
end
addEventHandler("onElementDataChange",getRootElement(),onRankChanged)
function onJoin ( )
setElementData(source, "Points", 0)
end
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin)
function onResStart ( )
for i,v in ipairs(getElementsByType ("player")) do
if not ( getElementData( v, "Points" ) ) then
setElementData( v, "Points", 0 )
end
end
end
addEventHandler ( "onResourceStart", getResourceRootElement(), onResStart )
I think this will work.
But you need to learn more, do not rely too much on others.
I know you are trying to learn from a long time, but I do not see any development!