PenUltima Online

It is currently Sun Sep 07, 2008 4:02 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Sleep and no script...
PostPosted: Tue Jun 27, 2006 12:39 pm 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
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?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 2:07 pm 
Offline
Distro Developer
User avatar

Joined: Thu Apr 06, 2006 5:11 pm
Posts: 350
Location: Nederland, Texas
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...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 27, 2006 5:05 pm 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
Thanks ill try


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl