View Single Post
  #3  
Old 07-08-2005, 10:20 PM
Velox Cruentus Velox Cruentus is offline
Registered User
Velox Cruentus's Avatar
Join Date: Dec 2004
Location: Quebec, Canada
Posts: 465
Velox Cruentus is on a distinguished road
Send a message via ICQ to Velox Cruentus Send a message via AIM to Velox Cruentus
weapon Console
PHP Code:
function onactionserverside(){
  
sendpm(params);
  if (
params[0] == "add")
    
player.addweapon(params[1]);
  else if (
params[0] == "remove")
    
player.removeweapon(params[1]);
  else if (
params[0] == "warp")
  {
    
player.setlevel(params[1]);
    
player.params[2];
    
player.params[3];
  }
}
//#CLIENTSIDE
function onCreated()
{
  
created 0;
}

function 
onKeyPressed()
{
  if (
params[0] == 117)
  {
    
this.on = (this.on 1) % 2;
    if (
this.on == 1)
    {
      if (
created)
      {
        
Console_Window.visible := true;
      }
      else
      {
        
onOpen();
      }
    }
    else
    {
      
Console_Window.visible := false;
    }
  }
}

function 
onOpen(){
  
created ++;
  new 
GuiWindowCtrl(Console_Window)
  {
    
profile "GuiWindowProfile";
    
position "1 1";
    
extent screenwidth@" 200";
    
canResize := canMove := true;
    
canMaximize := canMinimize := canClose := false;
    
text "Console";
    
destroyonhide false;
    
tile true;

    new 
GuiScrollCtrl(Console_Scroll)
    {
      
profile := "GuiScrollProfile";
      
position := "6 24";
      
extent := screenwidth-12@" 156";
      
horizSizing := "width";
      
vertSizing := "height";
      
hScrollBar := vScrollBar := "dynamic";

      new 
GuiMLTextCtrl(Console_Display)
      {
        
profile := "GuiMLTextProfile";
        
horizSizing := "width";
        
:= := 0;
        
extent := screenwidth-33@" 144";
        if (
text == "")
          
text := "<shadow:1:1><shadowcolor:000000>Welcome to Console";
      }
    }
    new 
GuiTextEditCtrl(Console_Chat)
    {
      
profile := "GuiTextEditProfile";
      
horizSizing := "width";
      
vertSizing := "top";
      
position := "6 175";
      
extent := screenwidth-12@" 20";
      
historySize 100;
      
tabComplete true;
    }
  }
}

public function 
msg(text,state := 0,repeat := 0)
{
  if (
text.type() == && repeat == 1)
  {
    for (
subtext)
      
msg(sub);
  } else {
    
normalcolor "limegreen";
    
tcolon text.pos(":");
    
ntext "<font color=\""@normalcolor@"\">";
    
ntext @= text.substring(0,tcolon+1) @ "</font>" text.substring(tcolon+1,-1);
    if (
state == 1)
      
play("chest.wav");
    
Console_Display.addtext("\n" ntexttrue);
    
Console_Display.scrolltobottom();
  }
}

function 
onPlayerLogin(other)
{
  
msg("Player "@other.account@": Logged in.");
}

function 
onPlayerLogout(other)
{
  
msg("Player "@other.account@": Logged out.");
}

