|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Thu Feb 16, 2017 11:38 am
Looking for a specific Room Name |
I found this sweet script in the forums here, awesome!
It searches for rooms containing the name, or part of the name provided.
Can i make a version wich will match the exact room name? (using "=" instead of "LIKE")
I tried to modify it but i dont know SQ can some one help please?
here is the code:
Code: |
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<alias name="MapFind" copy="yes">
<value><![CDATA[#if (%-1 != %null) {
$room = %lower(%-1)
$str = %concat("[Name] LIKE '%", $room, "%'")
$locations = %mapquery($str)
#call %roommode(1)
#print ""
#mxp {<color brown><hr></color>}
$msg = "<strong><color khaki>VNum" + %repeat(" ",4) + "Destinations" + %repeat(" ",31) + "Zones</color></strong>"
#print $msg
#mxp {<color brown><hr></color>}
#forall $locations {
$roomNum = %roomnum(%i)
$roomName = %roomname(%i)
$roomZone = %zonename(%roomzone(%i))
$msg = "<color white>[<color gold>" +
%repeat(" ", 5-(%len($roomNum))) +
$roomNum + "</color>]</color><color silver> " +
$roomName%repeat(" ", 40-(%len($roomName))) +
"</color><color lime> " + $roomZone + "</color>"
#print $msg
}
#mxp {<color brown><hr></color>}
#call %roommode(0)
} {
#print "<color red>NO ROOM NAME PROVIDED. ENTER THE ROOM NAME OR PART OF THE NAME.</color>"
}]]></value>
<notes>Enter MAPFIND "room name or part of room name"</notes>
</alias>
</cmud>
|
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Thu Feb 16, 2017 2:00 pm |
Try:
$str = %concat("[Name] = ", $room) |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Thu Feb 16, 2017 2:33 pm |
shalimar wrote: |
Try:
$str = %concat("[Name] = ", $room)
|
didnt work |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Thu Feb 16, 2017 6:31 pm |
SQL likes to have its quotes too.
$str = %concat("[Name] = '", %replace($room, "'", "''"), "'") |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Sat Feb 18, 2017 11:21 am |
Vijilante wrote: |
SQL likes to have its quotes too.
$str = %concat("[Name] = '", %replace($room, "'", "''"), "'")
|
When i read Vijilante answered, i thought ok, its done! i know about u from forums, u r amazing!
this time didnt work tho!
it dosent store any data, i get blank "VNum, Name, ZONE" fields, i guess i need to adjust something after the FORALL
thank u tho u r always nice! |
|
Last edited by Latino on Sat Feb 18, 2017 11:23 am; edited 1 time in total |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Sat Feb 18, 2017 11:22 am |
ERROR
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Feb 18, 2017 1:08 pm |
Or it could be a case sensitive issue?
Try changing:
$room = %lower(%-1)
to
$room = %-1 |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Sat Feb 18, 2017 2:18 pm |
shalimar wrote: |
Or it could be a case sensitive issue?
Try changing:
$room = %lower(%-1)
to
$room = %-1
|
YEAH! thats it! now its perfect for what i need! thank u so much! id love to have ur knowledge
|
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Sat Feb 18, 2017 2:27 pm |
shalimar wrote: |
Or it could be a case sensitive issue?
Try changing:
$room = %lower(%-1)
to
$room = %-1
|
I spoke too early! xD
It worked on the first try, after that was doing again the same type of search :( |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sun Feb 19, 2017 2:08 am |
Are you making sure to use the proper case for the roomname as stored in your map database when you call the alias?
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Tue Feb 21, 2017 9:56 am |
shalimar wrote: |
Are you making sure to use the proper case for the roomname as stored in your map database when you call the alias? |
200% sure!
i dont really get this, pls help! |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Thu Feb 23, 2017 1:22 pm |
I'm really not sure what to say...
If it worked once and then stopped, it sounds like an issue specific to you.
Did you accidently leave it open and type something in that might have broken the script? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Fri Feb 24, 2017 11:37 am |
i thought about that, so i made a fresh new session and loaded the script, which worked as on my main session.
when i tried to execute it from an 3th new session applying ur suggestions, it didnt even fire "correctly" the first time, got just a blank field as on my main session |
|
|
|
chosig Novice
Joined: 20 Apr 2008 Posts: 39 Location: Sweden
|
Posted: Fri Feb 24, 2017 3:07 pm |
It's a SQLITE database, if you want case insensitive searches you do something like this:
Code: |
$str = %concat("[Name] LIKE '", $room, "' COLLATE NOCASE") |
Oh, and also that's exact search with no wildcard in the start/end. |
|
|
|
Latino Beginner
Joined: 16 Feb 2017 Posts: 12
|
Posted: Fri Feb 24, 2017 7:12 pm |
chosig wrote: |
It's a SQLITE database, if you want case insensitive searches you do something like this:
Code: |
$str = %concat("[Name] LIKE '", $room, "' COLLATE NOCASE") |
Oh, and also that's exact search with no wildcard in the start/end. |
Brilliant! 100% right! thanks god u passed by!
thank you |
|
|
|
chosig Novice
Joined: 20 Apr 2008 Posts: 39 Location: Sweden
|
Posted: Sun Feb 26, 2017 3:57 pm |
Finally something I could answer, I blow at cMUD scripting, but SQL is my game...
|
|
|
|
|
|