Author Topic: /spy command functionality?  (Read 3813 times)

How does the /spy command work, when numbers are the parameters? I can't seem to /spy this guy, but i can /find him and use eval on him just fine.














Contributors
-Magus-Conan
-DragonoidSlayer-Zealot
-Xenos the Red-Owl
-The Brighter Dark-Chill
-Uxie-Teneksi
-Whirlwind

If you want to contribute, send me a PM, with whatever you feel shows off your talent! :)
« Last Edit: September 22, 2015, 11:29:38 PM by Conan »

It's interpreting the number as a client object.  It also doesn't actually do any validation to make sure that the number does in fact reference a client object - 11 is neither a client nor does it have a player.

How /spy works is making a loop into each client and comparing the string to search a client's name you were searching for.

When using eval without quotes for a number, it will try to find it as an object ID, which is 11, but if you put that into a string, it will search for the name instead of an object.

that seems a bit backwards, since spy should then work?
but isn't spy the one that's referencing object 11 instead of the client, so can't find it's player and says the player doesn't exist?

that seems a bit backwards, since spy should then work?
but isn't spy the one that's referencing object 11 instead of the client, so can't find it's player and says the player doesn't exist?

It's interpreting the number as a client object.  It also doesn't actually do any validation to make sure that the number does in fact reference a client object - 11 is neither a client nor does it have a player.
aka its trying to spy the player object with the objectid 11, but since it doesn't exist it cant. in addition, it doesn't check whether or not the client even exists

Code: allGameScripts.cs.dso (37 lines)
function serverCmdSpy(%client, %victimName)
{
   if(!%client.isAdmin)
       return;

   if(mFloor(%victimName) > 0)
    {
       if(isObject(%victimName.Player))
        {
           %client.Camera.setMode("Corpse", %victimName.Player);
           %client.setControlObject(%client.Camera);
           %client.isSpying = "1";
        }
       else
           messageClient(%client, '', "Client does not have a player object");
    }
   else
   {
       %victimClient = findclientbyname(%victimName);

       if(%victimClient)
        {
           %victimPlayer = %victimClient.Player;

           if(isObject(%victimPlayer))
            {
               %client.Camera.setMode("Corpse", %victimPlayer);
               %client.setControlObject(%client.Camera);
               %client.isSpying = "1";
            }
           else
               messageClient(%client, '', "Client does not have a player object");
        }
       else
           messageClient(%client, '', "Client not found");
    }
}


This allows the spy button in the admin menu to work, as it uses /spy with the object id of clients. Unfortunately it also makes you unable to use the /spy command for clients whose name is a number.

-Snip of should be compiled and encrypted code-

This allows the spy button in the admin menu to work, as it uses /spy with the object id of clients. Unfortunately it also makes you unable to use the /spy command for clients whose name is a number.

How exactly did you get into the DSO?

Probably BLDasm by computermix.

so it's looking for an objectid instead of an objects name?

if the input is a number, it assumes it's the client ID, not the name
you'd need a way to denote the name is not a number somehow, and still pass findclientbyname, and that sounds difficult

if the input is a number, it assumes it's the client ID, not the name
you'd need a way to denote the name is not a number somehow, and still pass findclientbyname, and that sounds difficult

It isn't difficult, it's impossible. You can't use the default /spy command in chat if the name is a number. You'll have to use the admin menu.

It isn't difficult, it's impossible. You can't use the default /spy command in chat if the name is a number. You'll have to use the admin menu.
can't you package it?











Contributors
-Magus-Conan
-DragonoidSlayer-Zealot
-Xenos the Red-Owl
-The Brighter Dark-Chill
-Uxie-Teneksi
-Whirlwind

If you want to contribute, send me a PM, with whatever you feel shows off your talent! :)
« Last Edit: September 22, 2015, 11:28:03 PM by Conan »

can't you package it?

Then you'll most likely break the button in admin menu. I guess you could make a second command without the switch

probably overwrite it to be something like /spy name bool

then change if(mFloor(%victimName) > 0) to if(mFloor(%victimName) > 0 || bool)

but then if spy ever gets updated in the future, that could be an issue

probably overwrite it to be something like /spy name bool

then change if(mFloor(%victimName) > 0) to if(mFloor(%victimName) > 0 || bool)

but then if spy ever gets updated in the future, that could be an issue
It would have to be if(mFloor(%victimName) > 0 && !%bool) in this case