Jump to content

Some Help in Points System :)


^Dev-PoinT^

Recommended Posts

Posted

Hi all see the code

clientSide

localPlayer = getLocalPlayer() 
exports.scoreboard:scoreboardAddColumn("Points") 
function onKill (ammo, killer, weapon, bodypart) 
    if(killer and killer ~=source) then 
    setElementData(localPlayer, "Points", +1) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()),add) 
  
function Hi() 
local PlayerMoney = getPlayerMoney(source) 
local PlyaerPoints = getElementData(getlocalPlayer(), "Points") 
end 

serverSide ..

addEvent("onPlayerWasted",true) 
addEventHandler("onPlayerWasted",getRootElement(), 
function (winner) 
        outputChatBox(getPlayerName ( winner ) .. "Killed a Player and Got 1 Point",getRootElement(),255,255,0) 
        setElementData(winner,"Points",tonumber(getElementData(winner,"Points"))+1)             
end) 

i want it if Killer killed a Player Got 1 point

and how Make a tabel with points

example

"Points 10" = Level Noob

"Points"20 = level Player

....

Posted (edited)

What's the problem..?

This script doesn't make sence.

-- ~ Client-side 
exports.scoreboard:scoreboardAddColumn("Points") 
  
function addPoints(killer, weapon, bodypart) 
    local points = getElementData(killer, "Points") 
    local killername = getPlayerName(killer) 
    local targetname = getPlayerName(source) 
    local player = getLocalPlayer() 
     
    if killer and killer ~= source then 
        setElementData(killer, "Points", tonumber(points) + 1) 
        triggerServerEvent("onAddingPoints", getLocalPlayer(), killername, targetname) 
    end 
end 
addEventHandler("onClientPlayerWasted", getLocalPlayer(), addPoints) 
  
-- ~ Server-side 
function showMessage(killer, source) 
    outputChatBox(killername .. " killed " .. targetname .. " and gained 1 point.", getRootElement(), 255, 255, 0, false) 
end 
addEvent("onAddingPoints", true) 
addEventHandler("onAddingPoints", getRootElement(), showMessage) 

Edited by Guest

If I helped you, please click the like button on the right ;) Thanks!

Posted

Try this, but still suggesting Snake's link.

-- ~ Client-side 
exports.scoreboard:scoreboardAddColumn("Points") 
exports.scoreboard:scoreboardAddColumn("Rank") 
  
-- Table 
ranks = {{[1] = "Beginner lvl 1"}, {[2] = "Beginner lvl 2"}} 
  
-- Adding points 
function addPoints(killer, weapon, bodypart) 
    local points = getElementData(killer, "Points") 
    local rank = getElementData(killer, "Rank") 
    local killername = getPlayerName(killer) 
    local targetname = getPlayerName(source) 
    local player = getLocalPlayer() 
     
    if killer and killer ~= source then 
        setElementData(killer, "Points", tonumber(points) + 1) 
        setElementData(killer, "Rank", tonumber(rank) + 1) 
        triggerServerEvent("onAddingPoints", getLocalPlayer(), killername, targetname) 
    end 
end 
addEventHandler("onClientPlayerWasted", getLocalPlayer(), addPoints) 
  
-- ~ Server-side 
-- Showing the message 
function showMessage(killer, source) 
    outputChatBox(killername .. " killed " .. targetname .. " and gained 1 point.", getRootElement(), 255, 255, 0, false) 
end 
addEvent("onAddingPoints", true) 
addEventHandler("onAddingPoints", getRootElement(), showMessage) 

If I helped you, please click the like button on the right ;) Thanks!

Posted

Why you client and server side? you can just use onPlayerWasted server side, the trigger is completely useless.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

why soldSnake trigger wont work?

exports.scoreboard:scoreboardAddColumn("Points") 
exports.scoreboard:scoreboardAddColumn("Rank") 
  
