31
mIRC/pawn Scripting / Re: Location Script
« on: November 25, 2007, 03:03:51 am »
here is my adaptation of falcons above code(only slightly different):
convert your vcmp.data.ini locations to a hash table and save it
create then load the hash table on script start
to find an xy coordinate's location name:
basically the same, except it gets rid of the "Set max locations" step and saves the max_loc value directly into the hash table at the time of conversion so it can be referenced from there.
convert your vcmp.data.ini locations to a hash table and save it
Code: [Select]
alias convert {
!hmake -s areatemp 500
var %b = 1, %c
while (%b <= $ini(vcmp.data.ini,AREA2,0)) {
%c = $ini(vcmp.data.ini,AREA2,%b)
!hadd areatemp %b %c
!hadd areatemp %b $+ . $readini(vcmp.data.ini,AREA2,%c)
!inc %b
}
!hadd areatemp max_loc %b
!hsave areatemp vcmp.area.hash
!hfree -s areatemp
}
create then load the hash table on script start
Code: [Select]
!hmake -s area 1000
if ($exists(vcmp.area.hash)) { !hload area vcmp.area.hash }
to find an xy coordinate's location name:
Code: [Select]
alias vcmp.area {
if (($1) && ($2)) {
var %a = 1
while (%a < $hget(area,max_loc)) {
if ($inpoly($1,$2, [ $hget(area,%a) ] )) !return $hget(area,%a $+ .)
!inc %a
}
}
!return Vice City
}
basically the same, except it gets rid of the "Set max locations" step and saves the max_loc value directly into the hash table at the time of conversion so it can be referenced from there.