Target*() timeout

Archive of the older Feature Request Forum Posts

Moderator: POL Developer

Locked
User avatar
taxman
Journeyman Poster
Posts: 63
Joined: Tue Apr 18, 2006 11:10 pm

Target*() timeout

Post by taxman »

I wrote about it so i repeat..
additional parameter for Target*() calls - timeout for waiting. Now script stops on this call and waiting forever. Often it is not good.
Bytehawk
Apprentice Poster
Posts: 56
Joined: Fri Feb 03, 2006 2:25 am

Post by Bytehawk »

These two scripts might help in this situation (not tested!)

askfortarget.src sets a flag (cprop) on the player, starts a monitoring script (waitfortarget.src) and asks for a target. If the player does not chose a target within 5 seconds, waitfortarget.src kills the script askfortarget.src, which should also kill the target cursor. As I said above it's not tested, but should theoretically work :)

Code: Select all

// ----- askfortarget.src -----
use os;
use uo;

program askfortarget(who)

  SetObjProperty (who, "#waitfortarget", ReadGameClock ());
  start_script ("waitfortarget", array {who, GetPID (), 5});
  var victim:= Target (who);

  if (victim.acctname && (victim != who))
    PrintTextAbovePrivate (victim, who.name + " targetted you.", victim);
  else
    SendSysMessage (who, "Cancelled.");
  endif

  EraseObjProperty (who, "#waitfortarget");

endprogram

Code: Select all

// ----- waitfortarget.src -----
use os;
use uo;

program waitfortarget(params)

  var wait:= params[3];
  var pid:= params[2];
  var who:= params[1];
  Sleep (wait);

  if (GetObjProperty (who, "#waitfortarget"))
    EraseObjProperty (who, "#waitfortarget");
    GetProcess (pid).kill ();
  endif

endprogram
User avatar
taxman
Journeyman Poster
Posts: 63
Joined: Tue Apr 18, 2006 11:10 pm

Post by taxman »

i can kill waiting script but i cant continue it execution. As sometimes people says in Odessa "Its two great differences" ;)
Marilla

Post by Marilla »

I like this idea; let the Target() call expire, returning a specific error on timeout. The only thing I'd be interested in knowing about further would be could the target on the client be handled somehow, as just letting it sit there might be confusing. Though on expiration, the script could send a SysMessage or something to let the player know it expired, I guess.
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm

Post by CWO »

You can make the client cancel a target just by

SendPacket(who, "6C000000000003000000000000000000000000")

This will automatically make the client send the target info as if you hit ESC.
Marilla

Post by Marilla »

Beany-ness :)
Bytehawk
Apprentice Poster
Posts: 56
Joined: Fri Feb 03, 2006 2:25 am

Post by Bytehawk »

This is in fact a "little" bit more elegant then my solution.

Note to self: DO look at that packet thing finally!
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

Target() only sends a packet to the client, there is no way to "time out". Sending the cancel target packet is the closest thing.

And yes, you should look into those packet things. With packet hooking you can do almost anything. The power can be quite intoxicating.
MuadDib
Former Developer
Posts: 1091
Joined: Sun Feb 12, 2006 9:50 pm

Post by MuadDib »

And, I am afraid without some intense thread work (aka, won't work without multithreading enabled in pol.cfg), a core-side option will take some time to come up with. Unless I actually do my job and investigate all possibilities. Which, atm, takes more time than I got.

But, never underestimate my level of boredom. Already done several 096.1 fixes, and much more. Will see what I can do, outside of thread work.
Locked