ranks = {{[1] = "Beginner lvl 1"}, {[2] = "Beginner lvl 2"}, {[3] = "Good Player}, {[4] = "NicePlayer"}, {[5] = "ProPlayer"} 
function addPoints(killer, weapon, bodypart) 
    local points = getElementData(killer, "Points") 
    local rank = getElementData(killer, "Rank") 
    local killername = getPlayerName(killer) 
    local targetname = getPlayerName(source) 
    local player = getLocalPlayer() 
     
    if killer and killer ~= source then 
        setElementData(killer, "Points", tonumber(points) + 1) 
        setElementData(killer, "Rank", tonumber(rank) + 1) 
        triggerServerEvent("onAddingPoints", getLocalPlayer(), killername, targetname) 
    end 
end 
addEventHandler("onClientPlayerWasted", getLocalPlayer(), addPoints) 
  
 

Posted
Why you client and server side? you can just use onPlayerWasted server side, the trigger is completely useless.

@Snake: Because he had them like that from the beginning. But true, it can be fully server side aswell.

@Dev: You hadn't closed a string in the table..

exports.scoreboard:scoreboardAddColumn("Points") 
exports.scoreboard:scoreboardAddColumn("Rank") 
  
ranks = {{[1] = "Beginner lvl 1"}, {[2] = "Beginner lvl 2"}, {[3] = "Good Player"}, {[4] = "Nice Player"}, {[5] = "Pro Player"}} 
  
function addPoints(killer, weapon, bodypart) 
    local points = getElementData(killer, "Points") 
    local rank = getElementData(killer, "Rank") 
    local killername = getPlayerName(killer) 
    local targetname = getPlayerName(source) 
    local player = getLocalPlayer() 
  
    if killer and killer ~= source then 
        setElementData(killer, "Points", tonumber(points) + 1) 
        setElementData(killer, "Rank", tonumber(rank) + 1) 
        triggerServerEvent("onAddingPoints", getLocalPlayer(), killername, targetname) 
    end 
end 
addEventHandler("onClientPlayerWasted", getLocalPlayer(), addPoints) 

If you want to change from client-side to server-side, use this:

exports.scoreboard:scoreboardAddColumn("Points") 
exports.scoreboard:scoreboardAddColumn("Rank") 
  
ranks = {{[1] = "Beginner lvl 1"}, {[2] = "Beginner lvl 2"}, {[3] = "Good Player"}, {[4] = "Nice Player"}, {[5] = "Pro Player"}} 
  
function addPoints(ammo, attacker, weapon, bodypart) 
    local points = getElementData(attacker, "Points") 
    local rank = getElementData(attacker, "Rank") 
    local killername = getPlayerName(attacker) 
    local targetname = getPlayerName(source) 
  
    if attacker and attacker ~= source then 
        setElementData(attacker, "Points", tonumber(points) + 1) 
        setElementData(attacker, "Rank", tonumber(rank) + 1) 
        outputChatBox(killername .. " killed " .. targetname .. " and gained 1 point.", getRootElement(), 255, 255, 0, false) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), addPoints) 

If I helped you, please click the like button on the right ;) Thanks!

Posted

yes but he can win the lvels esay i want if He Kill 10 Player = "Level 1" ...

if +1 that wel make him if he kill 7 Players he got all the ranks i want 10 =Level 1 20 = level 2 Please :)

Posted

Try something like this:

exports.scoreboard:scoreboardAddColumn("Points") 
exports.scoreboard:scoreboardAddColumn("Rank") 
  
ranks = {[1] = {"Beginner lvl 1", 10}, [2] = {"Beginner lvl 2", 15}, [3] = {"Good Player", 25}, [4] = {"Nice Player", 35}, [5] = {"Pro Player", 40}} 
  
function addPoints(ammo, attacker, weapon, bodypart) 
    local points = tonumber(getElementData(attacker, "Points")) 
    local rank = getElementData(attacker, "Rank") 
    local killername = getPlayerName(attacker) 
    local targetname = getPlayerName(source) 
  
    if attacker and attacker ~= source then 
        setElementData(attacker, "Points", tonumber(points) + 1) 
        outputChatBox(killername .. " killed " .. targetname .. " and gained 1 point.", getRootElement(), 255, 255, 0, false) 
        if points >= ranks[rank][2] then 
            setElementData(attacker, "Rank", tonumber(rank) + 1) 
        end 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), addPoints) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, it should do, why don't you test it?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted (edited)
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!

Edited by Guest
Posted

Bssol, you never check the points, and also, you are setting rank +1 each time you kill.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

that's what he want,

he wants a ranks system when a player killed another one, his rank rises 1 point.

in the same time he wants a groups of points, has a name for each group,

for example: from 1 to 10 called "Beginner lvl 1"

that's what he wants :)

any way, i fixed it in the past post.

Posted

Doesn't he want a kind of level system? e.g: kill 10 players, level up to rank 1, kill 20, rank 2, and so on.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

And, why code won't do the job? if so, could you explain why?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I posted a script before you'd, I supposed it didn't work, and that's why you posted.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
dosnt work Castillo its dont show the Msg and dont show the rank and points in Scoreboard!

Try making it work yourself for once..

All I see you do is complain when things dont work..

As people have told you before, you do have potential, but you are so lazy.. Read the wiki and figure you out for yourself.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...