Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-05-2007, 05:22 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
RC Toolbox

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 .

Last edited by Twinny; 05-05-2007 at 05:45 PM..
Reply With Quote
  #2  
Old 05-05-2007, 07:26 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
I...Love...You.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:58 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.