Jump to content

Money...


Mefisto_PL

Recommended Posts

  • 2 weeks later...

We gave you 100 examples and you haven't understood a single one of them? Give us a break.

Test the money function by typing /ctest in-game. You should lose $100.00 and when you logout/quit the game, it will save your money. When you log in, it will return back your money.

This is just an example, you must understand the code and please take time to read and understand it.

Client-side

addCommandHandler("ctest", 
    function(cmd) 
        triggerServerEvent("onMoneyTaken", localPlayer) 
    end 
) 

Server-side

addEventHandler("onPlayerQuit", root, 
    function(quitType, reason, responsibleElement) 
        if isGuestAccount(getPlayerAccount(source)) then return end 
        setAccountData(getPlayerAccount(source), "player:money", getPlayerMoney(source)) 
    end 
) 
  
addEventHandler("onPlayerLogout", root, 
    function(previousAccount, currentAccount) 
        if isGuestAccount(getPlayerAccount(source)) then return end 
        setAccountData(getPlayerAccount(source), "player:money", getPlayerMoney(source)) 
    end 
) 
  
addEventHandler("onPlayerLogin", root, 
    function(previousAccount, currentAccount, autoLogin) 
        if getAccountData(currentAccount, "player:money") then 
            setPlayerMoney(source, tonumber(getAccountData(currentAccount, "player:money"))) 
        else 
            setPlayerMoney(source, 200) 
        end 
    end 
) 
  
addEvent("onMoneyTaken", true) 
addEventHandler("onMoneyTaken", root, 
    function() 
        takePlayerMoney(source, 100) 
    end 
) 

Edited by Guest
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...