Author Topic: Finding Parameter Names  (Read 1728 times)

« Last Edit: November 05, 2008, 08:41:05 PM by Truce »

The important part is probably based in the engine.

As far as a trace shows, fxDTSBrick::onPlayerTouch is called for any player object, then that function defines whether to do the onPlayerTouch or onBotTouch event.

Do you know if anything happens with ::onCollision, and thus it checks the datablock type to determine what to output?

oncollision is first impact, onplayertouch is players bounding/near the brick

Ah okay.

So, for this tidbit of code...

Code: [Select]
package CmdFilter {
     function serverCmdBan(%client,%stuff){
          if($permission = 0) {
               messageclient(%client,'','\c0Sorry, only \c3Super Admins \c0can ban at this time.');
               break;
          }
          else {
               Parent::serverCmdBan(%client,%stuff);
          }
     }
};

activatePackage(CmdFilter);

...since the serverCmd Ban is built into the game, how can I figure out what %stuff is? I know the in-game syntax is:

Quote
/ban id [id] [time] [reason]

So how would I go about finding the proper names for the parameters?
« Last Edit: November 06, 2008, 03:43:01 PM by Truce »

You can use any name for the arguments, it doesn't effect it.

As Destiny said, the name of the parameters never matter, but you should give it a name that will say what it is.
Since there's four arguments in the /command, the parameters would be something like :

The standard %client for servercmds, %blid, %something, %time, and %reason.
I really don't know what %something does, as I've used several values for it and it seemed to work fine.

I thought it was client object's ID

Its just

servercmdban(%client,%victimClientID,%victimBLID,%time,%reason)

You can use any name for the arguments, it doesn't effect it.

I know parameter names doesn't matter if there's nothing trying to read it.
Like if I create my own cmd I choose the names for the parameters; I know, I've done it.

But if I'm using a parent function, wouldn't it matter?
For example, for my code, all I needed is the %client who uses the cmd.
However, the built-in ban cmd uses (and expects) more parameters.

So if I put in, say, serverCmdBan(%client,%blah,%blah2,%blah3,%blah4), since I know it has four user-defined parameters, wouldn't the parent not read %blah, since it's expecting something else? (Which, in this case, is %victimClientID, as Ephialtes pointed out.)

Also, thanks Ephialtes for telling me, but I'm going to need a lot of cmds' parameters. And I assume you don't want me to ask you each one, so is there any way to find the parameters of built-in cmds?

If you set that as your function and then call parent::servercmdBan(%client,%blah,%blah2,%blah3,%blah4); it'll work just as well.

Oh, ok then...
Torque is very interesting. o_o

Its the same in any programming language.

Odd; can you not parent serverCmdBan?

Code: [Select]
package BanFilter {
function serverCmdBan(%client,%1,%2,%3,%4) {
if($admincontrols::ban $= 0) {
messageall('','Win');
Parent::serverCmdBan(%client,%1,%2,%3,%4);
}
else {
messageall('','Fail');
}
}
};
activatePackage(BanFilter);

That doesn't work. However, this does:

Code: [Select]
package BanFilter {
function serverCmdWand(%client) {
if($admincontrols::ban $= 0) {
messageall('','Win');
Parent::serverCmdWand(%client);
}
else {
messageall('','Fail');
}
}
};
activatePackage(BanFilter);

Only thing that's different is that it uses serverCmdWand instead.

EDIT:

Yet, this does...

Code: [Select]
package BanFilter {
function serverCmdBan(%client,%victimClientID,%victimBLID,%time,%reason) {
if($admincontrols::ban $= 0) {
messageall('','Win');
Parent::serverCmdBan(%client,%victimClientID,%victimBLID,%time,%reason);
}
else {
messageall('','Fail');
}
}
};
activatePackage(BanFilter);

So it IS true that you need the exact parameter names?
Or did I do something else wrong?

EDIT 2:

Seems you can't use %1, %2, etc. It has to be %a, %b, and so on.
Answered my own question.
« Last Edit: November 06, 2008, 03:47:44 PM by Truce »

Yeah, variables cant start with a number.