Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Fri Aug 27, 2010 10:34 pm   

%mapquery trouble
 
hi

I got a room: Assassins' Meeting Chamber

This dosent work:
Code:
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name=''Assassins' Meeting Chamber'"))


but this does:
Code:
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name='Assassins'' Meeting Chamber'"))


so I put the roomname in a variables and use replace to get 2 ':
Code:
roomname = "Assassins' Meeting Chamber"
newroomname = %replace(@roomname,"'","''")

but when I then use it with the variable it wont work:
Code:
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name='@newroomname'"))


I have try to play around with it but with out any luck:
Code:
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name=',@newroomname,'"))
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name='"@newroomname"'"))
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name="'@newroomname'""))
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name="",@newroomname,"""))


I know I am close but my head is starting to hurt so please help :)
Reply with quote
dbosst
Apprentice


Joined: 15 Jun 2010
Posts: 121

PostPosted: Fri Aug 27, 2010 11:56 pm   
 
I understand your frustration ... try this, it works:

Code:

#SHOW %mapquery(%concat("Zoneid='",%zonenum,"' AND Name='",@newroomname,"'"))


Also remember that %zonenum returns the zone number of the room marked with the blue dot as the current room, not necessarily the zone you are currently viewing with the mapper if you selected to view a different area from the mapper GUI dropdown
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sat Aug 28, 2010 12:11 am   
 
The reason this:
Code:
#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name='@newroomname'"))

doesn't work is because @variables are not expanded within " quotes. And your @newroomname reference is within " quotes in all of your examples. So this is not a bug. dbosst has given the correct answer for doing this.
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Sat Aug 28, 2010 7:26 am   
 
Quote:
Code:
#SHOW %mapquery(%concat("Zoneid='",%zonenum,"' AND Name='",@newroomname,"'"))


nope sorry that does not work
Reply with quote
charneus
Wizard


Joined: 19 Jun 2005
Posts: 1876
Location: California

PostPosted: Sat Aug 28, 2010 8:04 am   
 
Try:

Code:
%mapquery(Zoneid='%zonenum' AND Name='%replace(@roomname,"'","''")')


The script I use does:

Code:
%mapquery( [Name] Like '%replace( %param( ), "'", "''")%' AND [ZoneID] Like '%roomzone()')


Hopefully it helps you.

Charneus
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Sat Aug 28, 2010 11:57 am   
 
no still not working, think I leave it for awhile until I can understand it better

but thanks for the help
Reply with quote
dbosst
Apprentice


Joined: 15 Jun 2010
Posts: 121

PostPosted: Sat Aug 28, 2010 12:53 pm   
 
dbosst wrote:
I understand your frustration ... try this, it works:

Code:

#SHOW %mapquery(%concat("Zoneid='",%zonenum,"' AND Name='",@newroomname,"'"))


Also remember that %zonenum returns the zone number of the room marked with the blue dot as the current room, not necessarily the zone you are currently viewing with the mapper if you selected to view a different area from the mapper GUI dropdown


I've tested this myself.. it is also nearly identical to most of my own mapper utility scripts... make sure the room name is in the zone you are currently in...
Reply with quote
Quit
Wanderer


Joined: 19 Jul 2008
Posts: 59

PostPosted: Sat Aug 28, 2010 1:39 pm   
 
I play on Aardwolf

I am in Underdark looking for The guildmaster a cp mob

Hunt guildmaster - You seem unable to hunt that target for some reason.

where guildmaster - The guildmaster Assassins' Meeting Chamber

#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name='Assassins'' Meeting Chamber'")) - 5768|5769|5770|5771 - the room number is correct

but to get it to work with a variable.....
Reply with quote
Anaristos
Sorcerer


Joined: 17 Jul 2007
Posts: 821
Location: California

PostPosted: Sat Aug 28, 2010 1:47 pm   
 
Why are you putting the zone number in single quotes?
I mean, it will work, but it will also cause the SQL engine to go through a type conversion. The field ZoneID is typed as integer so that's what you want to pass.
Code:

#SHOW %mapquery(%concat("Zoneid=",%zonenum," AND Name= '",%replace(@newroomname,"'","''"),"'"))

Personally, I prefer CMUD's syntax:
Code:

#SHOW %mapquery("Zoneid= " + %zonenum() + " AND Name = '" + %replace(@newroomname,"'","''") + "'")
_________________
Sic itur ad astra.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net