Difference between revisions of "Give InvItem every n hours"
Jump to navigation
Jump to search
Kireji Haiku (talk | contribs) m (-1 >> ERR_GENERIC and 0 >> FALSE and 1 >> TRUE) |
Omei Qunhua (talk | contribs) m (-1 meaning not found, is not a generic error) |
||
Line 36: | Line 36: | ||
integer giveallowed = FALSE; | integer giveallowed = FALSE; | ||
integer index = llListFindList( visitors, [ llDetectedKey(n) ] ); | integer index = llListFindList( visitors, [ llDetectedKey(n) ] ); | ||
if (index == | if (index == -1) | ||
{ | { | ||
visitors = visitors + [ llDetectedKey(n) ]; | visitors = visitors + [ llDetectedKey(n) ]; |
Revision as of 13:20, 9 September 2014
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
This script will give an inventory item on touch only every n hours, even if somebody touches the object more than once.
<lsl> // Idea and written by Criz Collins // Don't sell this FREE script!!!
string giveitem = "name of item in objects inventory"; float giveevery = 24; // hours!
/////////////////////////////////////////////
list visitors; list lastsent; integer n;
default {
on_rez( integer param ) { llResetScript(); }
changed(integer change) { if (change & CHANGED_INVENTORY) { llResetScript(); } } touch_start(integer total_number) { for (n=0; n<total_number; n++) { integer giveallowed = FALSE; integer index = llListFindList( visitors, [ llDetectedKey(n) ] ); if (index == -1) { visitors = visitors + [ llDetectedKey(n) ]; lastsent = lastsent + [(integer)llGetUnixTime()]; giveallowed = TRUE; } else { if (llList2Integer(lastsent, index) <= ((integer)llGetUnixTime() - (giveevery * 60 * 60))) { list replacer = [(integer)llGetUnixTime()]; list newlastsent = llListReplaceList(lastsent, replacer, index, index); lastsent = []; lastsent = newlastsent; giveallowed = TRUE; }
// else giveallowed = FALSE;
} if (giveallowed)// == TRUE { llGiveInventory(llDetectedKey(n), giveitem); } } }
} </lsl>
Criz Collins 11:14, 11 June 2008 (PDT)