Jump to content

getPlayerMoney strange..


Feche1320

Recommended Posts

  
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

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

EDIT:

I still have the getPlayerMoney problem, I also tried getPlayerMoney(getLocalPlayer()) and still not working.

Link to comment

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

Show me the eventHandlers or what you use :P

I solved that, I had to put false at the end :P

Still having getPlayerMoney bug..

Is there any other way on getting a player's money?

Link to comment

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

Show me the eventHandlers or what you use :P

I solved that, I had to put false at the end :P

Still having getPlayerMoney bug..

Is there any other way on getting a player's money?

Oh ok theres the "strike" for xD

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

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

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