Jump to content

SetText PlayerMoney


UAEpro

Recommended Posts

hii

in my race script

Money = getPlayerMoney ( getLocalPlayer() )

i got a label called " Money : ~{ " .. Money .. " }~ "

but in the server

when i set money

i can see the money in the label ..

but when next map came ..

i see the value " 0 "

but when i write

/cash

it give me the right value ?

Why ??

Link to comment

ok

cside

  
local playerMoney = getPlayerMoney(source) 
        Cashlbl = guiCreateLabel(12,54,203,20,"Cash : ~{ " .. playerMoney .. " }~",false,Tab1) 
guiLabelSetColor(Cashlbl,255,255,255) 
guiLabelSetVerticalAlign(Cashlbl,"top") 
guiLabelSetHorizontalAlign(Cashlbl,"left",false) 
  

i just did that to show the money amount

edit :

if i buy flip or repair from the shop tab

i can see the value of the money

Link to comment

as it was discussed here a million times already: dont use source for anything you can think of, it causes confusion.

source is a hidden variable that contains source of the event, passed to handler function.

even if you do something like «source = getLocalPlayer()» in the start of your script, in your handler function (and i bet this code runs in some event handler) source will still be the source of the event in that function. because your global source gets replaced with source local to the function.

Link to comment

Actually, variables like 'source' are globals in Lua, so if you did source = getLocalPlayer() at the top of your script, that variable would get overwritten by the source variable the first time an event it triggered.

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