Jump to content

DGS edit box strange warning


Tekken

Recommended Posts

Hi, I'm trying to implement DGS over my GUI scripts and I came to a strange warning, client.lua: 3: Bad argument @ ''addEventHandler" [Expected element at argument 2, got nil] witch is strange that the element exists and the script works just fine while using GUI however this is a simple example of what my script does, actually I'm trying to update a gridlist while typing something into an edit box.

local shop = {window = {},edit={}};

addEventHandler("onClientResourceStart", resourceRoot, function()
	shop.window[1] = dgs:dgsCreateWindow((sW-483)/2, (sH-352)/2, 483, 352, "some window", false, 0xff000000, 25, nil, 0xC800ff00, nil, 0x96141414, 5, false);
	shop.edit[1] = dgs:dgsCreateEdit(419, 81, 40, 27, "1", false, shop.window[1]);
end);

addEventHandler("onDgsTextChange", shop.edit[1], function()
	-- do something...
end);

Greetings

Link to comment
  • Moderators
1 hour ago, Tekken said:

Hi, I'm trying to implement DGS over my GUI scripts and I came to a strange warning

onClientResourceStart triggers later than the moment you try to attach the addEventHandler below.

  • Like 1
Link to comment
  • Scripting Moderators

Your code doesn't work with GUI. You will get the same warning.

local shop = {window = {},edit={}};

addEventHandler("onClientResourceStart", resourceRoot, function()
	shop.window[1] = dgs:dgsCreateWindow((sW-483)/2, (sH-352)/2, 483, 352, "some window", false, 0xff000000, 25, nil, 0xC800ff00, nil, 0x96141414, 5, false);
	shop.edit[1] = dgs:dgsCreateEdit(419, 81, 40, 27, "1", false, shop.window[1]);
   addEventHandler("onDgsTextChange", shop.edit[1], function()
		-- do something...
	end,false);
end);

 

Edited by thisdp
  • Like 1
Link to comment
2 hours ago, thisdp said:

Your code doesn't work with GUI. You will get the same warning.


local shop = {window = {},edit={}};

addEventHandler("onClientResourceStart", resourceRoot, function()
	shop.window[1] = dgs:dgsCreateWindow((sW-483)/2, (sH-352)/2, 483, 352, "some window", false, 0xff000000, 25, nil, 0xC800ff00, nil, 0x96141414, 5, false);
	shop.edit[1] = dgs:dgsCreateEdit(419, 81, 40, 27, "1", false, shop.window[1]);
   addEventHandler("onDgsTextChange", shop.edit[1], function()
		-- do something...
	end,false);
end);

 

Ok got it thank you. I actually use a slightly different way but the same principal however that didn’t work with DGS so I try’d like this and I got this warning. Thank you both.

I use « onClientGUIClick », resourceRoot, etc and check the source within the function however didn’t updated my gui don’t know why 

So I should attach it within the create function I’ m I right ?

Edited by Tekken
Link to comment
  • Scripting Moderators

if you are using DGS

onClientGUIClick is unusable, use onDgsMouseClick instead, You'd better check wiki otherwise you may confuse this function with onClientGUIClick

Link to comment
  • Scripting Moderators
12 minutes ago, Tekken said:

When I said onClientGUIClick I was talking about GUI, I know DGS won’t work I have read the wiki ;)

I don't recommand you to bind "onClientGUIClick" on resourceRoot, it takes more CPU resource. Don't set the 4th argument to false when binding "onClientGUIClick" on resourceRoot.

  • Like 1
Link to comment
1 hour ago, thisdp said:

I don't recommand you to bind "onClientGUIClick" on resourceRoot, it takes more CPU resource. Don't set the 4th argument to false when binding "onClientGUIClick" on resourceRoot.

Thanks I will keep that in mind.

  • Like 1
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...