GrantPrivilege

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.

Moderator: POL Developer

Post Reply
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

GrantPrivilege

Post 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
User avatar
CWO
POL Expert
Posts: 1159
Joined: Sat Feb 04, 2006 5:49 pm
Location: Chicago, IL USA

Re: GrantPrivilege

Post 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.
User avatar
Damien White
Journeyman Poster
Posts: 68
Joined: Tue Aug 18, 2009 6:34 pm
Location: Canada

Re: GrantPrivilege

Post by Damien White »

This looks like it could be a potential invulnerability potion?
Pierce
Forum Regular
Posts: 420
Joined: Thu Feb 02, 2006 8:33 am

Re: GrantPrivilege

Post 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" );
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: GrantPrivilege

Post by Tharon »

Thank You :) :)
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: GrantPrivilege

Post 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
Turley
POL Developer
Posts: 670
Joined: Sun Feb 05, 2006 4:45 am

Re: GrantPrivilege

Post 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)
Tharon
Novice Poster
Posts: 44
Joined: Fri May 15, 2009 2:27 am

Re: GrantPrivilege

Post by Tharon »

Thank you :) :)
Terciob
Master Poster
Posts: 90
Joined: Fri Nov 07, 2008 3:47 am

Re: GrantPrivilege

Post 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.
Post Reply