diff options
author | Joseph Botosh <rumly111@gmail.com> | 2015-09-05 16:49:02 +0300 |
---|---|---|
committer | Joseph Botosh <rumly111@gmail.com> | 2015-09-05 16:52:17 +0300 |
commit | e92064437d78f4e292c5a048aabcd793c742df39 (patch) | |
tree | 1a9627ecf727a09233db21ddfae0e9382609db13 /npc | |
parent | f107b57002b84070a404b95b14a0bd2cc439598f (diff) | |
download | serverdata-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.txt | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 273353714..9ca373cb0 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); +} |