Author Topic: Infinite condition  (Read 725 times)

How do I set a condition like white out to be never ending? Is it possible?

You'd create a scheduled loop...

Code: [Select]
function whiteOutPlayer(%obj)
{
     if(!isObject(%obj))
          return;

     %obj.setWhiteOut(1000);
     %obj.whiteoutSchedule = schedule(100,0,"whiteOutPlayer",%obj);
}

And use cancel(%obj.whiteoutSchedule); to stop it.

That doesn't make it continue looping, mind you, I'm making a server command to blind people, Ill post the code.

Code: [Select]
package Blind
{
function servercmdblind(%client, %user)
{
if(!%client.isAdmin)
{
messageClient(%client, '', '\c6You must be an Admin to use this command');

return;
}
if(%user !$= "")
{
%player = findClientByName(%user).player;
%playern = FindclientByName(%user);
%player.setwhiteout(1000);
%player.whiteoutschedule = schedule(100,0,"whiteoutschedule",%player);
messageAll("", '\c3%1\c6 was Blinded by \c3%2', %playern.name, %client.name);
messageClient(%player, '', '\c6You were blinded by \c3%1', %client.name);
}
}
};
ActivatePackage(Blind);
Please help more.

Code: [Select]
function servercmdBlind(%client, %victim)
{
     if(!%client.isAdmin)
     {
          //blah blah not admin
          return;
     }

     %victim = findClientByName(%victim);
     if(isObject(%victim))
     {
          if(!isObject(%victim.player))
          {
               //blah blah not spawned yet
               return;
          }

          if(isEventPending(%victim.player.whiteoutSch))
          {
               cancel(%victim.player.whiteoutSch);
               //blah blah you're not so blind anymore
               return;
          }
          playerWhiteout(%victim.player);
          //blah blah you're blind messages here
     }
}

function playerWhiteout(%player)
{
     if(!isObject(%player))
          return;

     %player.setWhiteout(1000);
     %player.whiteoutSch = schedule(100,0,"playerWhiteout",%player);
}

Its less work to just give you a nearly finished thing instead of teaching you not to be stupid.

=(

By the way I laughed when it read "Blah Blah Blah not so blind anymore" XD Ephi you are awesome
« Last Edit: March 13, 2009, 08:53:38 PM by AGlass0fMilk »

For some reason, it's still not working. Did I mention there was a second command? It's to un Blind the person. Here is the entire code:
Code: [Select]
function servercmdblind(%client, %user)
{
if(!%client.isAdmin)
{
messageClient(%client, '', '\c6You must be an Admin to use this command');

return;
}
if(%user !$= "")
{
%player = findClientByName(%user).player;
%playern = FindclientByName(%user);
if(!isObject(%player))
{
messageClient(%Client, '', '\c6That player hasnt spawned yet!');

return;
}
else
{
WhiteOut(%player);
messageAll("", '\c3%1\c6 was Blinded by \c3%2', %playern.name, %client.name);
messageClient(%player, '', '\c6You were blinded by \c3%1', %client.name);
}

function Whiteout(%player)
{
if(!isObject(%player))

return;

%player.setWhiteout(1000);
%player.whiteoutsch = schedule(100,0,"Whiteout",%player);
}

function Servercmdunblind(%Client, %user, %player, %playern)
{
if(!%client.isAdmin)
{
messageClient(%client, '', '\c6You must be an Admin to use this command');

return;
}
if(!isObject(%player))
{
messageClient(%Client,'', '\c6That player hasnt spawned yet!');

return;
}
if(%user !$= "")
{
cancel(%player.whiteoutsch);
messageAll("", '\c3%1 \c6has un blinded \c3%2', %playern.name, %client.name);
messageClient(%player, '', '\c3%1 \c6 has un blinded you.', %Client.name);
}
}
}
Now here is the syntax in the console (I just took a chunk of the script and put the error halt where it was in the console):
Code: [Select]
{
WhiteOut(%player);
messageAll("", '\c3%1\c6 was Blinded by \c3%2', %playern.name, %client.name);
messageClient(%player, '', '\c6You were blinded by \c3%1', %client.name);
}

function ##W##hiteout(%player) <<< (this is not in the real code, here so it's not so hard to find the error)
{
if(!isObject(%player))

return;

%player.setWhiteout(1000);
%player.whiteoutsch = schedule(100,0,"Whiteout",%player);
}

function Servercmdunblind(%Client, %user, %player, %playern)
{
Could someone tell me why this is syntaxing?

The code I provided already unblinds them if you do /blind name again.

Well, I re-made my code and it is similar to yours but, it does not syntax but does not white out. Here is the code:

-snip-
I did mess up the code, I left in some of my variables (silly me)
« Last Edit: March 13, 2009, 10:32:27 PM by AGlass0fMilk »

It works, I'm locking, might release, and I will add prefs like the kill script if I release, And thank you ephi, I will credit you =D