Jump to content

Get players money


Gtagasje

Recommended Posts

Ok, first off all, before you read this script, there might be alot wrong in it, this is my first script with money.

I want the script to check everybody's money, and output it in the Scoreboard ( added the column ).

The timer works, but the other things, dont..

I dont know how to fix this.

Please help. :P.

  
local players = "" 
  
function getMoney () 
    getPlayerMoney ( players ) 
    setElementData ( players, "Money", getPlayerMoney ( players ) ) 
end 
setTimer ( getMoney, 5000, 0 ) 
addEventHandler("onResourceStart", getRootElement(), getMoney) 
  

Regards, Gtagasje.

Link to comment

SERVER-ONLY:

function getMoney () 
    for i, p in ipairs ( getElementsByType ( "player" ) ) do --We get a table with all players 
        setElementData ( p, "Money", getPlayerMoney ( p ) ) --To every player, we get its money and set it as element data 
    end 
end 
setTimer ( getMoney, 5000, 0 ) 
getMoney ( ) 

Btw this is not very efficient and uses very much server CPU. You could try to make another system, like, instead of using default GTA money, use element data for it. And create custom functions to work with the element data.

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