For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!
Moderator: MacroQuest Developers
-
topgun
- a lesser mummy

- Posts: 43
- Joined: Thu Jan 09, 2003 8:27 am
Post
by topgun » Thu May 27, 2004 2:34 am
Any macro experts who have a few minutes to fix this one please ???
Code: Select all
| guilds.mac - lists guilds in zone by blueninja
#turbo
Sub Main
/declare curid local
/declare previd local
/declare guilds array2
/declare guildcount global
/varset curid 0
/varset guildcount 0
:spawnloop
/varset previd @curid
/varset curid $searchspawn(pc,id:@curid,next)
/if n @curid==@previd /goto :breakout
/if n @curid==0 /goto :breakout
/call AddGuild "$spawn(@curid,guild)"
/goto :spawnloop
:breakout
|searchspawn won't find you so do that manually
/call AddGuild "$spawn($char(id),guild)"
/call ShowGuilds
/echo Total of $calc(@guildcount-1)
/return
Sub ShowGuilds
/declare counter local
/for counter 0 to $calc(@guildcount-1)
/echo @guilds(@counter,0) ($int(@guilds(@counter,1)))
/next counter
/return
Sub AddGuild(guildname)
/if "@guildname"==NULL /return
/declare counter local
/for counter 0 to @guildcount
:searchloop
/if "@guilds(@counter,0)"=="@guildname" {
/varadd guilds(@counter,1) 1
/return
}
/next counter
/varset guilds(@guildcount,0) "@guildname"
/varset guilds(@guildcount,1) 1
/varadd guildcount 1
/return
-
Chill
- Contributing Member

- Posts: 435
- Joined: Fri May 07, 2004 5:06 pm
- Location: Erie, PA
Post
by Chill » Thu May 27, 2004 5:35 am
Not tested yet -- will try to debug it this afternoon if I can -- but I took a stab at it. Think it would look something like:
Code: Select all
| guilds.mac - lists guilds in your zone
#turbo
Sub Main
/declare curid int local 0
/declare previd int local
/declare guildcount int outer 0
/declare guilds array[100,100] string outer
/declare c int outer 0
:firstspawn
/for c 0 to 9999
/target pc id ${c}
/if (${target.ID}==${c}) {
/varset curid ${c}
/call AddGuild ${Spawn[${curid}].Guild}
/goto :spawnloop
}
/next c
:spawnloop
/varset previd ${curid}
/varset curid ${NearestSpawn.[pc ${previd}].Next.ID}
/if (${curid}==${previd}) /goto :breakout
/if (${curid}==0) /goto :breakout
/call AddGuild ${Spawn[${curid}].Guild}
/goto :spawnloop
:breakout
|searchspawn won't find you so do that manually
/call AddGuild ${Me.Guild}
/call ShowGuilds
/echo Total of ${Math.Calc[${guildcount}-1]} guilds
/return
Sub ShowGuilds
/for c 0 to ${Math.Calc[${guildcount}-1)]}
/echo ${guilds[${c},0]} (${guilds[${c},1]})
/next c
/return
Sub AddGuild(guildname)
/if (${guildname.Equal[NULL]}) /return
/for c 0 to ${guildcount}
:searchloop
/if (${guilds[${counter},0].Equal[${guildname}]}) {
/varcalc guilds[${counter},1] ${guilds[${counter},1]}+1
/return
}
/next c
/varset guilds[${guildcount},0] ${guildname}
/varset guilds[${guildcount},1] 1
/varcalc guildcount ${guildcount}+1
/return
-
topgun
- a lesser mummy

- Posts: 43
- Joined: Thu Jan 09, 2003 8:27 am
Post
by topgun » Thu May 27, 2004 6:32 am
Damm that was some fast help :) Tnx a bunch