Anthony Posted August 8, 2017 Share Posted August 8, 2017 bindKey("F1", "down", function() if getElementData(localPlayer,"Stats") < 2 and getElementInterior(localPlayer) == 0 and getElementDimension(localPlayer) == 0 then if not isInColExport () then guiSetVisible(Window_VS, not guiGetVisible(Window_VS)) guiSetVisible (Window_CHK, false) showCursor(guiGetVisible(Window_VS)) end end end) triggerServerEvent("onOpenGui", localPlayer) what's the wrong at this script supports English and Arabic help Link to comment
Administrators Lpsd Posted August 8, 2017 Administrators Share Posted August 8, 2017 Are there any errors when using 'debugscript 3'? Without more information it's hard to know what the problem is. 1 Link to comment
Anthony Posted August 8, 2017 Author Share Posted August 8, 2017 @LopSided_ attempt to compare boolean with number it appears when i press the bind key Link to comment
Administrators Lpsd Posted August 8, 2017 Administrators Share Posted August 8, 2017 (edited) The problem is here: getElementData(localPlayer,"Stats") < 2 "Stats" does not contain a number value, instead it contains a boolean (true or false) - this means that somewhere else in your code you are not setting that player value correctly. Edited August 8, 2017 by LopSided_ Link to comment
Anthony Posted August 8, 2017 Author Share Posted August 8, 2017 @LopSided_ and what's the right code? Link to comment
Administrators Lpsd Posted August 8, 2017 Administrators Share Posted August 8, 2017 I don't know... I haven't seen the rest of your script. Where are you setting the "Stats" value for the player? Link to comment
Abdul KariM Posted August 8, 2017 Share Posted August 8, 2017 use thing bindKey("F1", "down", function ( ) local Stats = getElementData ( localPlayer ,"Stats" ) or 0 if Stats < 2 and getElementInterior(localPlayer) == 0 and getElementDimension(localPlayer) == 0 then if not isInColExport () then guiSetVisible(Window_VS, not guiGetVisible(Window_VS)) guiSetVisible (Window_CHK, false) showCursor(guiGetVisible(Window_VS)) end end end ) if player don't have data "stats" the data equal 0 good luck Link to comment
Administrators Lpsd Posted August 8, 2017 Administrators Share Posted August 8, 2017 @Abdul KariM that just avoids the problem, it doesn't fix it. There is something going wrong in other parts of his script. Link to comment
Anthony Posted August 8, 2017 Author Share Posted August 8, 2017 @LopSided_ thanks @Abdul KariM شكرا الكود أشتغل Link to comment
Abdul KariM Posted August 8, 2017 Share Posted August 8, 2017 @LopSided_ no , There is a check if data "stats" younger than 2 will go to second check @Anthony You're Welcome Link to comment
Administrators Lpsd Posted August 8, 2017 Administrators Share Posted August 8, 2017 (edited) @Abdul KariM Yes, I'm quite aware of that. However there is still a problem somewhere else in the code as I just explained. Your "fix" is actually quite useless, since without finding the underlying problem you'll never get past the if statement. Edited August 8, 2017 by LopSided_ Link to comment
Abdul KariM Posted August 8, 2017 Share Posted August 8, 2017 @LopSided_ no no , if player doesn't have data "stats" getElementData return false so there check of numbers must replace false to 0 , to skip this problem Link to comment
Administrators Lpsd Posted August 8, 2017 Administrators Share Posted August 8, 2017 (edited) You just verified my point. You have skipped the problem. I'm not saying your "solution" doesn't stop the error from showing up - but it's really bad practice. I assume the OP is trying to create a system in which as long as the users 'level' or such is above 2 and they press F1, a GUI opens - but he's either entering the wrong value for "Stats" or simply not creating it at all. Your solution, I assume, will just return 0 every time - since "Stats" is false. This means no one will ever be able to open the GUI. The most practical approach would be to look at the stats/level system and work out why "Stats" isn't being saved or created correctly. No one is going to be able to increase their "Stats" if that system is broken. Edited August 8, 2017 by LopSided_ 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