Jump to content

check this code


Samking

Recommended Posts

Posted
function fly()
if isPedInVehicle(localPlayer) == false then
outputChatBox("You can only use FLY car mode when in Vehicle", 255, 0, 0, true)
end
if isPedInVehicle(localPlayer) == true then
if source == GUIEditor.button[15] then
setWorldSpecialPropertyEnabled("aircars", true)
outputChatBox("Fly Mode is Disabled ", 255,215,0, true)
end
end
end
addEventHandler("onClientGUIClick", GUIEditor.button[15], fly, false)

Bad Argument @AddEventHsndler  Except Element Argument 2 got nil

plz fix

  • Moderators
Posted

addEventHandler("onClientGUIClick", GUIEditor.button[15], fly, false)

The table reference inside of the variable GUIEditor.button[15] doesn't contain the reference of a button[element].

With other words, the there is no button (yet) created when the line 12 is executed.

 

 

This might solve the problem, if the issue is caused by a wrong code execution order:

addEventHandler("onClientResourceStart", resourceRoot, 
function ()
	addEventHandler("onClientGUIClick", GUIEditor.button[15], fly, false)
end, true, "low")

If the button doesn't exist, this code will not solve your problem.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
12 hours ago, IIYAMA said:

addEventHandler("onClientGUIClick", GUIEditor.button[15], fly, false)

The table reference inside of the variable GUIEditor.button[15] doesn't contain the reference of a button[element].

With other words, the there is no button (yet) created when the line 12 is executed.

 

 

This might solve the problem, if the issue is caused by a wrong code execution order:


addEventHandler("onClientResourceStart", resourceRoot, 
function ()
	addEventHandler("onClientGUIClick", GUIEditor.button[15], fly, false)
end, true, "low")

If the button doesn't exist, this code will not solve your problem.

It's not Working Plz can u make one for me?

 

Posted
1 hour ago, Samking said:

It's not Working Plz can u make one for me?

 

Show us code of button creation "GUIEditor.button[15]".

Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة

ليس عليك اسعاد الجميع ,
ولكن عليك بإن لا تؤذي أحداً 

=========
You do not have to make everyone happy,
But you should not hurt anyone

 

Want to contact with me?

 

Discord: JustCarry#2616 (Always there)
Skype: Live:JustCarry10 (Not always)

  • Moderators
Posted
2 hours ago, Samking said:

It's not Working Plz can u make one for me?

 

My purpose here is teaching and not free scripting.

Please help yourself:

https://wiki.multitheftauto.com/wiki/GuiCreateButton

https://wiki.multitheftauto.com/wiki/AddEventHandler

 

  • Thanks 1

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
3 hours ago, iMr.WiFi..! said:

Show us code of button creation "GUIEditor.button[15]".

        GUIEditor.button[15] = guiCreateButton(203, 273, 128, 59, "Fly car", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[15], "default-bold-small")
        guiSetProperty(GUIEditor.button[15], "NormalTextColour", "FF0C6DF2")

 

Posted
1 hour ago, Samking said:

        GUIEditor.button[15] = guiCreateButton(203, 273, 128, 59, "Fly car", false, GUIEditor.window[1])
        guiSetFont(GUIEditor.button[15], "default-bold-small")
        guiSetProperty(GUIEditor.button[15], "NormalTextColour", "FF0C6DF2")

 

Put your codes under the creation of the button

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