Hey guys, ive been trying to get my trashbarrel script to work but im having next to no luck... Dont get me wrong it works but it wont sleep for 30seconds when i put in sleep(30);, it goes right through and deletes the item instantly would anyone be able to see what im doing wrong?
use uo;
use os;
include "include/objtype";
program trash(who, trashcan)
foreach item in EnumerateItemsInContainer(trashcan)
if (item)
DoWaitMessage(who, trashcan, "This item will be deleted in 30 seconds.");
Sleep(30);
if (item.container.serial == trashcan.serial)
DestroyItem(item);
endif
endif
PlaySoundEffect(trashcan, 0x226 );
endforeach
endprogram
function DoWaitMessage(who, what, msg)
if (who.concealed or what.container)
if (msg)
PrintTextAbovePrivate(what, msg, who);
endif
else
if (msg)
PrintTextAbove(what, msg);
endif
endif
endfunction
program onInsert_trash (who, container, movetype, inserttype, item)
if (!item)
syslog("wtf was that!?");
return;
endif
DoWaitMessage(who, container, "This item will be deleted in 30 seconds.");
detach();
Sleep(30);
if (!item or !container)
return;
endif
if (item.container.serial == container.serial)
DestroyItem(item);
endif
endprogram
something like this, haven't tested but should work:)
but it's a wrong way anyway.
if you use your trashcan 100 times, it starts the timer 100 times (then it plays soundeffect 100 times etc.)..
if you use your trashcan, wait 29secs, and then insert an item - it'll be destroyed in 1 second.
bad idea imho;)
better use onInsert or control script for something like this, or do some checks if trashcan is already used.
program trash(who, trashcan)
DoWaitMessage(who, trashcan, "This item will be deleted in 30 seconds.");
detach();
Sleep(30);
foreach item in EnumerateItemsInContainer(trashcan)
if (item)
if (item.container.serial == trashcan.serial)
DestroyItem(item);
endif
endif
PlaySoundEffect(trashcan, 0x226 );
endforeach
endprogram
im not completely sure as to why it doesnt work and im ok with the timer starting over again or not starting. id just rather there be a timer incase someone puts something in there, they have the chance to get it out, so they cant blame the game im makin for losing something. as is, the script that was there before would just delete the item after double clicking on it and give u a penny for it lmao
Why not put a CProp on the trashcan with a ReadGameClock()+29 at insertion time? And have the sleep(30), and next check if the cprop is lower than the current gameclock. If it's lower, then destroy all items, if not, just skip, leaving all items untouched.
ok, so i want the trash barrel to act like a normal one, that just deletes items from the game after player go for a hunt or watever when they are clearing out there pack. but incase they put something valuable into the trash barrel, i would like it to tell the player that it will be deleted in 30 seconds so that they have a bit of time to make sure what they put in isnt something valuable.
i think this will also stop people from harrassing or blaming me if they destroy a large price item accidently, because then you have the chance of being able to take the item out of the trash barrel before it deletes it. so will need a can remove and onremove script to support this, im currently using the WOD container chest ones.
program onInsert_trash (who, container, movetype, inserttype, item)
if (!item) // don't know if this check is really required
syslog("wtf was that!?");
return;
endif
DoWaitMessage(who, container, "This item will be deleted in 30 seconds.");
var script := start_script( "DestroyThisItem", array{item, container} );
if( script.errortext )
SysLog( "Error starting script <DestroyThisItem> -->"+script.errortext );
endif
endprogram
function DoWaitMessage(who, what, msg)
if (who.concealed or what.container)
if (msg)
PrintTextAbovePrivate(what, msg, who);
endif
else
if (msg)
PrintTextAbove(what, msg);
endif
endif
endfunction
use uo;
program DestroyItem(item, trashcan)
Sleep(30);
if (!item or !trashcan)
return;
endif
if (item.container.serial == trashcan.serial)
PlaySoundEffect(trashcan, 0x226 );
DestroyItem(item);
endif
endprogram
If you don't want people to blame or harass you if they lose an item, then don't be apologetic about it. If they put it in the trash can and lost it, it's their fault, you have to make that clear and stand firm. Also, in most shards, harassing a staff member is a bannable offense.
Agata wrote:If you don't want people to blame or harass you if they lose an item, then don't be apologetic about it. If they put it in the trash can and lost it, it's their fault, you have to make that clear and stand firm. Also, in most shards, harassing a staff member is a bannable offense.
uhh ok so ive done one thing to the destroythisitem.src, i had to rename the program from DestroyItem because its a function pol wont accept it. ive tested it out and oninsert_trash works perfectly, but once it goes through to DestroyThisItem.src, it fails and i cant figure out why or where in the script
program DestroyThisItem(item, trashcan)
Sleep(30);
if (!item or !trashcan)
return;
endif
if (item.container.serial == trashcan.serial)
PlaySoundEffect(trashcan, 0x226 );
DestroyItem(item);
endif
endprogram
it doesnt play the sound effect so it must be getting caught up in the first if statement thinking theres no item or trashcan? :s