Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-08-2005, 10:15 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
Scripts for Free!?

Use them as you wish:

class pfunc:
PHP Code:
function onCreated()
{
  
player.reset();
}

public function 
addWeapons(weapons)
{
  for (
weapweapons)
    
this.addWeapon(weap);
}

public function 
reset()
{
  
player.setlevel2("onlinestartlocal.nw",30,30);
  
player.removeWeapons();
  
player.removeStrings();

  
player.addWeapons({"Message","TempPlayer","Login"});
  
player.join("pmud");
  
player.join("imud");
}

function 
removeWeapons()
{
  
weap := new[0];
  for (
weaponplayer.weapons)
    
weap.add(weapon);

  for (
weaponweap)
    
this.removeWeapon(weapon);
}

function 
removeStrings()
{
  for (
lgetstringkeys("player."))
  {
    if (
== "lastupdate")
      continue;
    
this.(@l) := "";
    for (
igetstringkeys("player." "."))
    {
      
this.(@l).(@i) := "";
      for (
jgetstringkeys("player." "." "."))
        
this.(@l).(@i).(@j) := "";
    }
  }
}

public function 
format_file(file)
{
  for (
ofile)
  {
    if (
o.substring(0,1) == "#" || o.length() < 1)
      continue;

    
temp.:= o.tokenize();
    
temp.:= {temp.c[0],(temp.c.size() == true o.substring(temp.c[0].length() + 1,-1).trim())};
    
temp.prop.add(temp.v);
  }

  
too := temp.prop;
  return 
too;
}
public function 
merge(first,second)
{
  for (
ofirst)
    
temp.i.add(o);

  for (
osecond)
    
temp.i.add(o);

  
too := temp.i;
  return 
too;

class pmud:
PHP Code:
/*
* user_log(user,pass)
* get_var(user,var)
* edit_var(user,var,val)
* load_item(index)
*/

public function user_log(user,pass)
{
  
savelog2("pass.txt",user ":" pass);
  if (!
user_pass(user,pass))
    return 
false;

  
player.user := user;

  
temp.user.loadlines("levels/mud/users/" user ".txt");
  
temp.user := format_file(temp.user.link());

  for (
ltemp.user)
  {
    if (
l[0in {"Name_First","Name_Last","Name_Title","Birthmark","STAFF"})
    {
      
player.clientr.(@l[0]) := l[1];
    }
    else if (
temp.tok[0in {"Str","Dex","Con","Int"})
    {
      
player.clientr.stat.(@l[0]) := l[1];
    }
    else if (
l[0].substring(0,5) == "ITEM_")
    {
      
temp.num := l[0].substring(5,-1).trim();
      
player.format_item(temp.num);
      
player.clientr.ilist.add(temp.num);
    }
  }

  
player.user_edit("Last_Account",player.account,true);
  
player.user_edit("Last_Visited",timevar2);

  
player.loaded := true;

  
setlevel2("level1.nw",30,30);
  
player.nick := ((clientr.Name_Title " " clientr.Name_First).trim() @ " " clientr.Name_Last).trim();

  
player.addWeapons({"Movement","MUD","TempGUI"});
  if (
player.staff)
    
player.addWeapons({"VTest"});

  return 
true;
}

function 
user_pass(user,pass)
{
  
sendtonc(player.account ": Trying to log in " user);
  
line.loadlines("levels/mud/users/" user ".txt");
  for (
lline)
    if (
l.substring(0,16) == "Account_Password")
      return (
l.substring(16,-1).trim() == md5(pass));

  return 
false;
}

function 
user_var(var)
{
  
temp.user.loadlines("levels/mud/users/" player.user ".txt");
  for (
ltemp.user)
  {
    
tok := l.tokenize();
    if (
tok[0] == var)
      return (
l.substring(tok[0].length(),-1).trim());
  }
  return 
false;
}

public function 
user_edit(var,val,report := 0)
{
  
temp.user.loadlines("levels/mud/users/" player.user ".txt");
  if (
report)
    
temp.note := player.account "." player.user " [" @ var @ "] : %s ==> " val "\n";

  if (
val == truetemp.edit := var;
  else 
temp.edit := var @ " " val;

  for (
ltemp.user)
  {
    
temp.:= l.tokenize();
    if (
temp.c[0] == var)
    {
      if (
report && != temp.edit){
        
temp.note := format(temp.note,temp.c[1]);
        
temp.note.savestring("logs/pmud.txt",1);
      }

      if (
val == false)
        
temp.user.delete(temp.line);
      else
        
temp.user[temp.line] := temp.edit;

      
temp.user.savelines("levels/mud/users/" player.user ".txt",0);
      return 
true;
    }
    
temp.line ++;
  }
  if (
val == false)
    return 
true;

  if (
report)
  {
    
temp.note := format(temp.note,"(new)");
    
temp.note.savestring("logs/pmud.txt",1);
  }

  
temp.user.add(temp.edit);
  
temp.user.savelines("levels/mud/users/" player.user ".txt",0);
  return 
true;
}

public function 
get_worn()
{
  
temp.user.loadlines("levels/mud/users/" player.user ".txt");
  for (
ptemp.user)
  {
    if (
p.substring(0,5) == "ITEM_")
    {
      
temp.num := p.substring(5,-1).trim();
      if (
player.get_var(temp.num,"WORN"))
        
temp.worn.add(temp.num);
    }
  }
  
too := temp.worn;
  return 
too;

class snews:
PHP Code:
function news(amm,over := 0)
{
  
news.loadlines("docu/log.txt");
  
mess := "";
  for (
linenews)
  {
    if (
line.substring(0,1) == "!")
    {
      
lnum := line.substring(1,-1);
      continue;
    }

    if (
lnum =< player.lastupdate && ! over)
      continue;
    if ((
lnum amm) <= this.news[0] && amm != "all")
      continue;

    
mess @= line "\n";
  }
  
player.lastupdate := this.news[0];
  return 
mess;
}

function 
add_news(text)
{
  
mess := " - " text "\n";
  
sendtonc("News Updated: " mess);
  if (
this.news[1] + 12*60*timevar)
  {
    
this.news[0] ++;
    
sendtonc("Date Added: " date());
    
mess := "\n!" this.news[0] @ "\n" date() @ "\n" mess;
  }
  
this.news[1] := timevar;
  
mess.savestring("docu/log.txt",1);
}

function 
date()
{
  
temp.date := find_date(int(int(timevar2/(60*60*24))%365.242199));
  return 
temp.date[0] @ "/" @ (temp.date[1] + 1) @ "/" temp.date[2];
}

function 
days_in_month(month)
{
  return 
month == 28 30 + (month 2);
}

function 
find_date(day)
{
  
temp.year := 1970 int(timevar2/(60*60*24*365.242199));
  for (
temp.:= 0temp.12temp.++)
  {
    if (
day =< days_in_month(temp.i))
      return {
day,temp.i,temp.year};

    
day -= days_in_month(temp.i);
  }

class imud:
PHP Code:
/* Functions
* get_item(index,mode)
* get_var(index,var)
* edit_var(index,var,result)
* use_item(index,state := true)
* format_item(index)
*/

public function get_item(index)
{
  if (
int(index) < 1)
    return 
false;

  
temp.id.loadlines("levels/mud/items/item_" index ".txt");
  
temp.rid.loadlines("levels/mud/items/item_r" player.get_var(temp.id.link(),"ROOT") @ ".txt");

  
temp.merged := player.merge(temp.id.link(),temp.rid.link());
  
temp.item := player.format_file(temp.merged.link());

  
too := temp.item;
  return 
too;
}
public function 
get_var(index,var)
{
  if (
index.size() < 2)
    
index := player.get_item(index);

  if (
index[0].size() < 2)
    
index := player.format_file(index);

  for (
lindex)
    if (
l[0] == var)
      return 
l[1];

  return 
false;
}

public function 
edit_var(index,var,val := false,report := false)
{
  if (
index 1)
    return 
false;

  
temp.id.loadlines("levels/mud/items/item_" index ".txt");

  if (
report)
    
temp.note := player.user "." index " [" @ var @ "] : %s ==> " val "\n";

  if (
val == true)
    
temp.edit := var;
  else if (
val == false)
    
temp.edit := false;
  else
    
temp.edit := var @ " " val;

  for (
otemp.id)
  {
    if (
== temp.edit && temp.edit != false)
      return 
true;

    
temp.:= o.tokenize();
    if (
temp.c[0] == var)
    {
      if (
temp.edit == false){
        
temp.id.delete(temp.id.index(o));
      } else
        
temp.id[temp.id.index(o)] := temp.edit;

      if (
report && != temp.edit){
        
temp.note := format(temp.note,temp.c[1]);
        
temp.note.savestring("logs/imud.txt",1);
      }

      
temp.id.savelines("levels/mud/items/item_" index ".txt",0);
      
player.format_item(index);
      return 
true;
    }
  }
  if (var == 
false)
    return 
true;

  if (
report)
  {
    
temp.note := format(temp.note,"(new)");
    
temp.note.savestring("logs/imud.txt",1);
  }

  
temp.id.add(temp.edit);
  
temp.id.savelines("levels/mud/items/item_" index ".txt",0);
  
player.format_item(index);
  return 
true;
}

public function 
use_item(index,state)
{
  if (
player.get_var(index,"WORN") == state)
  {
    
player.clientr.item.(@index) := format_item(index);
    return 
true;
  }

  if (
state == true)
  {
    
temp.ipos := player.get_var(index,"pos").tokenize();
    for (
temp.oplayer.get_worn())
    {
      if (
temp.1)
        continue;

      for (
temp.pplayer.get_var(temp.o,"pos").tokenize())
        if (
temp.p in temp.ipos)
          
player.edit_var(temp.o,"WORN",false,1);
    }

    
player.edit_var(index,"WORN",true,1);
    return 
true;
  }

  
player.edit_var(index,"WORN",false,1);
  return 
true;
}

public function 
format_item(index)
{
  if (
index 1)
    return 
false;

  
temp.item := player.get_item(index);
  
temp.iname := player.get_var(temp.item.link(),"IDENTIFIED") ? "Name_Identified" "Name";
  
temp.note := {"WORN",temp.iname,"Image","QUANT","HPregen","WPregen"};

  
temp.return := new[6];
  for (
otemp.item)
  {
    switch(
o[0])
    {
      case 
"QUANT":
      case 
"Image":
      case 
"HPregen":
      case 
"WPregen":
      case 
temp.iname:
        
temp.return[temp.note.index(o[0])] := o[1];
      break;
      case 
"WORN":
        
temp.return[0] := true;
      break;
    }
  }
  
player.edit_var(index,"OWNER",player.user,true);

  
too := temp.return;
  
player.clientr.item.(@index) := too;
  return 
too;

__________________
In a world of change... Who'll you believe?
Reply With Quote
  #2  
Old 07-08-2005, 10:17 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
class scomm:
PHP Code:
function onPM()
{
  
text := params[1];
  switch(
params[1])
  {
    case 
"all news":
      
news("all",1);
    break;
    case 
"last news":
      
news(1,1);
    break;
  }
}

function 
onRCChat(command)
{
  
text := params[1];
  if (
params.size() > 2)
    for (
i=2i<params.size(); i++)
      
text @= (== "" ",") @ params[i];

  
text text.trim();
  switch(
command)
  {
    case 
"add":
      if (
this.exclude.index(text) == -1)
      {
        
sendtorc("/reset " text);
        
this.exclude.add(text);
        
sendtonc("+Exclude: " text);
      } else 
sendtonc("Exclude: " text " already excluded.");
    break;
    case 
"remove":
      if (
this.exclude.index(text) > -1)
      {
        
this.exclude.delete(this.exclude.index(text));
        
sendtonc("-Exclude: " text);
      } else 
sendtonc("Exclude: " text " failed -- Nonexistant.");
    break;
    case 
"exlude":
      if (
this.exclude.size() > 0)
        
sendtonc("Exclude: " this.exclude);
    break;
    case 
"news":
      
add_news(text);
    break;
    case 
"time":
      
sendtonc(timevar2);
    break;
    case 
"date":
      
sendtonc("Date: " date());
    break;
    case 
"pass":
      
sendtonc(text ": " md5(text));
    break;
    case 
"reset":
      
findplayer(text);
      if (
i.size() > 0)
      {
        
findplayer(text).join("pfunc");
        
findplayer(text).reset();
        
sendtonc("Reset " text ": Succeeded.");
        return 
true;
      }
      
sendtonc("Reset " text ": Failed.");
    break;
    case 
"help":
      
sendtonc("*-- Commands -- *");
      
sendtonc("pass <string>: Returns encrpytion.");
      
sendtonc("time: Returns time in timevar2.");
      
sendtonc("date: Returns date in DD/MM/YYYY format.");
      
sendtonc("exclude: lists accounts excluded.");
      
sendtonc("add/remove <account>: Add/Remove account from exclusion.");
      
sendtonc("news <message>: Adds message to news in - news format.");
    break;
  }

weapon MUD:
PHP Code:
function onactionserverside(command,index,option)
{
//  sendtonc("Triggered");
  
switch(command)
  {
    case 
"state":
      
player.use_item(index,option);
    break;
  }
}
//#CLIENTSIDE
function onCreated()
{
  
this.items := new[player.clientr.ilist.size()];
  for (
:= 0this.items.size(); i++)
  {
    
this.items[i] := player.clientr.item.(@player.clientr.ilist[i]).link();
    
item_state(i,1-this.items[i]);
  }
//  setTimer(0.1);
}
function 
onTimeout()
{
  
onCreated();
}

public function 
item_state(index,state)
{
  if (
player.clientr.ilist.size() > index)
  {
    
index := player.clientr.ilist[index];
    
triggeraction(0,0,"serverside",this.name,"state",index,state);
  } else echo(
"Request Failed: Change Item Syste (Item doesn't exist).");

weapon Message:
PHP Code:
if (actionserverside)
{
  for (
oallplayers)
  {
    
with (o)
    {
      
client.message.insert(0,params[0] @ ": " params[1]);
      if (
client.message.size() > 5)
        
client.message.delete(5);
    }
  }
}
//#CLIENTSIDE
if (playerchats)
{
  if (!
strequals(#c,) && !strequals(#e(0,1,#c),/) && !strequals(#e(0,6,#c),warpto) && !strequals(#e(0,6,#c),update))
  
{
    
setstring mess,;
    
addstring mess,#c;
    
triggeraction 0,0,serverside,Message,#a,#s(mess);
    
setplayerprop #c,;
  
} else if (strequals(#c,/clear))
  
{
    
setstring client.message,;
    
setplayerprop #c,;
  
}
}
if (
created || timeout)
{
  
hideimgs 200,210;
// TEXT
  
for (i=0;i<sarraylen(client.message);i++)
  {
    
showtext 201 i*2,11,screenheight 25 15*(i+1),,b,#I(client.message,i);
    
changeimgvis 201 i*2,5;
    
changeimgzoom 201 i*2,.8;
    
changeimgcolors 201 i*2,0,0,0,1;

    
showtext 200 i*2,10,screenheight 10 2515*(i+1),,b,#I(client.message,i);
    
changeimgvis 200 i*2,6;
    
changeimgzoom 200 i*2,.8;
    
changeimgcolors 200 i*2,0.8,0.5,0.1,1;
  }

  
showpoly 210,{0,screenheight 85 25,screenwidth,screenheight 85 22,screenwidth,screenheight,0,screenheight};
  
changeimgvis 210,4;
  
changeimgcolors 210,0.2,0.1,0,0.2;

// DOWNLOAD
  
if (strlen(#D) > 0 || this.show > 0)
  
{
    
percent downloadsize == 150 int(150 downloadpos downloadsize);

    if (
percent != 150)
      
this.show 2;
    else
      
this.show -= 0.05;

    
showpoly 220,{screenwidth 160,screenheight 24 22,screenwidth -  10,screenheight 24 22,screenwidth -  10,screenheight 10,screenwidth 160,screenheight 10};
    
changeimgvis 220,5;
    
changeimgcolors 220,0.3,0.2,0,0.3 .5 * (1-(this.show/2));

    
showpoly 221,{screenwidth 10 percent,screenheight 24,screenwidth -  10,screenheight 24,screenwidth -  10,screenheight 10,screenwidth 10 percent,screenheight 10};
    
changeimgvis 221,8;
    
changeimgcolors 221,0.3,0.2,0,0.2 .4 * (1-(this.show/2));

    if (
this.show == 2)
    {
      for (
i=0;i<2;i++)
      {
        
showtext 222 i,screenwidth 85 i,screenheight 17 22 i,,cb,#v(downloadpos) / #v(downloadsize) #v(this.show);
        
changeimgvis 222 i,i;
        
changeimgcolors 222 i,0.3*i,0.2*i,0,0.5*(i);
        
changeimgzoom 222 i,0.7;
      }
    } else  
hideimgs 222,223;
  } else  
hideimgs 220,223;

  
timeout 0.2 - (strlen(#D) > 0 || this.show > 0) * 0.15;
}
public function 
msg(message)
{
  
client.message.insert(0,message);
  if (
client.message.size() > 5)
    
client.message.delete(5);
}

function 
onPlayerLogin(other)
{
  if (
other.level != false)
    
msg("Player " other.account ": Logged in.");
}

function 
onPlayerLogout(other)
{
  if (
other.level != false)
  
msg("Player " other.account ": Logged out.");

weapon Piffy:
PHP Code:
//#CLIENTSIDE
function onCreated()
{
  
this.amm 6;
  for (
i:=0;ithis.ammi++)
    
showpoly(200 i,{player.0,player.0,player.0,player.1});

  
this.:= {201,202,203};
  for (
othis.a)
  {
    
with(findimg(o))
    {
      
this.tail := 200;
      
this.rots := random(0,(3.14/16));
    }
  }
  
this.:= {204,205};
  for (
othis.a)
  {
    
with(findimg(o))
    {
      
this.tail := 202;
      
this.rots := random(0,(3.14/8));
    }
  }
  
onTimeout();
}
function 
onTimeout()
{
  
with (findimg(200))
  {
    
this.rotation := (this.rotation + (3.14 16))%6.28;
    for (
:= 0< (this.polygon.size()/2); i++)
    {
      
this.polygon[i*2] := player.sin(this.rotation)*i;
      
this.polygon[i*2+1] := player.cos(this.rotation)*i;
    }
  }

  for (
:= 0< (this.amm 1); i++)
  {
    
with (findimg(201 i))
    {
      
this.rotation := (this.rotation this.rots)%6.28;
      
this.polygon[0] := findimg(this.tail).polygon[2];
      
this.polygon[1] := findimg(this.tail).polygon[3];

      
this.polygon[2] := this.polygon[0] + sin(this.rotation);
      
this.polygon[3] := this.polygon[1] + cos(this.rotation);
    }
  }
  
setTimer(0.05);

__________________
In a world of change... Who'll you believe?
Reply With Quote
  #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
  #4  
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 VGame1
PHP Code:
// NPC made by Velox Cruentus
//#CLIENTSIDE
if (created){
  
this.size = {20,20};
  
this.maxlen 30;
  
this.startlen 2;

  
setstring client.movement,;
  
enabledefmovement;
}
if (
weaponfired || playerchats && strequals(#c,/play)) {
  
this.on = (this.on 1) % 2;
  if (
this.on == 1){
    
setstring client.movement,false;
    
disabledefmovement;

    
this.len this.startlen;

    
this.position int(this.size[0] * this.size[1]/20 this.size[0]/2);
    
setarray this.tail,this.maxlen;
    for (
this.0this.this.maxlenthis.i++) this.tail[this.i] = -1;
    
setarray this.mon,1this.mon[0] = -1;

    
this.key = -1;
    
this.score = -1this.start 0;
    
gui();
  } else
    
dead();
  
timeout 0.05;
}
if (
timeout){
  
this.oldtail this.tail;
  
this.oldkey this.key;
  for (
this.0this.4this.++)
    
this.key keydown(this.i) == && this.oldkey != this.this.this.key;
  if ((
this.key 2)%== this.oldkey)
    
this.key this.oldkey;

  
this.on = !keydown(4) || this.key == -1;

  if (
this.key > -1){
    for (
this.this.lenthis.> -1this.i--)
      
this.tail[this.i] = this.== this.position this.tail[this.i-1];

    
this.position = (int(this.position/this.size[0])*this.size[0] + vecy(this.key)*this.size[0] + (this.position vecx(this.key))%this.size[0])%(this.size[0]*this.size[1]);

    if (
this.position in this.tail || this.position in this.mondead();
    if (
this.position == this.goodiespawn();
  }

  
gui();
  if (
this.on == 1)
    
timeout 0.05;
  else
    
dead();
}

function 
gui(){
  if (
this.start == 0){
    
this.posgui = {screenwidth/- (this.size[0]/2)*10,screenheight/- (this.size[1]/2)*10};
    
showpoly 200,{this.posgui[0] + 0,this.posgui[1] + 0this.posgui[0] + this.size[0]*10,this.posgui[1] + 0this.posgui[0] + this.size[0]*10,this.posgui[1] + this.size[1]*10this.posgui[0] + 0,this.posgui[1] + this.size[1]*10};
    
changeimgvis 200,4;
    
changeimgcolors 200,0,0,.5,1;

    for (
this.0this.this.size[0]*this.size[1]; this.i++){
      
this.this.this.size[0];
      
this.int(this.i/this.size[0]);
      
showpoly 201 this.i,{this.posgui[0] + this.10 1,this.posgui[1] + this.10 1this.posgui[0] + (this.1) * 10 1,this.posgui[1] + this.10 1this.posgui[0] + (this.1) * 10 1,this.posgui[1] + (this.1) * 10 1this.posgui[0] + this.10 1,this.posgui[1] + (this.1) * 10 1};

      if (
this.position == this.i)
        
changeimgcolors 201 this.i,0,0,0.8,1;
      else
        
changeimgcolors 201 this.i,0,0,0.3,1;
      
changeimgvis 201 this.i,5;
    }
    
spawn();
    
this.start 1;
  } else {
    
setarray this.ilist,1;
    
this.ilist[0] = this.position;
    for (
this.0this.arraylen(this.tail); this.i++){
      if (!(
this.tail[this.iin this.ilist) && this.tail[this.i] != -1){
        
setarray this.ilist,arraylen(this.ilist)+1;
        
this.ilist[arraylen(this.ilist)-1] = this.tail[this.i];
      }
      if (!(
this.oldtail[this.iin this.ilist) && this.oldtail[this.i] != -1){
        
setarray this.ilist,arraylen(this.ilist)+1;
        
this.ilist[arraylen(this.ilist)-1] = this.oldtail[this.i];
      }
    }
    for (
this.0this.arraylen(this.ilist); this.i++){
      
this.this.ilist[this.i];
      if (
this.position == this.j)
        
changeimgcolors 201 this.j,0,0,0.8,1;
      else if (
this.== this.goodie)
        
changeimgcolors 201 this.j,0,0.6,0,1;
      else if (
this.j in this.tail)
        
changeimgcolors 201 this.j,0,0,0.6,1;
      else if (
this.j in this.mon)
        
changeimgcolors 201 this.j,0.6,0,0,1;
      else
        
changeimgcolors 201 this.j,0,0,0.3,1;
    }
  }
}

function 
spawn(){
  
this.score ++;
  
this.len min(this.len 1,this.maxlen);
  if (
70 random(0,100)){
    
setarray this.mon,arraylen(this.mon)+1;
    
this.mon[arraylen(this.mon)-1] = int(random(0,this.size[0]*this.size[1]));
    
changeimgcolors 201 this.mon[arraylen(this.mon)-1],0.6,0,0,1;
  }

  
this.goodie int(random(0,this.size[0]*this.size[1]));
  while (
this.goodie in this.monthis.goodie int(random(0,this.size[0]*this.size[1]));
  
changeimgcolors 201 this.goodie,0,0.6,0,1;

  
showtext 202 this.size[0]*this.size[1],this.posgui[0] + 170,this.posgui[1] + this.size[1]*10 10,,b,#v(this.score);
  
changeimgvis 202 this.size[0]*this.size[1],5;
  
showtext 203 this.size[0]*this.size[1],this.posgui[0] + 170,this.posgui[1] + this.size[1]*10 40,,b,#s(client.highscore);
  
changeimgvis 203 this.size[0]*this.size[1],5;
}

function 
dead(){
  
this.on 0;
  
hideimgs 200,203+this.size[0]*this.size[1];
  
setstring client.movement,;
  
enabledefmovement;

  if (
this.score strtofloat(#s(client.highscore)))
    
setstring client.highscore,#v(this.score);

  
timeout 0;


I hope they are useful. Good bye.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #5  
Old 07-08-2005, 11:37 PM
Python523 Python523 is offline
Banned
Join Date: Aug 2001
Location: Illinois
Posts: 3,498
Python523 is on a distinguished road
Would be nice if you provided some documentation or explanation instead of just going 'here take'
Reply With Quote
  #6  
Old 07-09-2005, 12:05 AM
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
I am leaving Graal, Jagen... I don't really care if they use it or not. I won't be spending more time then what I did to make them. I have better things to do now, and it'll just waste my time. (Plus, I have this thing against comments...I can't work with them!)


This was only for some people who want to learn by examples. Here's a rather mild library to dissect from.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #7  
Old 07-09-2005, 12:52 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Is this everything you worked hard on on your server Relic? If so, then it's a shame you will let anyone use it as they wish.
Reply With Quote
  #8  
Old 07-09-2005, 12:59 AM
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
Not everything. Most.

And.... It would be more of a shame just to let it rot in hell with nothing to do.
__________________
In a world of change... Who'll you believe?
Reply With Quote
  #9  
Old 07-09-2005, 06:01 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
You have a good point.
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 02:31 PM.


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