diff --git a/bin/conf/PseuWoW.conf.default b/bin/conf/PseuWoW.conf.default index 2fb4456..36a914c 100644 --- a/bin/conf/PseuWoW.conf.default +++ b/bin/conf/PseuWoW.conf.default @@ -91,4 +91,9 @@ disablespellcheck=0 // to use the default language for your race (defined in race.scp) defaultlang=0 +// special char that is used to trigger server commands (for example ".goname Player") +// (WoWEmu="." MaNGOS="." or "!") +// other servers might be different +cmdchar=. + diff --git a/bin/scripts/_enterworld.def b/bin/scripts/_enterworld.def index 85372a4..90b319d 100644 --- a/bin/scripts/_enterworld.def +++ b/bin/scripts/_enterworld.def @@ -5,13 +5,13 @@ LOG * World entered, executing appropriate script... // MaNGOS: make PseuWoW invincible -// SAY .gmon +// CMD gmon // you can also teleport on every startup to a certain player... // simple: use the .goname command as usual. // SAY .goname Gamemaster // or teleport to a specific loacation... -// .tele gmisland +// CMD tele gmisland // to know everything worked fine, etc SAY [${@version_short}] login successful. diff --git a/bin/scripts/autobroadcast.def b/bin/scripts/autobroadcast.def index fe6b83f..525cba4 100644 --- a/bin/scripts/autobroadcast.def +++ b/bin/scripts/autobroadcast.def @@ -8,8 +8,8 @@ // --- CONFIG --- - // your command you use to broadcast - set,cmd .announce + // your command you use to broadcast (without trailing "." or whatever!) + set,cmd announce // set the broadcast interval (in seconds!) // here we set it to 20 mins @@ -51,7 +51,7 @@ add,x 1 // broadcast the text number x -say ${cmd} ${text${x}} +CMD ${cmd} ${text${x}} // if x = textcount: reset text counter x to 0 (using the modulo operator) mod,x ${textcount} diff --git a/bin/scripts/cmd.def b/bin/scripts/cmd.def new file mode 100644 index 0000000..4e866d9 --- /dev/null +++ b/bin/scripts/cmd.def @@ -0,0 +1,7 @@ +#permission=255 + +// purpose: send a server command. +// args: +// @def: command to send + +SAY ${#CMDCHAR}${@def} \ No newline at end of file diff --git a/bin/scripts/config.def b/bin/scripts/config.def index 61b0fb5..8f5df8c 100644 --- a/bin/scripts/config.def +++ b/bin/scripts/config.def @@ -11,3 +11,6 @@ APPLYPERMISSIONS // remove dangerous variables CLEANUPVARS + +// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style) +DEFAULT,#CMDCHAR . diff --git a/bin/scripts/getchatitem.def b/bin/scripts/getchatitem.def new file mode 100644 index 0000000..7423d75 --- /dev/null +++ b/bin/scripts/getchatitem.def @@ -0,0 +1,18 @@ +#permission=255 + +// expected args: +// @def: item id +// @0 (optional): color (in RGB hex format: 00FF00 = pure green) +// returns: clickable item link + +SET,i ${@def} +SET,color ${@0} +DEFAULT,i 0 +TOINT,i ${i} +DEFAULT,color 6679FF +SET,link |cff${color}|Hitem:${i}:0:0:0|h[Item ${i}]|h|r + +UNSET i +UNSET color + +RETURN ${link} \ No newline at end of file diff --git a/bin/scripts/quit.def b/bin/scripts/quit.def index 7b1e606..4e00346 100644 --- a/bin/scripts/quit.def +++ b/bin/scripts/quit.def @@ -1,3 +1,5 @@ #permission=255 -SAY Terminating proc... +IF ${@inworld} + SAY Terminating proc... +ENDIF SHDN \ No newline at end of file diff --git a/bin/scripts/s.def b/bin/scripts/s.def index 60a33d9..0135e1b 100644 --- a/bin/scripts/s.def +++ b/bin/scripts/s.def @@ -1,2 +1,20 @@ #permission=0 -SAY,{${@0}} ${@def} \ No newline at end of file + +// purpose: easy way for any player to make pseuwow say text. +// if it thinks the player is trying to use a server command it will not say it. +// args are the same as say.def +// only players whose permission is = 255 can use this script to say commands + +// first find out the first char of the message string +SET,c ?{SUBSTR,1 ${@def}} + +// is the char equal to the char we use for commands? does the player have a permission lvl below 255? +IF ?{AND,?{EQUAL,${c} {${#CMDCHAR}}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}} + // yes: say a warning and the command the player wanted to use + SAY ${@thiscmd_name}: no permission to use commands [${@def}] + RETURN false +ELSE + // no: say the text as usual. + SAY,{${@0}} ${@def} + RETURN true +ENDIF \ No newline at end of file diff --git a/bin/scripts/sayitem.def b/bin/scripts/sayitem.def index 77cd0f9..c069bf7 100644 --- a/bin/scripts/sayitem.def +++ b/bin/scripts/sayitem.def @@ -2,4 +2,7 @@ MAKECHATITEM,i ${@def} SAY ${i} -UNSET i \ No newline at end of file +UNSET i + +// we could also use the following: +// SAY ?{GETCHATITEM ${@def}} diff --git a/bin/scripts/uptime.def b/bin/scripts/uptime.def index 308e1ae..5d85bc3 100644 --- a/bin/scripts/uptime.def +++ b/bin/scripts/uptime.def @@ -7,7 +7,9 @@ // returns: uptime formatted as 0h 0m 0s #onload - set,#uptime 0 + if ?{not ?{isset #uptime}} + set,#uptime 0 + endif removeevent event_{${@myname}} addevent,event_{${@myname}},1000 add,#uptime 1 #endonload diff --git a/src/Client/DefScript/DefScript.cpp b/src/Client/DefScript/DefScript.cpp index 869f939..bdbd7bf 100644 --- a/src/Client/DefScript/DefScript.cpp +++ b/src/Client/DefScript/DefScript.cpp @@ -214,16 +214,16 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){ continue; // line was an option, not script content } // help with loading lines where a space or tab have accidently been put after the cmd - if(memcmp(line.c_str(),"else ",5)==0 || memcmp(line.c_str(),"else\t",5)==0) line="else"; - else if(memcmp(line.c_str(),"endif ",6)==0 || memcmp(line.c_str(),"endif\t",5)==0) line="endif"; - else if(memcmp(line.c_str(),"loop ",5)==0 || memcmp(line.c_str(),"loop\t",5)==0) line="loop"; - else if(memcmp(line.c_str(),"endloop ",8)==0 || memcmp(line.c_str(),"endloop\t",8)==0) line="endloop"; - - if(line=="else" || line=="endif" || line=="loop" || line=="endloop") - line=stringToLower(line); + std::string tline=stringToLower(line); + if(memcmp(tline.c_str(),"else ",5)==0 || memcmp(tline.c_str(),"else\t",5)==0) tline="else"; + else if(memcmp(tline.c_str(),"endif ",6)==0 || memcmp(tline.c_str(),"endif\t",5)==0) tline="endif"; + else if(memcmp(tline.c_str(),"loop ",5)==0 || memcmp(tline.c_str(),"loop\t",5)==0) tline="loop"; + else if(memcmp(tline.c_str(),"endloop ",8)==0 || memcmp(tline.c_str(),"endloop\t",8)==0) tline="endloop"; + if(tline=="else" || tline=="endif" || tline=="loop" || tline=="endloop") + line=tline; // check for correct block match - if(memcmp(line.c_str(),"if ",3)==0) + if(memcmp(tline.c_str(),"if ",3)==0) // need to check lowercased line! (IF may be uppercased) Blocks.push_back(BLOCK_IF); else if(line=="else") { @@ -290,7 +290,7 @@ bool DefScriptPackage::LoadScriptFromFile(std::string fn, std::string sn){ } } f.close(); - if(cantload) + if(cantload || Blocks.size()) { printf("DefScript: Error loading script '%s'\n",sn.c_str()); DeleteScript(sn); @@ -446,11 +446,11 @@ DefReturnResult DefScriptPackage::RunScript(std::string name, CmdSet *pSet,std:: if(b.type==BLOCK_IF && b.istrue) { unsigned int other_ifs=0; - for(i=b.startline;;i++) + for(i=b.startline+1;;i++) { - if(sc->GetLine(i).substr(0,3)=="if ") + if(memcmp(sc->GetLine(i).c_str(),"if ",3)==0) other_ifs++; - if(sc->GetLine(i)=="endif") + else if(sc->GetLine(i)=="endif") { if(!other_ifs) break; diff --git a/src/Client/DefScript/DefScriptFunctions.cpp b/src/Client/DefScript/DefScriptFunctions.cpp index a217766..f436997 100644 --- a/src/Client/DefScript/DefScriptFunctions.cpp +++ b/src/Client/DefScript/DefScriptFunctions.cpp @@ -144,7 +144,7 @@ DefReturnResult DefScriptPackage::func_setscriptpermission(CmdSet& Set) if(Set.defaultarg.empty() || Set.arg[0].empty()) return r; - scriptPermissionMap[Set.arg[0]] = atoi(Set.defaultarg.c_str()); + scriptPermissionMap[Set.arg[0]] = (unsigned char)toUint64(Set.defaultarg.c_str()); return r; } @@ -365,7 +365,8 @@ DefReturnResult DefScriptPackage::func_not(CmdSet& Set) DefReturnResult DefScriptPackage::func_isset(CmdSet& Set) { - return variables.Exists(Set.defaultarg); + std::string vname=_NormalizeVarName(Set.defaultarg,Set.myname); + return variables.Exists(vname); } DefReturnResult DefScriptPackage::func_tohex(CmdSet& Set) @@ -415,7 +416,7 @@ DefReturnResult DefScriptPackage::func_substr(CmdSet& Set) unsigned int start,len; len=(unsigned int)toNumber(Set.arg[0]); start=(unsigned int)toNumber(Set.arg[1]); - if(start+lenSet.defaultarg.length()) len=Set.defaultarg.length()-start; r.ret=Set.defaultarg.substr(start,len); return r;