summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDastgir <dastgirpojee@rocketmail.com>2015-06-04 18:53:37 +0530
committerDastgir <dastgirpojee@rocketmail.com>2015-06-04 18:53:37 +0530
commit45b443ae81a813b04dcb497ccd6ee963ce048048 (patch)
tree84eeb253b3d6fdfd90e869b71c470b346f92a2b6
parent5d83253484c92116580fd400eb77b8fe65f1b1f3 (diff)
downloadhercules-45b443ae81a813b04dcb497ccd6ee963ce048048.tar.gz
hercules-45b443ae81a813b04dcb497ccd6ee963ce048048.tar.bz2
hercules-45b443ae81a813b04dcb497ccd6ee963ce048048.tar.xz
hercules-45b443ae81a813b04dcb497ccd6ee963ce048048.zip
Implemented strcmp Function.
-rw-r--r--doc/script_commands.txt21
-rw-r--r--src/map/script.c9
2 files changed, 29 insertions, 1 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index 779589281..342934533 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -7809,7 +7809,7 @@ mes axtoi("11"); // Displays 17 (1 = 1, 10 = 16)
---------------------------------------
-*compare(<string>,<substring>)
+*compare("<string>","<substring>")
This command returns 1 or 0 when the substring is in the main string (1)
or not (0). This command is not case sensitive.
@@ -7822,7 +7822,26 @@ Examples:
//dothat; will not be executed ('Blood butterfly' does not contain 'Bloody').
if (compare("Blood Butterfly","Bloody"))
dothat;
+
+---------------------------------------
+
+*strcmp("<string>","<string>")
+
+This command compares two strings and is similar to strcmp in C.
+Return Values:
+ >0 : String 1 > String 2
+ 0 : Strings are equal
+ <0 : String 1 < String 2
+
+Examples:
+ .@a = strcmp("abcdef","ABCDEF");
+ if (.@a > 0){
+ mes ".@a is greater than 0."; //Output is this.
+ }else{
+ mes ".@a is less or equal to 0";
+ }
+
---------------------------------------
*getstrlen("<string>")
diff --git a/src/map/script.c b/src/map/script.c
index 19bc5262e..724b3b135 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -15490,6 +15490,14 @@ BUILDIN(compare)
return true;
}
+BUILDIN(strcmp)
+{
+ const char *str1 = script_getstr(st,2);
+ const char *str2 = script_getstr(st,3);
+ script_pushint(st,strcmp(str1, str2));
+ return true;
+}
+
// List of mathematics commands --->
BUILDIN(log10)
@@ -20076,6 +20084,7 @@ void script_parse_builtin(void) {
BUILDIN_DEF(countstr,"ss?"),
BUILDIN_DEF(setnpcdisplay,"sv??"),
BUILDIN_DEF(compare,"ss"), // Lordalfa - To bring strstr to scripting Engine.
+ BUILDIN_DEF(strcmp,"ss"),
BUILDIN_DEF(getiteminfo,"ii"), //[Lupus] returns Items Buy / sell Price, etc info
BUILDIN_DEF(setiteminfo,"iii"), //[Lupus] set Items Buy / sell Price, etc info
BUILDIN_DEF(getequipcardid,"ii"), //[Lupus] returns CARD ID or other info from CARD slot N of equipped item