Author Topic: need help with %arg 1  (Read 2239 times)

Another problem I just saw - popdialog closes a GUI, not opens

yea i figured that. BUT i fixed it. AND another error. it is that it only opens it for the game host. How can it open for other people.

You can do this.
function gameConnection::openGUI(%this, %arg1, %cl)
{
 if(%arg1 $= "")
 {
  return;
 }
commandToClient('OpenGui', %arg1);
}
(This in the clients gui thing)
function clientCommandOpenGUI(%arg1)
{
 canvas.pushDialog(%arg1);
}
Im pretty sure this works.

That didn't work either.

Everyone else needs to have a clientside add-on with the clientCmd in it.

Everyone in here but headcrab is obviously terrible at scripting.

Code: [Select]
//serverside

function gameConnection::openGUI(%this, %arg)
{
if(!%arg)
return;
commandToClient(%this, 'openGUI',%arg);
}

registerOutputEvent("gameConnection","openGUI","string 100 100",0);

//clientside -- this is REQUIRED for the event to work

function clientCmdOpenGUI(%arg)
{
if(!isObject(%arg))
return;
canvas.pushDialog(%arg);
}

That should work perfectly.

Didn't work. It doesn't even pop up the gui.

Your event is named OpenGUI while the method is named GUIOpener

You're also trying to call a clientside function through the server.
Anytime anyone in the server triggers the event, it will open the GUI on the host's screen.

And finally, using both %this and %client in that function is redundant.


CRAP

I was going to say the exact same thing.

Everyone in here but headcrab is obviously terrible at scripting.

Code: [Select]
//serverside

function gameConnection::openGUI(%this, %arg)
{
if(!%arg)
return;
commandToClient(%this, 'openGUI',%arg);
}

registerOutputEvent("gameConnection","openGUI","string 100 100",0);

//clientside -- this is REQUIRED for the event to work

function clientCmdOpenGUI(%arg)
{
if(!isObject(%arg))
return;
canvas.pushDialog(%arg);
}

That should work perfectly.

As i just said... This is NOT working perfectly. THIS doesn't even pop up the GUI. COULD SOMEONE TEST IT BEFORE THEY RELEASE THERE THEORY! I mean seriously. this should work. omg well it doesn't.

What are you entering in the string. You're probably putting an invalid gui name. Try "JoinServerGui"

no syntax errors. But no GUI pops up still. I use like honormining. (me and a friend made a gui name honormining) But yea wont pop up.

Did you remember to execute the GUI file itself?

The problem :
Code: [Select]
if(!%arg)
    return;

Since %arg is a string, and strings evaluate to 0, !%arg will evaluate to 1, and will return.

Switch back to if(%arg $= "") like the last several posts.
Or you could completely delete those two lines since the isObject check in the clientCmd does basically the same thing.
« Last Edit: August 08, 2010, 04:48:33 PM by Headcrab Zombie »