Feche1320 Posted January 2, 2011 Posted January 2, 2011 getPlayerMoney on client-side scripts sometimes returns me 0, is it a bug? www.host-ar.com.ar
Moderators Zango Posted January 2, 2011 Moderators Posted January 2, 2011 If player's cash isn't 0 and the result differentiates from the serverside one, then yes?
Feche1320 Posted January 2, 2011 Author Posted January 2, 2011 I have a server-side client (/cash), and it show the right ammount, but client-side sometimes returns $0. www.host-ar.com.ar
Feche1320 Posted January 2, 2011 Author Posted January 2, 2011 local player = getLocalPlayer() addEventHandler('onClientGUIClick', BuyMapButton, function() local money = getPlayerMoney(player) if money > 3499 then local row, column = guiGridListGetSelectedItem(Shop) local mapname = guiGridListGetItemText(Shop, row, column) triggerServerEvent("buyMapFromPanel", getLocalPlayer(), mapname) else outputChatBox("You don't have enough money, you have $" ..tostring(money).. ", you need $3500.", 255, 0, 0) end end ) That is. www.host-ar.com.ar
Aibo Posted January 2, 2011 Posted January 2, 2011 thats the whole code? are you sure that script local «player» variable is not reassigned somewhere else? anyway its a bad decision to store local player in «player» variable, can be confusing. ?
Feche1320 Posted January 2, 2011 Author Posted January 2, 2011 No, it's not the hole code, just a part. And in that client-side script its the only player variable that I have. Also, I have three buttons on my gui, and if I press at the middle of the gui for example, is like the buttons are pressed. EDIT: I still have the getPlayerMoney problem, I also tried getPlayerMoney(getLocalPlayer()) and still not working. www.host-ar.com.ar
Fabio(GNR) Posted January 2, 2011 Posted January 2, 2011 Also, I have three buttons on my gui, and if I press at the middle of the gui for example, is like the buttons are pressed. Show me the eventHandlers or what you use LuaCompiler United Social Gamers [ CnR / DD / DM & more ]
Feche1320 Posted January 2, 2011 Author Posted January 2, 2011 Also, I have three buttons on my gui, and if I press at the middle of the gui for example, is like the buttons are pressed. Show me the eventHandlers or what you use I solved that, I had to put false at the end Still having getPlayerMoney bug.. Is there any other way on getting a player's money? www.host-ar.com.ar
Fabio(GNR) Posted January 2, 2011 Posted January 2, 2011 Also, I have three buttons on my gui, and if I press at the middle of the gui for example, is like the buttons are pressed. Show me the eventHandlers or what you use I solved that, I had to put false at the end Still having getPlayerMoney bug.. Is there any other way on getting a player's money? Oh ok theres the "strike" for It should just work, really weird i'll try something and see if i get problems EDIT: Works for me, i did ( at result of clicking GUI button, to test: ) outputChatBox("you cash is: "..getPlayerMoney(client),client) and it resulted in giving me my cash number, so it must be the element... LuaCompiler United Social Gamers [ CnR / DD / DM & more ]
Feche1320 Posted January 2, 2011 Author Posted January 2, 2011 addCommandHandler('asd', function() outputChatBox(tostring(getPlayerMoney(getLocalPlayer()))) end ) This simply returns $0 to me.. www.host-ar.com.ar
Fabio(GNR) Posted January 2, 2011 Posted January 2, 2011 addCommandHandler('asd', function() outputChatBox(tostring(getPlayerMoney(getLocalPlayer()))) end ) This simply returns $0 to me.. why do you use tostring and stuff try the exact same i did EDIT: im sorry but i don't think i can help you LuaCompiler United Social Gamers [ CnR / DD / DM & more ]
Feche1320 Posted January 2, 2011 Author Posted January 2, 2011 No.. Still not working Why the hell it returns 0?? www.host-ar.com.ar
Aibo Posted January 2, 2011 Posted January 2, 2011 do you have any money? which gamemode are you using? ?
Feche1320 Posted January 3, 2011 Author Posted January 3, 2011 Yes, my /cash command script-sided returns the right ammount of money. I'm using the race gamemode. Something that I discovered, if I login, money will be displayed, and when another map starts, it returns 0 again, but if I set my money, it will return the right value. Could it be a MTA bug? A temporary fix that I did is this: addEvent('onMapStarting') addEventHandler('onMapStarting', g_Root, function() for i, player in ipairs(getElementsByType('player')) do local moneys = getPlayerMoney(player) setPlayerMoney(player, moneys) end end ) It seems to be working.. www.host-ar.com.ar
Aibo Posted January 3, 2011 Posted January 3, 2011 are there any other resources running that can possibly set player money? ?
Feche1320 Posted January 3, 2011 Author Posted January 3, 2011 Mh.. no.. really strange. www.host-ar.com.ar
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