UAEpro Posted February 17, 2011 Share Posted February 17, 2011 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
Castillo Posted February 17, 2011 Share Posted February 17, 2011 Post your code, we can't help you if you don't show us how does your script work. Link to comment
UAEpro Posted February 17, 2011 Author Share Posted February 17, 2011 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
Castillo Posted February 17, 2011 Share Posted February 17, 2011 where you got that "source" from? Link to comment
UAEpro Posted February 17, 2011 Author Share Posted February 17, 2011 where you got that "source" from? source = getLocalPlayer() edit :: when i started to learn you helped me with my old race script .. thank you but know .. i got this weird problem !! Link to comment
Aibo Posted February 17, 2011 Share Posted February 17, 2011 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
eAi Posted February 17, 2011 Share Posted February 17, 2011 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
UAEpro Posted February 18, 2011 Author Share Posted February 18, 2011 problem fixed by small trick ^^ close the topic Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now