Jump to content

Anthony

Recommended Posts

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

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 by LopSided_
Link to comment

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

@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 by LopSided_
Link to comment
  • Administrators

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