Feche1320 Posted January 2, 2011 Share Posted January 2, 2011 getPlayerMoney on client-side scripts sometimes returns me 0, is it a bug? Link to comment
Discord Moderators Zango Posted January 2, 2011 Discord Moderators Share Posted January 2, 2011 If player's cash isn't 0 and the result differentiates from the serverside one, then yes? Link to comment
Feche1320 Posted January 2, 2011 Author Share Posted January 2, 2011 I have a server-side client (/cash), and it show the right ammount, but client-side sometimes returns $0. Link to comment
Aibo Posted January 2, 2011 Share Posted January 2, 2011 well you haven't posted any code. Link to comment
Feche1320 Posted January 2, 2011 Author Share 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. Link to comment
Aibo Posted January 2, 2011 Share 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. Link to comment
Feche1320 Posted January 2, 2011 Author Share 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. Link to comment
Fabio(GNR) Posted January 2, 2011 Share 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 Link to comment
Feche1320 Posted January 2, 2011 Author Share 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? Link to comment
Fabio(GNR) Posted January 2, 2011 Share 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... Link to comment
Feche1320 Posted January 2, 2011 Author Share Posted January 2, 2011 addCommandHandler('asd', function() outputChatBox(tostring(getPlayerMoney(getLocalPlayer()))) end ) This simply returns $0 to me.. Link to comment
Fabio(GNR) Posted January 2, 2011 Share 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 Link to comment
Feche1320 Posted January 2, 2011 Author Share Posted January 2, 2011 No.. Still not working Why the hell it returns 0?? Link to comment
Aibo Posted January 2, 2011 Share Posted January 2, 2011 do you have any money? which gamemode are you using? Link to comment
Feche1320 Posted January 3, 2011 Author Share 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.. Link to comment
Aibo Posted January 3, 2011 Share Posted January 3, 2011 are there any other resources running that can possibly set player money? Link to comment
Feche1320 Posted January 3, 2011 Author Share Posted January 3, 2011 Mh.. no.. really strange. 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