diff options
author | Jesusaves <cpntb1@ymail.com> | 2020-05-14 21:47:55 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2020-08-05 03:25:39 -0300 |
commit | c0a9acb3c9bf2d3b56acd5c2162bd02beb4147d8 (patch) | |
tree | fad384616a4c4ad401b932f4556f7b384c4e21b5 | |
parent | 2e2b10d60a0b9c3f4041cad898674854df3ca082 (diff) | |
download | serverdata-c0a9acb3c9bf2d3b56acd5c2162bd02beb4147d8.tar.gz serverdata-c0a9acb3c9bf2d3b56acd5c2162bd02beb4147d8.tar.bz2 serverdata-c0a9acb3c9bf2d3b56acd5c2162bd02beb4147d8.tar.xz serverdata-c0a9acb3c9bf2d3b56acd5c2162bd02beb4147d8.zip |
Initial version of getv/setv
-rw-r--r-- | npc/functions/main.txt | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/npc/functions/main.txt b/npc/functions/main.txt index 1ae37a35..02374e14 100644 --- a/npc/functions/main.txt +++ b/npc/functions/main.txt @@ -224,6 +224,58 @@ function script npctalkonce { return true; } +// getv(variable{, Vault ID}) -> Returns a Vault Variable +function script getv { + .@v$=getarg(0); + .@id=getarg(1, ##VAULT[0]); + // Hard Fail + if (.@id <= 0) { + announce "ERROR: getv."+.@v$+" failed - Sysadmin help required.", bc_all|bc_npc; + channelmes("#irc", "CRITICAL ERROR: Invalid Account (getv."+.@v$+")"); + if (playerattached()) { + dispbottom "A critical error happened in getv."+.@v$+" function. This error is fatal, we halt execution."; + consolemes(CONSOLEMES_ERROR, "Account %d has no vault index. This error is fatal, script execution halted.", getcharid(3)); + } else { + consolemes(CONSOLEMES_ERROR, "Vault function called from script without a valid vault account ID. This error is fatal, script execution was halted."); + } + end; + } + // Yes, 90% of the function is hard-failing. + // I miss Exception() function >__> + return getd("$VAULT_"+.@v$+"["+.@id+"]"); +} + +// setv(variable, value{, Vault ID}) -> Sets a Vault Variable +function script setv { + .@v$=getarg(0); + if (charat(.@v$, getstrlen(.@v$)-1) == "$") { + .@val$=getarg(1); + .@str=true; + } else { + .@val=getarg(1); + .@str=false; + } + .@id=getarg(2, ##VAULT[0]); + // Hard Fail + if (.@id <= 0) { + announce "ERROR: getv."+.@v$+" failed - Sysadmin help required.", bc_all|bc_npc; + channelmes("#irc", "CRITICAL ERROR: Invalid Account (getv."+.@v$+")"); + if (playerattached()) { + dispbottom "A critical error happened in getv."+.@v$+" function. This error is fatal, we halt execution."; + consolemes(CONSOLEMES_ERROR, "Account %d has no vault index. This error is fatal, script execution halted.", getcharid(3)); + } else { + consolemes(CONSOLEMES_ERROR, "Vault function called from script without a valid vault account ID. This error is fatal, script execution was halted."); + } + end; + } + // Yes, 90% of the function is hard-failing. + // I miss Exception() function >__> + if (.@str) + return setd("$VAULT_"+.@v$+"["+.@id+"]", .@val$); + else + return setd("$VAULT_"+.@v$+"["+.@id+"]", .@val); +} + function script getquestlink { return "[@@q" + getarg(0) + "|@@]"; } |