summaryrefslogtreecommitdiff
path: root/npc
diff options
context:
space:
mode:
authorJoseph Botosh <rumly111@gmail.com>2015-09-05 16:49:02 +0300
committerJoseph Botosh <rumly111@gmail.com>2015-09-05 16:52:17 +0300
commite92064437d78f4e292c5a048aabcd793c742df39 (patch)
tree1a9627ecf727a09233db21ddfae0e9382609db13 /npc
parentf107b57002b84070a404b95b14a0bd2cc439598f (diff)
downloadserverdata-e92064437d78f4e292c5a048aabcd793c742df39.tar.gz
serverdata-e92064437d78f4e292c5a048aabcd793c742df39.tar.bz2
serverdata-e92064437d78f4e292c5a048aabcd793c742df39.tar.xz
serverdata-e92064437d78f4e292c5a048aabcd793c742df39.zip
add function strip() to script functions
Diffstat (limited to 'npc')
-rw-r--r--npc/functions/main.txt25
1 files changed, 25 insertions, 0 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt
index 27335371..9ca373cb 100644
--- a/npc/functions/main.txt
+++ b/npc/functions/main.txt
@@ -1,6 +1,7 @@
// Evol functions.
// Authors:
// 4144
+// Travolta
// Description:
// Build in functions.
@@ -50,3 +51,27 @@ function script addremovemapmask {
setmapmask getarg(0), (getmapmask(getarg(0)) | (getarg(1) + getarg(2))) ^ getarg(2);
return;
}
+
+// remove spaces at the start and end of string and return result
+function script strip {
+ .@s$ = getarg(0);
+ if (.@s$ == "")
+ return "";
+ .@start = 0;
+ .@end = getstrlen(.@s$) - 1;
+ for (.@i = .@start; .@i < .@end; .@i++)
+ {
+ if (charat(.@s$, .@i) != " ")
+ break;
+ else
+ .@start++;
+ }
+ for (.@i = .@end; .@i >= .@start; .@i--)
+ {
+ if (charat(.@s$, .@i) != " ")
+ break;
+ else
+ .@end--;
+ }
+ return substr(.@s$, .@start, .@end);
+}