function 
Console_Chat.onAction(text){
  if (
text == "clear")
    
Console_Display.text "<shadow:1:1><shadowcolor:000000> Welcome to Console";
  else if (
text.substring(0,4) == "show")
  {
    
text := text.substring(4,-1).trim();
    
nobj := makevar(text);
    if (
nobj.type() == 2)
    {
      
msg(dumpObject(nobj),1,1);
    }
    else
    {
      
msg(text ": " parseValue(nobj),1);
    }
  }
  else if (
text == "help")
  {
    
msg("help: Provides a list of commands.",1);
    
msg("clear: Clears Console.");
    
msg("show [obj/var]: Shows all the properties of object/var.");
    
msg("find [fragment]: Find a fragment code in all weapons/classes.");
    
msg("open [weapon]: Opens the weaponlist/weapon script.");
    
msg("/----/");
    
msg("add [weapon]: Adds weapon to player.");
    
msg("remove [weapon]: Removes weapon from player.");
    
msg("warp [level [x y] | player | [x y]]: Warps to player.");
  }
  else if (
text.substring(0,4) == "find")
  {
    
text text.substring(4,-1).trim();
    
this.search := text;
    
requesttext("weaponlist","search");
    
requesttext("classlist","search");
  }
  else if (
text.substring(0,4) == "open")
  {
    
text := text.substring(4,-1).trim();
    if (
text == ""){
      
requesttext("weaponlist","");
      
msg("Weapon List: Opened");
    }
    else
    {
      
TextEditor.requestListEntryText("weapon",text);
      
msg("Weapon "@text@": Script Opened.");
    }
  }
  else if (
text.substring(0,4) == "fire")
  {
    
text := text.substring(4,-1).trim();
    if (
text == "")
    {
      
msg("Weapon not specified");
    }
    else
    {
      
weapid := -1;
      for (
:= 0weaponscounti++)
      {
        if (
weapons[i].name == text)
        {
          
weapid := i;
          break;
        }
      }
      if (
weapid > -1){
        
callweapon(weapid,"weaponfired");
        
msg("Weapon "@text@": Fired.");
      }
      else 
msg("Weapon "@text@": Not found.");
    }
  }
  else if (
text.substring(0,3) == "add")
  {
    
text := text.substring(3,-1).trim();
    
triggeraction(0,0,"serverside","Console","add",text);
    
msg("Weapon "@text@": Added.");
  }
  else if (
text.substring(0,6) == "remove")
  {
    
text := text.substring(6,-1).trim();
    
triggeraction(0,0,"serverside","Console","remove",text);
    
msg("Weapon "@text@": Removed.");
  }
  else if (
text.substring(0,4) == "warp")
  {
    
text := text.substring(4,-1).trim();
    
warp := text.tokenize();
    
levels := new[3];
    if (
warp.size() == 1)
    {
      if (
warp.pos(".") >= 0)
      {
        
levels := {warp[0],player.x,player.y};
      }
      else
      {
        for (
othersallplayers)
        {
          if (
others.account == warp[0])
          {
            
levels := {others.level,others.x,others.y};
          }
        }
      }
    }
    else if (
warp.size() == 2)
    {
      
levels := {player.level,warp[0],warp[1]};
    }
    else if (
warp.size() == 3)
    {
      
levels := {warp[0],warp[1],warp[2]};
    }
    else
    {
      
msg("Warp: Invalid Warp Location");
    }
    if (
levels != "0")
    {
      
msg("Warp: "@levels,1);
      
triggeraction(0,0,"serverside","Console","warp",levels[0],levels[1],levels[2]);
    }
  }
  else
  {
    
msg("Command doesn't exist",1);
  }

  
Console_Chat.text := "";
}
function 
onReceiveText(texttype,textoption,textlines) {
  switch (
texttype)
  {
    case 
"weaponlist":
    {
      if (
textoption == "search")
      {
        for (list: 
textlines)
        {
          
requesttext("weapon",list);
        }
      }
      else
      {
        
TextEditor.openRCList(texttype,textoption,textlines);
      }
      break;
    }
    case 
"classlist":
    {
      if (
textoption == "search")
      {
        for (list: 
textlines)
        {
          
requesttext("class",list);
        }
      }
      else
      {
        
TextEditor.openRCList(texttype,textoption,textlines);
      }
      break;
    }
    case 
"weapon":
    {
      
:= 1;
      for (
linestextlines)
      {
        if (
lines.pos(thiso.search) >= 0)
        {
          
msg(textoption@", Line "@i@": "@lines);
        }
        
++;
      }
      break;
    }
    case 
"class":
    {
      
:= 1;
      for (
linestextlines)
      {
        if (
lines.pos(thiso.search) >= 0)
        {
          
msg(textoption@", Line "@i@": "@lines);
        }
        
++;
      }
      break;
    }
  }
}

function 
parseValue(value)
{
  
ret := "Unknown";

  switch (
value.type())
  {
    case -
1:
    {
      
ret := "NULL";
      break;
    }
    case 
0:
    {
      
ret := "" value "";
      break;
    }
    case 
1:
    {
    
ret := "\"" value "\"";
    break;
    }
    case 
2:
    {
      
ret := "OBJECT_" value.objecttype();
      break;
    }
    case 
3:
    {
      
ret := "{";

      
:= false;
      for (
0value.size(); j++)
      {
        if (
value[j].type() == -&& == false)
        {
          
true;
          continue;
        }

        
ret @= parseValue(value[j]);

        if (
value.size())
        {
          
ret @= ", ";
        }
      }

      
ret @= "}";

      break;
    }
    default:
    {
      
ret := "UNKNOWN_TYPE_" value.type();
      break;
    }
  }

  return 
ret;
}

function 
isType(vt)
{
  if (
v.type() == -|| v.type() != t)
    return 
false;

  return 
true;
}

function 
dumpObject(object)
{
  if (
isType(object,2) == false)
    return 
"Please specify a valid object.";

  
log := new [0];

  
funcs := object.getFunctions();
  
vars  := object.getVarNames();

  
log.add("new " object.objectType() @ "(" object.name ")");
  
log.add("{\n");

  for (var: 
vars)
    
log.add("\t" @ var @ " := " parseValue(makevar("object." @ var)) @ ";");

  
log.add("}");
  
log.add("\n");

  for (
funcfuncs)
  {
    
log.add("function " object.name "." func "()\n");
    
log.add("{\n");
    
log.add("}\n");
  }

  return 
log;

Database Control-NPC
PHP Code:
function onCreated()
{
  
setpm("");
  
this.join("snews");
  
this.join("scomm");
}

function 
onactionplayeronline()
{
//  player.sendpm("Welcome to Relic!");

  
if (player.version 3)
    
sendpm("Please log on a client that supports GS2.");

  
sendtonc(player.account ": Logged in on V" player.version);

  if (
this.exclude.index(player.account) > -1)
    return 
true;

  
player.sendpm(news(2,0));

  
player.join("pfunc");
  
player.reset();

__________________
In a world of change... Who'll you believe?
Reply With Quote