Author Topic: /command  (Read 1887 times)

Using a /command echos something


Im just now sure how the server would detect a /command at all.

I saw this and wondered how this worked

to set it up so /opengui GuiName  will work you ned the following:

in server.cs
Code: [Select]
function serverCmdOpenGui(%client, %guiName)
  {
   commandToClient(%client, 'OpenGui', %guiName);
  }

in client.cs
Code: [Select]
function clientCmdOpenGui(%guiName)
  {
   Canvas.pushDialog(%guiName);
  }

definately complicated - but due to the way blockland and torque is setup, this is what you need.


Im guessing that you would replace guiname with a message statement or an echo?
« Last Edit: July 20, 2010, 10:33:07 AM by Obibital »

it works like this:

%guiName is whatever you put after /opengui

so if I said "/opengui ABCGui" it would then call OpenGUI(%guiName) [in this case %guiName is ABCGui so it would be OpenGUI(ABCGui)]

which would then perform Canvas.pushDialog(ABCGui); because ABCGui is what %guiName has been defined as

also, for clientCmd's to work you'll need a support add-on made by truce which I have no idea where to find
« Last Edit: July 20, 2010, 10:40:25 AM by SpreadsPlague »

servercmdYourCommand(%arguments)
{
whatever you want it to do
}

/yourcommand

Ahh, so instead of something like an if statement you use servercmd

like
Code: [Select]
servercmdtest(%arguments)
{
echo ("worked")

}


and i would type /test?





**In another issue, what is a argument? ive looked in the appendix and many threads but failed to find the true answer. Before i learn to script, i want to be able to read it in plain english.

don't actually put %arguments in the brackets, that was just to show you that's where you put arguments

arguments are like %client , %victim , %a, %b, etc etc

anyways make sure to add semicolons to ensure proper syntax


-tiredsnip-
« Last Edit: July 20, 2010, 10:50:26 AM by SpreadsPlague »

don't actually put %arguments in the brackets, that was just to show you that's where you put arguments

arguments are like %client , %victim , %a, %b, etc etc

anyways make sure to add semicolons to ensure proper syntax




your command should look like this

Code: [Select]
servercmdtest()
{
echo("worked");
}


servercmd's dont need to be in a function do they?


Well, i knew they were items that had %'s in front of them, like %client, or %obj, and whatnot

But what are they for? what do they do?
why do we need them? thats what i wanted to know


servercmd's dont need to be in a function do they?


sorry, yes they do, it's 10 AM here and I haven't even slept yet

I'm sorry for the confusing advice, hopefully someone more conscious will come soon lol




sorry, your command should actually look like this
Code: [Select]
function servercmdtest
{
echo("worked");
}









Quote
Well, i knew they were items that had %'s in front of them, like %client, or %obj, and whatnot

But what are they for? what do they do?
why do we need them? thats what i wanted to know

%client is always your client,
%obj is an object,



here's a terrible example using arguments

Code: [Select]
function servercmdcompare(%a, %b)
{
   if(%a == %b)

     return;

   else

    commandtoserver('Self Delete');
}

/compare X Y would then compare X to Y

if X == Y then the script does nothing and everyone is happy

however if X != Y then you die

arguments can be used in lots of ways but unfortunately I'm too tired to remember any

sorry.. so here's a helpful tip instead


= sets a variable to something
== means is equal to


%a = 1
this sets %a to 1

if(%a == 1)
this means "if %a is 1"


I hope this post helps you somehow ..



     
   
« Last Edit: July 20, 2010, 11:00:50 AM by SpreadsPlague »

sorry, yes they do, it's 10 AM here and I haven't even slept yet

I'm sorry for the confusing advice, hopefully someone more conscious will come soon lol




sorry, your command should actually look like this
Code: [Select]
function servercmdtest
{
echo("worked");
}

Thanks much though, figured id try and do something simple first :p

I can wait for your explanation XD

EDITZ: Its not reading as a function, its just reading everything as text.
**Its 11:00 here :p
« Last Edit: July 20, 2010, 10:57:46 AM by Obibital »

**Its 11:00 here :p

I've been up since like noon yesterday :[

anyways..

EDITZ: Its not reading as a function, its just reading everything as text.

what do you mean? did you package it correctly?

I simply put it into a normal folder so i could edit it and execute it everytime i edit it, isnt that how you do it XD?

In other words its not i a .zip and the whole code is what you put up.

:\ i was thinking about the fact that, Dont you need something to activate the function?



I simply put it into a normal folder so i could edit it and execute it everytime i edit it, isnt that how you do it XD?

nope, needs to be in add-on format you can type it directly into the console if you want

function servercmdtest() { echo("working"); }

:\ i was thinking about the fact that, Dont you need something to activate the function?

no
« Last Edit: July 20, 2010, 11:55:31 AM by SpreadsPlague »

nope, needs to be in add-on format or you can type it directly into the console

function servercmdtest() { echo("working"); }

doesn't work like that

no

Ok, i was just trying to find a way to shorten the amount of time it took to edit it

So, i mostly just need to re .zip it everytime i edit and then exec("blahblahblah") in the console?

Ok, i was just trying to find a way to shorten the amount of time it took to edit it

So, i mostly just need to re .zip it everytime i edit and then exec("blahblahblah") in the console?

pretty much, but if it's short enough, typing it into the console would be faster

ignore me
« Last Edit: July 20, 2010, 11:58:46 AM by SpreadsPlague »

From the way I have been experimenting with mods you don't need to zip it unless you are done with it. I have found it much easier to open scripts in Dreamweaver edit it, hit Ctrl + S to save, and then go straight to my Blockland window open console and type
exec("add-ons/(addon name)/server.cs");   If you do plan to do this make sure it doesn't have a model (for future reference) or it will kick all clients off your server with an invalid packet error. I hope this was informative and not a waste of time to read.
P.S. after you execute it once in the console if your planning to edit and save again you can use the up arrow key to go back to your previous console command.

Yeah you don't need the zip, just but everything in the same format as if it were a zip (description.txt, server.cs, etc)


From the way I have been experimenting with mods you don't need to zip it unless you are done with it. I have found it much easier to open scripts in Dreamweaver edit it, hit Ctrl + S to save, and then go straight to my Blockland window open console and type
exec("add-ons/(addon name)/server.cs");   If you do plan to do this make sure it doesn't have a model (for future reference) or it will kick all clients off your server with an invalid packet error. I hope this was informative and not a waste of time to read.
P.S. after you execute it once in the console if your planning to edit and save again you can use the up arrow key to go back to your previous console command.


Did that exactly, But i didnt check the box in add-ons becuase i think that exec does that.

when i execute it it just shows me the entire code and says theres an error of some kind

%client is always your client,
%obj is an object,



here's a terrible example using arguments

Code: [Select]
function servercmdcompare(%a, %b)
{
   if(%a == %b)

     return;

   else

    commandtoserver('Self Delete');
}

/compare X Y would then compare X to Y

if X == Y then the script does nothing and everyone is happy

however if X != Y then you die

arguments can be used in lots of ways but unfortunately I'm too tired to remember any

sorry.. so here's a helpful tip instead


= sets a variable to something
== means is equal to


%a = 1
this sets %a to 1

if(%a == 1)
this means "if %a is 1"


I hope this post helps you somehow ..



      
    


Most of that is helpful thanks :D

Some i know from AS2 like the = is set to and the == is checking.

So basically if you want to do anything with values in functions, you need to state which values will be used?

(Im pretty sure that an argument is a value, am i correct?)
« Last Edit: July 20, 2010, 04:03:34 PM by Obibital »