PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
Sleep and no script...

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> General Help (095)
Display posts from previous:   

Author Message
Poi



Joined: 14 Apr 2006
Posts: 203

PostPosted: Tue Jun 27, 2006 4:39 pm    Post subject: Sleep and no script... Reply with quote

Ok im making a barter script, but i dont want people spamming non stop, and i tried putting in a sleepms(60000); at the end, but it doesnt work, how do you make it so it waits a certain amount of time befor they can run that script again?

Author Message
tekproxy
Distro Developer


Joined: 06 Apr 2006
Posts: 350
Location: Nederland, Texas

PostPosted: Tue Jun 27, 2006 6:07 pm    Post subject: Reply with quote

That sleep statement will just cause it to sleep before ending the script, but it will not prevent someone from starting a new instance of the script.

One way to prevent them from doing it again would be to set a cprop on them storing the last time they ran the script and check/compare the stored cprop on the player with the current time. So, for example:

Code:
use uo;
use os;

CONST WAIT_TIME := 60; // must wait 60 seconds

program Barter(mobile)
   var last_barter := CInt(GetObjProperty(mobile, "#LastBarter"));
   
   // If last_barter was set, and the difference between then and now is less than WAIT_TIME, fail with a message
   if ( last_barter  && (Polcore().systime - last_barter) < WAIT_TIME )
      SendSysMessage(mobile, "You must wait at least "+WAIT_TIME+" seconds before bartering again.");
      return 0;
   else
      // Set #LastBarter prop on moible
      // the "#" will tell POL to not save this prop
      // when the server restarts, the prop is gone
      SetObjProperty(mobile, "#LastBarter", Polcore().systime);
   endif
   
   // Do barter stuff here
endprogram


Something like that...

Author Message
Poi



Joined: 14 Apr 2006
Posts: 203

PostPosted: Tue Jun 27, 2006 9:05 pm    Post subject: Reply with quote

Thanks ill try

Post new topic   Reply to topic    PenUltima Online Forum Index -> General Help (095) All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty