Sleep and no script...

Here you can post threads requesting help on the official POL Ultima Online Emulator Core 095. Note: Core 095 is no longer officially supported.
Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Sleep and no script...

Post by Poi »

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?
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

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: Select all

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...
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Thanks ill try
Post Reply