View Single Post
  #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