DRW Posted May 2, 2015 Posted May 2, 2015 Hello, I'm making a kind of script that gives you a random weapon with random ammo and reproduces a sound (Like in Black Ops Zombies, but I'm still working with the GUI. Alright, the problem is that I created a button that detects if you have less money than 8000 and says you don't have enough and cancels the event, that works, but when you have enough, you are supposed to lose 8000, but you don't, actually it does nothing. Client: rRoot = getResourceRootElement(getThisResource()) function cerrarmystery () guiSetVisible(mystery,false) showCursor (false) end function abrirmystery () guiSetVisible (mystery, true) showCursor (true) end function mysterymoney (thePlayer) local money = getPlayerMoney(thePlayer) if (money < 8000) then cancelEvent () if (money < 8000) then outputChatBox ("NO TIENES SUFICIENTE DINERO") else givePlayerMoney (-8000) end end end addEvent ("cajamisterio", true) addEventHandler ("cajamisterio", localPlayer, abrirmystery) addEventHandler ("onClientResourceStart", rRoot,cerrarmystery) local screenW, screenH = guiGetScreenSize() mystery = guiCreateWindow((screenW - 699) / 2, (screenH - 152) / 2, 699, 152, "CAJA MISTERIOSA", false) guiWindowSetSizable(mystery, false) mysterylabel = guiCreateLabel(55, 23, 592, 46, "¿Quieres comprar la caja aleatoria?", false, mystery) guiSetFont(mysterylabel, "sa-header") mysterybutton1 = guiCreateButton(460, 81, 187, 48, "NO.", false, mystery) guiSetFont(mysterybutton1, "default-bold-small") guiSetProperty(mysterybutton1, "NormalTextColour", "FFFF0000") mysterybutton2 = guiCreateButton(55, 81, 187, 48, "SÍ (8.000$)", false, mystery) guiSetFont(mysterybutton2, "default-bold-small") guiSetProperty(mysterybutton2, "NormalTextColour", "FF84FF00") addEventHandler ("onClientGUIClick", mysterybutton1, cerrarmystery, false) addEventHandler ("onClientGUIClick", mysterybutton2, mysterymoney, false) Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
WhoAmI Posted May 2, 2015 Posted May 2, 2015 You have to set money serverside. Client side won't work. Like that setPlayerMoney ( player, getPlayerMoney ( player ) - amount )
DRW Posted May 2, 2015 Author Posted May 2, 2015 Tried clientside, not working. Tried serverside, not working. Client function mysterymoney (thePlayer) local money = getPlayerMoney(thePlayer) if (money < 8000) then cancelEvent () if (money < 8000) then outputChatBox ("NO TIENES SUFICIENTE DINERO") else triggerServerEvent ("quitardinero",thePlayer) end end end Server function fueradinero (player) takePlayerMoney (player, 8000 ) end addEvent ("quitardinero",true) addEventHandler ("quitardinero", fueradinero) Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
WhoAmI Posted May 2, 2015 Posted May 2, 2015 Remove player from function's argument and use source instead.
DRW Posted May 2, 2015 Author Posted May 2, 2015 Remove player from function's argument and use source instead. function fueradinero () takePlayerMoney (source, 8000 ) end Still not working, also, nothing in debugscript. Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
WhoAmI Posted May 2, 2015 Posted May 2, 2015 Also add 'root' to event s-side, because as far as I can see you've forgotten about it.
WhoAmI Posted May 2, 2015 Posted May 2, 2015 function mysterymoney (thePlayer) local money = getPlayerMoney(thePlayer) if (money < 8000) then outputChatBox ("NO TIENES SUFICIENTE DINERO") return else triggerServerEvent ("quitardinero",thePlayer) end end
DRW Posted May 2, 2015 Author Posted May 2, 2015 Also add 'root' to event s-side, because as far as I can see you've forgotten about it. function fueradinero () takePlayerMoney (source, 8000 ) end addEvent ("quitardinero",true) addEventHandler ("quitardinero", root, fueradinero Like this? It's not working... Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
WhoAmI Posted May 2, 2015 Posted May 2, 2015 1.function mysterymoney () 2.local money = getPlayerMoney() 3.if (money < 8000) then 4. outputChatBox ("NO TIENES SUFICIENTE DINERO") 5.return 6.else 7.triggerServerEvent ("quitardinero",localPlayer) 8.end 9.end 10. If doesn't work check debugscript.
DRW Posted May 2, 2015 Author Posted May 2, 2015 1.function mysterymoney () 2.local money = getPlayerMoney() 3.if (money < 8000) then 4. outputChatBox ("NO TIENES SUFICIENTE DINERO") 5.return 6.else 7.triggerServerEvent ("quitardinero",localPlayer) 8.end 9.end 10. If doesn't work check debugscript. FINALLY, THANK YOU VERY MUCH! Proud owner and developer of ZNEXT: Aftermath. Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience. Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. Español, Pусский, Türk, عربى, Polski, Português IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB
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