Jump to content

Levels to image


Recommended Posts

Posted

Hello all, i'm trying to transform rank numbers to image, here is the lua

local levels = {[200] = 1, [500] = 2, [600] = 3, [1000] = 4, [2000] = 5, [3000] = 6, [4000] = 7, [5000] = 8, [9000] = 9} 
  
function win(ammo, killer, weapon, bodypart) 
    if (killer and killer ~= source) then 
        local H = getElementData(killer, "Reputation") 
        local S = getElementData(killer, "Rank") 
        local killer1 = getPlayerName(killer) 
        local noob = getPlayerName(source) 
        setElementData(killer, "Reputation", tonumber(H)+math.random ( 20, 50 ) ) 
        if levels[tonumber(H)] then 
            setElementData(killer, "Rank", "Rank ".. tostring(levels[tonumber(H)]) .." ! ") 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local H = getElementData ( source, "Reputation" ) or 0 
    setElementData ( source, "Reputation", tonumber ( H ) - math.random ( 20, 50 ) ) 
end 
addEventHandler( "onPlayerWasted", getRootElement(), win) 
  
function onLogin (_,account) 
    setElementData(source, "Rank", getAccountData(account, "Rnk") or "0") 
    setElementData(source, "Reputation", getAccountData(account, "Rep") or "0") 
end 
addEventHandler ("onPlayerLogin", root, onLogin) 
  
function saveData(thePlayer, theAccount) 
    if (theAccount and not isGuestAccount(theAccount)) then 
        setAccountData (theAccount, "Rnk", getElementData(thePlayer, "Rank")) 
        setAccountData (theAccount, "Rep", getElementData(thePlayer, "Reputation")) 
    end 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (prev) saveData(source, prev) end) 

Also i want add them to scoreboard

elseif column.name == "Rank" then 
                            column.width = 20 
                            dxDrawImage( topX+theX, y+s(1), 16, 11, content, 0, 0, 0, cWhite, drawOverGUI ) 

Ranks images are

Rank/Lvl1.png

.........

Rank/Lvl9.png

I hope somebody help me in this, and thanks

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Bump !

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

try this:

local levels = { 
    [200] = "1", 
    [500] = "2", 
    [600] = "3", 
    [1000] = "4", 
    [2000] = "5", 
    [3000] = "6", 
    [4000] = "7", 
    [5000] = "8", 
    [9000] = "9" 
} 
  
addEventHandler( "onPlayerWasted",root, function(_, killer) 
    if (killer and killer ~= source) then 
        local Rep = tonumber(getElementData(killer, "Reputation")) or 0 
        local Rank = getElementData(killer, "Rank") 
        local kName = getPlayerName(killer) 
        local sName = getPlayerName(source) 
        setElementData(killer, "Reputation", Rep + math.random ( 20, 50 ) ) 
        if levels[Rep] then 
            setElementData(killer, "Rank", "Rank ".. levels[Rep] .." ! ") 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local Rep = tonumber(getElementData ( source, "Reputation" )) or 0 
    setElementData ( source, "Reputation", Rep  - math.random ( 20, 50 ) ) 
end) 
  
addEventHandler ("onPlayerLogin", root, function (_,curAcc) 
    setElementData(source, "Rank", getAccountData(curAcc, "Rank") or "0") 
    setElementData(source, "Reputation", getAccountData(curAcc, "Rep") or 0) 
end) 
  
function saveData(source, acc) 
    if not acc or isGuestAccount(acc)then return end 
    setAccountData (acc, "Rnk", getElementData(source, "Rank")) 
    setAccountData (acc, "Rep", getElementData(source, "Reputation")) 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (acc) saveData(source, acc) end) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

I will try thanks for youre help.

location for them is ":Reputation/Reputation/Rank"..rank..".png"

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Didn't work no errors,

i guess forgot to check if FileExist

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted
local levels = { 
    [200] = "1", 
    [500] = "2", 
    [600] = "3", 
    [1000] = "4", 
    [2000] = "5", 
    [3000] = "6", 
    [4000] = "7", 
    [5000] = "8", 
    [9000] = "9" 
} 
  
addEventHandler( "onPlayerWasted",root, function(_, killer) 
    if (killer and killer ~= source) then 
        local Rep = tonumber(getElementData(killer, "Reputation")) or 0 
        local kName = getPlayerName(killer) 
        local sName = getPlayerName(source) 
        setElementData(killer, "Reputation", Rep + math.random ( 20, 50 ) ) 
        if levels[Rep] then 
            setElementData(killer, "Rank", "Rank/Lvl".. levels[Rep] ..".png") --Rank/Lvl1.png 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local Rep = tonumber(getElementData ( source, "Reputation" )) or 0 
    setElementData ( source, "Reputation", Rep  - math.random ( 20, 50 ) ) 
end) 
  
addEventHandler ("onPlayerLogin", root, function (_,curAcc) 
    setElementData(source, "Rank", getAccountData(curAcc, "Rank") or "0") 
    setElementData(source, "Reputation", getAccountData(curAcc, "Rep") or 0) 
end) 
  
function saveData(source, acc) 
    if not acc or isGuestAccount(acc)then return end 
    setAccountData (acc, "Rnk", getElementData(source, "Rank")) 
    setAccountData (acc, "Rep", getElementData(source, "Reputation")) 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (acc) saveData(source, acc) end) 

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

  • 3 weeks later...
Posted

Not working :'(

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

Heeelp

If you're looking for a cheap paid scripter, don't hesitate to contact me.

Great minds discuss ideas, Average minds discuss events and small minds discuss people.

Posted

try this:

local levels = { 
    [200] = "1", 
    [500] = "2", 
    [600] = "3", 
    [1000] = "4", 
    [2000] = "5", 
    [3000] = "6", 
    [4000] = "7", 
    [5000] = "8", 
    [9000] = "9" 
} 
  
addEventHandler( "onPlayerWasted",root, function(_, killer) 
    if (killer and killer ~= source) then 
        local Rep = tonumber(getElementData(killer, "Reputation")) or 0 
        local kName = getPlayerName(killer) 
        local sName = getPlayerName(source) 
        setElementData(killer, "Reputation", Rep + math.random ( 20, 50 ) ) 
        if levels[Rep] then 
            setElementData(killer, "Rank", ":Reputation/Reputation/Rank/Lvl".. levels[Rep] ..".png") -- :Reputation/Reputation/Rank/Lvl1.png 
            triggerClientEvent ( killer, "playSound", killer ) 
        end 
    end 
    local Rep = tonumber(getElementData ( source, "Reputation" )) or 0 
    setElementData ( source, "Reputation", Rep  - math.random ( 20, 50 ) ) 
end) 
  
addEventHandler ("onPlayerLogin", root, function (_,curAcc) 
    setElementData(source, "Rank", getAccountData(curAcc, "Rank") or "0") 
    setElementData(source, "Reputation", getAccountData(curAcc, "Rep") or 0) 
end) 
  
function saveData(source, acc) 
    if not acc or isGuestAccount(acc)then return end 
    setAccountData (acc, "Rnk", getElementData(source, "Rank")) 
    setAccountData (acc, "Rep", getElementData(source, "Reputation")) 
end 
  
addEventHandler ("onPlayerQuit", root, function () saveData(source, getPlayerAccount(source)) end) 
addEventHandler ("onPlayerLogout", root, function (acc) saveData(source, acc) end) 

And please tell me if there's an error or why it's not working!

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

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...