Page 1 of 1

GrantPrivilege

Posted: Mon Oct 12, 2009 3:56 am
by Tharon
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

Re: GrantPrivilege

Posted: Mon Oct 12, 2009 4:47 am
by CWO
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.

Re: GrantPrivilege

Posted: Mon Oct 12, 2009 4:56 am
by Damien White
This looks like it could be a potential invulnerability potion?

Re: GrantPrivilege

Posted: Mon Oct 12, 2009 5:09 am
by Pierce

Code: Select all

for (i := 1; i <= 180; i := i+1)
if (i == 180)
RevokePrivilege(who, "invul" );
who.disable("invul");
endif
endfor
The problem is there is no sleep in that loop, so the counting is so fast that you didn't get the priviledge :D

Code: Select all

for (i := 1; i <= 180; i := i+1)
sleep(1);
if (i == 180)
RevokePrivilege(who, "invul" );
who.disable("invul");
endif
endfor
or even better without the for/endfor loop:

Code: Select all

sleep(180);
who.disable("invul");
RevokePrivilege(who, "invul" );

Re: GrantPrivilege

Posted: Mon Oct 12, 2009 7:14 am
by Tharon
Thank You :) :)

Re: GrantPrivilege

Posted: Fri Oct 16, 2009 12:39 pm
by Tharon
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

Posted: Fri Oct 16, 2009 2:55 pm
by Turley
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)

Re: GrantPrivilege

Posted: Sat Oct 17, 2009 1:47 am
by Tharon
Thank you :) :)

Re: GrantPrivilege

Posted: Sat Oct 17, 2009 11:02 am
by Terciob
Also try to give a little basic security lines:

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

Also add revokepriv in logon.src for players, this prevents cheats with saveworld and a shutdown or crash.