Handy RC commands I made during my time making my Mud sys. The mkfile command was made over the need to have an easy way to make a file without needing to create it locally and uploading. Note that for the mkfile and cp commands to work, NPC-Server will need rights to the folders you with to use.
Behold!
PHP Code:
/* Twinny's RC toolbox commands */
case "mkfile":
temp.obj.loadlines(params[1]);
if (!temp.obj.size())
{
temp.obj = {"Place","Holder"};
temp.obj.savelines(params[1],0);
temp.obj2.loadlines(params[1]);
if (temp.obj2.size())
printf("[File Creation]: File created at %s",params[1]);
else
echo("[File Creation]: Error! File was not created. Check NPC-Server rights");
}
else if (params[2] == 1)
{
temp.obj = {"Place","Holder"};
temp.obj.savelines(params[1],0);
temp.obj2.loadlines(params[1]);
if (temp.obj2.size())
printf("[File Creation]: %s was overwritten",params[1]);
else
echo("[File Creation]: Error! File was not created. Check NPC-Server rights");
}
else
printf("[File Creation]: File already exists at %s. Use 1 as 2nd parameter if you wish to overwrite", params[1]);
break;
case "cp":
temp.obj.loadlines(params[1]);
if (!temp.obj.size())
{
printf("[Copy]: Error! File %s does not exist",params[1]);
break;
}
temp.obj2.loadlines(params[2]);
if (!temp.obj2.size())
{
temp.obj.savelines(params[2],0);
temp.obj2.loadlines(params[2]);
if (temp.obj2.size())
printf("[Copy]: %s was copied to %s",params[1],params[2]);
else
echo("[Copy]: Error! File was not created. Check NPC-Server rights");
}
else if (params[3] == 1)
{
temp.obj.savelines(params[2],0);
temp.obj2.loadlines(params[2]);
if (temp.obj2.size())
printf("[Copy]: %s was overwritten by %s",params[1],params[2]);
else
echo("[Copy]: Error! File was not created. Check NPC-Server rights");
}
else
echo("[Copy]: Error! File already exists. Set 3rd paramater as 1 if you with to overwrite");
break;
case "getinfo":
printf("Object Type: %s = %s", params[1],makevar(params[1]).objecttype());
printf("Static Vars: %s",makevar(params[1]).getstaticvarnames());
printf("Dynamic Vars: %s",makevar(params[1]).getdynamicvarnames());
break;
case "md5":
printf("[MD5]: %s = %s", params[1],md5(params[1]);
break;
/* End Twinny's RC toolbox commands */
Add this code in Control-NPC between
PHP Code:
function RCChat()
{
switch(params[0])
{
//put code here
//The following case should be entered last. It let's you know if you entered an invalid command
default:
printf("[%s] Unknown Command: %s",player.account,params);
break;
}
}
4 commands available: mkfile, cp and getinfo. 4 commands I am using alot at the moment. Usage:
/npc mkfile path overwrite?. This will try to make a file at the given path and return echo if it was sucessful or not. If the file exists and you enabled overwrite then it will replace the file else echo an error message. To overwrite, simply place a 1. Eg. /npc mkfile mud/test.arc 1
/npc cp path1 path2 overwrite?
This command will attempt to copy a file from path and copy it to path2. It will echo it's success. If path file does not exist, it will return an error. If path2 exists, it will return an error unless you put a 1 in the overwrite parameter
eg. /npc cp mudlib/template.arc mudlib/swords/firesword.arc
/npc getinfo obj
Will echo the objects type, static and dynamic vars. Eg. /npc getinfo dbnpc.randomobj
I found it useful to check whether my container was made with the correct information.
/npc md5 blah
Simply echos the md5 of the parameter given to RC.
Enjoy

.