Jump to content

How to make money on dxscoreboard?, help i tried


Recommended Posts

I tried about 3 or 4 hours, but nothing. Someone help me? I tried:

function onPlayerQuit ( )
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playermoney = getPlayerMoney ( source )
           setAccountData ( playeraccount, "funmodev2-money", playermoney )
     end
end
 
local root = getRootElement()
addEventHandler("onPlayerLogin", root,
 function()
     local playeraccount = getPlayerAccount ( source )
     if ( playeraccount ) then
           local playermoney = getAccountData ( playeraccount, "funmodev2-money" )
           if ( playermoney ) then
                 setPlayerMoney ( source, playermoney )
           end
      end
 end
)
 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit )
 
local playercash = getPlayerMoney ( player )
 
function addColumns()
  exports.dxscoreboard:scoreboardAddColumn("$Money")
  points ()
end
addEventHandler("onResourceStart",getRootElement(),addColumns)
 
function points ()
  setElementData ( player, "$Money", playercash )
end

but does not work :(

Edited by Guest
Link to comment
how it should look like?

client:

local root = getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick
addEventHandler("onClientRender",root,
function()
if not starttick then
		starttick = getTickCount()
end
	counter = counter + 1
	currenttick = getTickCount()
if currenttick - starttick >= 1000 then
setElementData(player,"money",getPlayerMoney(player) )
		counter = 0
		starttick = false
end
end

server:

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
function()
call(getResourceFromName("scoreboard"),"addScoreboardColumn","money")
end
)

Link to comment
how it should look like?
local root = getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick
addEventHandler("onClientRender",root,
function()
if not starttick then
		starttick = getTickCount()
end
	counter = counter + 1
	currenttick = getTickCount()
if currenttick - starttick >= 1000 then
setElementData(player,"money",getPlayerMoney(player) )
		counter = 0
		starttick = false
end
end

senseless.just use

setTimer(function() setElementData(player,"money",getPlayerMoney(player) end, 0, 5000 )

Link to comment

ok, in meta i wrote:

<meta>
<info author="Carbonik" type="script" version="1.0" name="money_dx" description="Adds money on dxscoreboard"/>
<script src="money.lua" type="client"/>
<script src="table.lua" type="server"/>
</meta>

money.lua:

local root =  getRootElement()
local player = getLocalPlayer()
local counter = 0
local starttick
local currenttick
addEventHandler("onClientRender",root,
  function()
     if not starttick then
        starttick = getTickCount()
     end
     counter = counter + 1
     currenttick = getTickCount()
     if currenttick - starttick >= 1000 then
        setElementData(player,"money",getPlayerMoney(player) )
        counter = 0
        starttick = false
     end
  end
  setTimer(function() setElementData(player,"money",getPlayerMoney(player)  end, 0, 5000  )

and table.lua:

addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
  function()
     call(getResourceFromName("dxscoreboard"),"addScoreboardColumn","money")
  end
)

and it does not work :(:

problemlj.png

Link to comment

1)use [ lua] [/lua] tags

2)rename dxscorebaord resource to "scoreboard", due to fact all resources supports that name

3)only table.lua needed

local root =  getRootElement()
addEventHandler("onResourceStart",getResourceRootElement(),
function()
     exports.scoreboard:addScoreboardColumn("money")
setTimer(
function() 
for _,player in ipairs(getElementsByType("player")) do
setElementData(player,"money",getPlayerMoney(player)) 
end
end, 0, 5000)
end
)

4)don't get money clientside as then money is hackable

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