* new conf option: "cmdchar". default is "."

* various .def scripts updates
* added cmd.def & getchatitem.def
* fixed: correctly check variable names in function "isset"
* fixed problems with loading scripts that cosist captalized IF/ENDIF/LOOP/ENDLOOP statments. now  upper, lower and mixedcase work as they should.
This commit is contained in:
False.Genesis 2007-03-24 00:07:59 +00:00
parent 739ee2eae2
commit 1299c5490f
12 changed files with 83 additions and 24 deletions

View File

@ -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=.

View File

@ -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.

View File

@ -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}

7
bin/scripts/cmd.def Normal file
View File

@ -0,0 +1,7 @@
#permission=255
// purpose: send a server command.
// args:
// @def: command to send
SAY ${#CMDCHAR}${@def}

View File

@ -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 .

View File

@ -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}

View File

@ -1,3 +1,5 @@
#permission=255
SAY Terminating proc...
IF ${@inworld}
SAY Terminating proc...
ENDIF
SHDN

View File

@ -1,2 +1,20 @@
#permission=0
SAY,{${@0}} ${@def}
// 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

View File

@ -2,4 +2,7 @@
MAKECHATITEM,i ${@def}
SAY ${i}
UNSET i
UNSET i
// we could also use the following:
// SAY ?{GETCHATITEM ${@def}}

View File

@ -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

View File

@ -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;

View File

@ -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+len<Set.defaultarg.length())
if(start+len>Set.defaultarg.length())
len=Set.defaultarg.length()-start;
r.ret=Set.defaultarg.substr(start,len);
return r;