Hallo, can you help me with this small script, it doesn't work and i do not know where the mistake is.
use uo;
program RollederUnverwundbarkeit(who, item)
GrantPrivilege(who, "invul" );
who.enable("invul");
var i;
for (i := 1; i <= 180; i := i+1)
if (i == 180)
RevokePrivilege(who, "invul" );
who.disable("invul");
endif
endfor
DestroyItem(Item);
endprogram
GrantPrivilege
Re: GrantPrivilege
What are you trying to accomplish here? What exactly is the problem you're having? From what I see in the script, it makes "who" invulnerable for a very small fraction of a second (don't know what the for loop is supposed to be for) then destroys the item.
- Damien White
- Journeyman Poster
- Posts: 68
- Joined: Tue Aug 18, 2009 6:34 pm
Re: GrantPrivilege
This looks like it could be a potential invulnerability potion?
Re: GrantPrivilege
Code: Select all
for (i := 1; i <= 180; i := i+1)
if (i == 180)
RevokePrivilege(who, "invul" );
who.disable("invul");
endif
endfor

Code: Select all
for (i := 1; i <= 180; i := i+1)
sleep(1);
if (i == 180)
RevokePrivilege(who, "invul" );
who.disable("invul");
endif
endfor
Code: Select all
sleep(180);
who.disable("invul");
RevokePrivilege(who, "invul" );
Re: GrantPrivilege
I need help for this script again. It works god, but i can not do other action. For example I can not open a door or drink another potion. If I log out and log in again I am invul whole the time.
Code: Select all
use uo;
use os;
program RollederUnverwundbarkeit(who, item)
GrantPrivilege(who, "invul" );
who.enable("invul");
DestroyItem(Item);
sleep(180);
RevokePrivilege(who, "invul" );
who.disable("invul");
SendSysMessage( who, "Ihr seid wieder verwundbar!", font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEXT_COLOR );
endprogram
Re: GrantPrivilege
Detach() is the key 
It seems that this is a usescript, usescripts are attached to the char. You cannot use other scripts while this is running and it stops running if char logs out. Call function Detach() right before the sleep(180), then your only problem is server shutdown during the sleep(180). (Could be fixed with cprop and logon or start script)

It seems that this is a usescript, usescripts are attached to the char. You cannot use other scripts while this is running and it stops running if char logs out. Call function Detach() right before the sleep(180), then your only problem is server shutdown during the sleep(180). (Could be fixed with cprop and logon or start script)
Re: GrantPrivilege
Also try to give a little basic security lines:
Also add revokepriv in logon.src for players, this prevents cheats with saveworld and a shutdown or crash.
Code: Select all
use uo;
use os;
program RollederUnverwundbarkeit(who, item)
if (!Accessible(who, item))
return;
endif
if (!ReserveItem(item))
return;
endif
if (!destroyitem (item))
return;
endif
GrantPrivilege(who, "invul" );
who.enable("invul");
detach();
sleep(180);
RevokePrivilege(who, "invul" );
who.disable("invul");
SendSysMessage( who, "Ihr seid wieder verwundbar!", font := _DEFAULT_TEXT_FONT, color := _DEFAULT_TEXT_COLOR );
endprogram