Hi, at the moment i'm scripting a new gamemode, and a component involves a GUI that lets you purchase weapons, items and vehicles. If i scripted it normally with IF statements, the script would have to go through all weapons, items and vehicles to find the button you clicked. As a result, i'm trying to limit its search range by making it only do a certain set of if statements for each tab, for example if the "Weapons" tab is open and you click a button, it will jump to a set of "if's" for which weapon button was clicked.
Here is my client script at the moment, but the Purchase doesn't work
function onClientGUIClick (button, state, absoluteX, absoluteYe)
if selectedTab == TabItems then
if (source == WepBtnSHOVEL) then
money = getPlayerMoney (source)
if (money >= 300) then
player = getLocalPlayer()
outputChatBox ("You bought a SHOVEL for $300",225,225,0)
takePlayerMoney(300)
triggerServerEvent ("GiveSHOVEL",getLocalPlayer(),GiveSHOVEL)
else
outputChatBox ("Your funds are too low")
end
elseif (source == WepBtnKATANA) then
money = getPlayerMoney (source)
if (money >= 500) then
player = getLocalPlayer()
outputChatBox ("You bought a KATANA for $500",225,225,0)
takePlayerMoney(500)
triggerServerEvent ("GiveKATANA",getLocalPlayer(),GiveKATANA)
else
outputChatBox ("Your funds are too low")
end
end
end
if (source == StephCloseBtn) then guiSetVisible (StephMission, false) showCursor (false)
end
end
addEventHandler ("onClientGUIClick", getRootElement(), onClientGUIClick)
Here's the Server element:
function GiveSHOVEL ()
giveWeapon (source,6,1,true)
end
addEvent("GiveSHOVEL",true)
addEventHandler("GiveSHOVEL",getRootElement(),GiveSHOVEL)
function GiveKATANA ()
giveWeapon (source,8,1,true)
end
addEvent("GiveKATANA",true)
addEventHandler("GiveKATANA",getRootElement(),GiveKATANA)
What's wrong with it?
Thanks