Jump to content

Help needed with onClientGUIClick


Chilco

Recommended Posts

Hey all,

I made a button for buying repair:

function ButtonRepair()
local Moneyplayer = getElementData(getLocalPlayer(), "Money")
if (Moneyplayer > 3500 ) then
local vehicle = getPedOccupiedVehicle(getLocalPlayer())
fixVehicle(vehicle) 
setElementData(getLocalPlayer(),"Money",tostring(moneyplayer-3500))				
else
outputChatBox( "You don't have enough money ($3500) to buy repair!", getLocalPlayer(), 0, 150, 255 );
end	
 
end
addEventHandler ( "onClientGUIClick", GUIEditor_Button[1], ButtonRepair, false )

But it isn't working, can anyone help me?

Thanks,

-Chilco

Link to comment

give people some time to see your problems and help.

do you create the button you assign the event to anywhere? try tonumber(Moneyplayer) in line 3 and 6 (you even force the setElementData to save it as a string) plus variables are case sensitive(line 6). if this works you should read this page to be able to solve future problems by yourself: https://wiki.multitheftauto.com/wiki/Debugging

client side you need no player parameter in outputChatBox

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