Jump to content

What's wrong ?


novo

Recommended Posts

Hi all.

I need help with some scripts, lets start...

--------------------------------------------------------

I wanted to make a text where you can see your currently cash and it gets updated. Like if you get some cash you see that text updated + your new cash.

Here's my code:

addEventHandler('onClientResourceStart', g_ResRoot, 
    function() 
        g_Players = getElementsByType('player') 
  
        fadeCamera(false,0.0) 
        -- create GUI 
        local screenWidth, screenHeight = guiGetScreenSize() 
        local scale = relativeScale(screenHeight) 
        g_dxGUI = { 
            ranknum = dxText:create('0', screenWidth - 160, 155, false, 'bankgothic'), 
            ranksuffix = dxText:create('$', screenWidth - 90, 155, false, 'bankgothic', 1),     } 
        g_dxGUI.ranknum:color(255,255,255) 
        g_dxGUI.ranksuffix:color(0,132,255) 
        g_dxGUI.ranknum:type('stroke', 2, 0, 0, 0, 255) 
        g_dxGUI.ranksuffix:type('stroke', 2, 0, 0, 0, 255) 
    end 
) 
  
function relativeScale(int) 
    return (int*0.66)/1080 
end 
  
function setCashDisplay( player, cash ) 
local  
    if not tonumber(cash) then 
        g_dxGUI.cashnum:text('') 
        g_dxGUI.cashsuffix:text('') 
        return 
    end 
    g_dxGUI.cashnum:text(tonumber(getCashPlayer = getAccountData(getAcc, "Cash"))) 
    g_dxGUI.cashsuffix:text('$' ) 
end 

But it's not showing. Thanks.

---------------------------------------------

I wanted to add a tab in scoreboard for show currently cash but cash isn't showing.

Here's my code:

-- CASH TAB 
  
addEventHandler("onResourceStart", 
    getResourceRootElement(getThisResource()), 
    function() 
        exports.scoreboard:addScoreboardColumn("Cash", getRootElement(), 1, 0.08) 
    end)     
  
    addEventHandler("onPlayerLogin", getRootElement(), setTheCash) 
     
    function setTheCash(source) 
    local cash = getStats(source, "cash") 
    if (cash == "unknow")then 
        setElementData(source, "cash", 0) 
    else 
        setElementData(source, "cash", cash) 
    end 
    end 
  
    addEventHandler("onPlayerLogin", getRootElement(), 
    function() 
    setTimer(setTheCash, 5000, 0, source) 
    end) 
     
    addEventHandler("onPlayerChat", getRootElement(), 
    function() 
    setTimer(setTheCash, 5000, 0, source) 
    end) 
     
function getPlayerCash(player) 
    if player then 
        local account = getPlayerAccount(player) 
        if not (isGuestAccount(account)) then 
        local cash = getStats(source, "cash") 
            if cash then 
                return cash 
            else 
                return 0 
            end 
        else 
            return false 
        end 
    else 
        return false 
    end 
end 
  
--[[ 
function setPlayerCash(player, avatar) 
    if player then 
        local account = getPlayerAccount(player) 
        if not (isGuestAccount(account)) then 
            setAccountData(account, "profile-avatar", avatar) 
                local cash = getStats(source, "cash") 
            return true 
        else 
            return false 
        end 
    else 
        return false 
    end 
end 
]]-- 
  
addEvent("setAccountCash", true) 
addEventHandler("setAccountCash", getRootElement(), 
function(player, cash) 
    if cash then 
        setPlayerCash(player, cash) 
        -- outputChatBox("#007FFF[Account]#FFFFFF Avatar succesfully loaded !", getRootElement(), 255, 255, 255, true) 
        chatBox("Cash succefully loaded !", player) 
    end 
end) 
  
-- END CASH TAB 

Help me. Thanks.

-------------------------------------

So those are my scripts wich i need help to fix them.

Thanks (:

Link to comment
g_dxGUI.cashnum:text(tonumber(getCashPlayer = getAccountData(getAcc, "Cash"))) 

This line is completely wrong, getAccountData is server side, getAcc is not defined, and getCashPlayer is wrong too.

You should trigger event with the cash as an argument.

getStats function is not defined, you commented setPlayerCash so it's not defined too.

Link to comment

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