Author Topic: Toggling Command + Rapidly called  (Read 508 times)

How would i make a command toggled and rapidly called if it is on

What i have:
function ServercmdTEHCOMMAND(%client) {
   if(isObject(%client.player))
      if(%client.isAdmin==1 || client.isSuperAdmin==1)
         {
            if (%client.ISTEHCOMMANDON==1){
            %client.ISTEHCOMMANDON = 0;
            }
            else{
            %client.ISTEHCOMMANDON = 1;
            OTHERFUNCTION(%client);
            
            }
         }
   }
   function OTHERFUNCTION(%client){
   if (%client.ISTEHCOMMANDON==1){
   //do rapidly called stuff
   schedule(0,1000,OTHERFUNCTION);}
   
   }


Please help

I'm not entirely sure what you did, but in OTHERFUNCTION you should be using schedule(0,1000,OTHERFUNCTION, %client);

Also, 1000 isn't very rapid. That's once a second.

Also, 1000 isn't very rapid. That's once a second.
I know, was an example :P

I'm not entirely sure what you did, but in OTHERFUNCTION you should be using schedule(0,1000,OTHERFUNCTION, %client);
I had it there but took it out when i tried $OTHERFUNCTION instead of %client.OTHERFUNCTION

I had it there but took it out when i tried $OTHERFUNCTION instead of %client.OTHERFUNCTION
$ denotes a global variable and functions are by default global and they're not variables so you'd never use $functionname it'd return a syntax error. Since your function is named OTHERFUNCTION not GameConnection::OTHERFUNCTION you can't do %client.OTHERFUNCTION. If you did what I said and included %client in your schedule it would loop properly because it would continue satisfying the %client argument where as in yours it looses it after the first iteration.

Would this work? I'm a bit rusty.

Code: [Select]
function serverCmdTheCommand(%client) {
if(%client.isAdmin || %client.isSuperAdmin) {
if(%client.isCycling)
%client.isCycling = 0;
else {
%client.isCycling = 1;
%client.player.otherFunction();
}
}
}

function Player::otherFunction(%player) {
%client = %player.client;
if(%client.isCycling) {
%client.beStupid();
%player.schedule(10, otherFunction);
}
}