Page 1 of 1
.antilootingareas
Posted: Thu Dec 28, 2006 5:35 am
by lokaum
hi people,
i did .antilootingareas in my server and keep anti-loot areas.. later i saved and did a restart in server, but the chars can loot yet in these locations...
im using UL pol095...
thanks
Posted: Thu Dec 28, 2006 6:09 am
by tekproxy
I've never heard of that command. Could you post the code for it?
Could the characters loot BEFORE you restarted the server?
Posted: Thu Dec 28, 2006 6:18 am
by lokaum
yes...
pkg\opt\loot\antiloot.src
Code: Select all
use uo;
use os;
include "include/areas";
include "include/constants/propids";
program antilooting( who, corpse, item )
var serial := GetObjProperty( corpse, PROPID_CORPSE_CORPSE_OF );
if( !serial )
return 1;
elseif( who.cmdlevel )
return 1;
elseif( serial = who.serial )
return 1;
elseif( GetObjProperty( corpse, PROPID_MOBILE_CANT_BE_LOOTED ) )
return 0;
elseif( GetObjProperty( corpse, PROPID_MOBILE_GUARD_KILLED ) )
return AddLooter( who, corpse );
elseif( IsInAntiLootingArea(who) )
SendSysMessage( who, "You can't loot here." );
return 0;
else
var guild1 := GetObjProperty( who, "guild_id" );
if( guild1 )
var guild2 := GetObjProperty( who, "guild_id" );
if( guild2 )
if( guild1 = guild2 )
return AddLooter( who, corpse );
else
guild1 := FindGuild( guild1 );
guild2 := FindGuild( guild2 );
if( guild1.IsEnemyGuild(guild2) )
return AddLooter( who, corpse );
elseif( guild1.IsAllyGuild(guild2) )
return AddLooter( who, corpse );
endif
endif
endif
endif
if( IsInAntiLootingArea(who) )
SendSysMessage( who, "You can't loot here." );
return 0;
elseif( GetObjProperty( corpse, PROPID_CORPSE_IS_BLUE ) )
who.setCriminal(1);
return AddLooter( who, corpse );
endif
endif
return 1;
endprogram
function AddLooter( looter, object )
var looters := GetObjProperty(object, PROPID_CORPSE_LOOTED_BY);
if( !looters )
looters := dictionary;
endif
if( !looters.exists(looter.serial) )
looters[looter.serial] := looter.name;
return SetObjProperty(object, PROPID_CORPSE_LOOTED_BY, looters);
else
return 1;
endif
endfunction
want that i post the antilootingarea.src too?
thanks
Posted: Thu Dec 28, 2006 6:43 am
by tekproxy
Add "debug prints" in all those IF, ELSEIF portions. Here's an example:
Code: Select all
var serial := GetObjProperty( corpse, PROPID_CORPSE_CORPSE_OF );
Print("antiloot - serial:"+serial+" cmdlevel:"+who.cmdlevel+" who.serial:"+who.serial);
if( !serial )
return 1;
elseif( who.cmdlevel )
return 1;
elseif( serial = who.serial )
return 1;
elseif( GetObjProperty( corpse, PROPID_MOBILE_CANT_BE_LOOTED ) )
Print("antiloot - Found can't be looted prop, no looting!");
return 0;
elseif( GetObjProperty( corpse, PROPID_MOBILE_GUARD_KILLED ) )
Print("antiloot - Found killed by guard prop, AddLooter()!");
return AddLooter( who, corpse );
elseif( IsInAntiLootingArea(who) )
Print("antiloot - IsInAntiLootingArea()! No looting!");
SendSysMessage( who, "You can't loot here." );
return 0;
else
Print("antiloot - checking guild stuff...");
var guild1 := GetObjProperty( who, "guild_id" );
I'd also need to see the code for the function IsInAntiLootingArea(who) and how PROPID_MOBILE_CANT_BE_LOOTED is defined. You could probably figure it out on your own with the above debug messages.
Posted: Thu Dec 28, 2006 1:02 pm
by lokaum
antilootingareas.src
Code: Select all
use uo;
use os;
use cfgfile;
include "include/areas";
program antimagicareas( who )
var cfg := ReadConfigFile(":areas:areas");
var areas := GetConfigStringArray( cfg[1], "Area" );
var disabled := GetGlobalProperty("AntiLootAreas");
if( !disabled )
disabled := array;
endif
var layout := array( "page 0",
"nodispose",
"resizepic 50 0 2600 250 325",
"resizepic 100 280 5100 150 25",
"text 110 30 5 0" );
var data := array( "Anti-Looting Areas" );
var name;
var splited;
var count := 0;
var done := 0;
var page := 1;
var perpage := 10;
var y := 70;
var i;
var j;
layout.append( "page " + page );
if( areas.size() > perpage )
layout.append( "button 200 281 5540 5542 0 " + (page + 1) );
endif
for( i := 1; i <= areas.size(); i := i + 1 )
if( done = perpage )
done := 0;
page := page + 1;
y := 70;
layout.append( "page " + page );
layout.append( "button 125 281 5537 5538 0 " + (page - 1) );
if( areas.size() > (count + perpage) )
layout.append( "button 200 281 5540 5542 0 " + (page + 1) );
endif
endif
if( disabled[i] )
layout.append( "checkbox 250 " + y + " 210 211 1 " + i );
else
layout.append( "checkbox 250 " + y + " 210 211 0 " + i );
endif
splited := SplitWords( areas[i] );
name := splited[5];
j := 6;
while( splited[j] )
name := name + " " + splited[j];
j := j + 1;
endwhile
layout.append( "text 85 " + y + " 0 " + data.size() );
data.append( name );
y := y + 20;
done := done + 1;
count := count + 1;
Sleepms(1);
endfor
var save;
var result := SendDialogGump( who, layout, data );
for( i := 1; i <= areas.size(); i := i + 1 )
disabled[i] := result[i];
endfor
for( i := 1; i <= areas.size(); i := i + 1 )
if( result[i] )
disabled[i] := 1;
save := 1;
else
disabled[i] := 0;
endif
endfor
if( save )
if( SetGlobalProperty( "AntiLootAreas", disabled ) )
SendSysMessage( who, "Data saved" );
return 1;
endif
else
if( EraseGlobalProperty( "AntiLootAreas" ) )
SendSysMessage( who, "Data saved" );
return 1;
endif
endif
SendSysMessage( who, "Error occured" );
return 0;
endprogram
hmm
Posted: Thu Dec 28, 2006 1:13 pm
by lokaum
later try to loot any corpse...
this message show in console
Code: Select all
antiloot - serial: 30488 cmdlevel: 0 who.serial: 32623);
antiloot - Found killed by guard prop, AddLooter()!
what is the problem now?
Posted: Thu Dec 28, 2006 1:34 pm
by tekproxy
The mobile in question was killed by a guard and according to the code, you can loot if it has been killed by a guard, unless SetObjProperty has a problem and doesn't return 1 (not likely).
To change this, instead of returning AddLooter(), you could just return 0.
Code: Select all
elseif( GetObjProperty( corpse, PROPID_MOBILE_GUARD_KILLED ) )
return 0; // do not allow looting
Posted: Thu Dec 28, 2006 3:05 pm
by lokaum
thanks for all people!!

cya!!