Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-11-2008, 08:55 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Mudlib

I've decided to create one, they're alot of fun actually. However, I'm stuck on one part!

HTML Code:
function onCreated() {
  temp.folder.loadFolder("mudlib/*", 1);
  for (temp.e: folder) {
    temp.i = e.tokenize("/");
    if (!i[2].ends(".txt")) continue;
    
    temp.d = new TStaticVar();
    d.loadvars("mudlib/" @ e);
    
    makevar("item_" @ d.realname).destroy();
    makevar("item_" @ d.realname) = new TStaticVar();
    for (temp.f: d.getdynamicvarnames()) {
      if (f.starts("#")) continue;
      makevar("item_" @ d.realname).(@ f) = d.(@ f);
    }
    echo("MUD: Created Item-:" SPC d.displayname); 
    d.destroy();   
  }
}
So this is what creates my mudlib, it works fine! [There are no problems here]

HTML Code:
public function onItem(temp.itemname, temp.amount) {
  temp.data = makevar("item_" @ itemname);
  if (data == null) return false;
  
  temp.i = (this.onGetItemCount(itemname) + amount);
  if (i =< 0) {
    this.client.("i_" @ itemname) = null;
    this.clientr.itemnames.remove(itemname);
    ("i_" @ itemname) = null;
  } else {
    data.itemamount = max(1, i);
    
    this.client.("i_" @ itemname) = new TStaticVar();
    this.client.("i_" @ itemname).copyfrom(data);
    ("i_" @ itemname) = data;
    
    if (!(itemname in this.clientr.itemnames))
      this.clientr.itemnames.add(itemname);
  }
  echo("Amount:" SPC this.onGetItemCount(itemname));
}
  
public function onGetItemCount(temp.itemname) {
  return this.onGetItemStat(itemname, "itemamount");
}

public function onGetItemStat(temp.itemname, temp.flag) {
  return ("i_" @ itemname).(@ flag);
}
Here is the problem, when I am giving the player an item
player.onItem("Item Name", amount);
it's not saving the client.flag in the players attributes. Maybe I'm doing the object copying part wrong, I don't quite know!
Any suggestions?
Reply With Quote
  #2  
Old 07-11-2008, 08:58 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
this.clientr? Tells me this is a player joined class. Unsecure anyway, should move that function somewhere else.
Reply With Quote
  #3  
Old 07-11-2008, 08:59 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Quote:
Originally Posted by Crow View Post
this.clientr? Tells me this is a player joined class. Unsecure anyway, should move that function somewhere else.
so this is why the client flags are not saving?? o_o
it's not insecure at all
Reply With Quote
  #4  
Old 07-11-2008, 09:39 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Hmm, you use client/clientr as objects? ;o

Dunno if that is possible, not sure though..
__________________
Reply With Quote
  #5  
Old 07-11-2008, 10:08 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by [email protected] View Post
so this is why the client flags are not saving?? o_o
it's not insecure at all
You know what a big problem item duping can be. Since this code is inside the player class, it could theoretically be stopped anywhere within, just needs to right portion of lag. That screams insecure to me, sorry D:
Reply With Quote
  #6  
Old 07-11-2008, 10:14 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
ok novo helped me, I can't save tstaticvars [they are removed upon r/c] and i can't transfer them to clientside
Reply With Quote
  #7  
Old 07-11-2008, 10:16 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
I usually convert the object into an array serverside, then sends it clientside and builds up an object with the info in the array I sent :o
__________________
Reply With Quote
  #8  
Old 07-11-2008, 10:16 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Ya, I had that problem too.
Oh, and you should add a unique ID system early on to remove any ability to duplicate.
Reply With Quote
  #9  
Old 07-11-2008, 10:24 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
ah good idea @ Dusty, why thank u

i was going to do that @ chompy, i found it strange that objects can't be transferable to clientside tbh
Reply With Quote
  #10  
Old 07-12-2008, 02:43 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
PHP Code:
temp.data temp.data.savevarstoarray(false); // Maybe true? Cant remember, think its supposed to be false...
triggerClient("gui"name"foo"temp.data); // Sends the converted TStaticVar() as an array to client

//#CLIENTSIDE
function onActionClientSide()
{
  if (
params[0] == "foo"this.data.loadVarsFromArray(params[1]); // Back to a TStaticVar!


Maybe that helps you solve the object transfering?
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #11  
Old 07-12-2008, 08:04 AM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
ooo thanks !! i'll try it once i get back home
Reply With Quote
  #12  
Old 07-12-2008, 06:13 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
Works a charm, having true sorts it [character]

thanks tuff guy
Reply With Quote
  #13  
Old 07-12-2008, 06:42 PM
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
Keep it false unless you really need it sorted as sorting can take quite a bit of cpu if done every time you just want to transfer data clientside.
__________________
Do it with a DON!
Reply With Quote
  #14  
Old 07-12-2008, 06:50 PM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Just to go over a few things that were said here, "clientr." and "client." can definitely NOT be made into TStaticVars, lol.

Also, this is quite a bit insecure. Anything Mudlib related should be done completely serverside with copies of the information sent clientside for reading usage from systems.
Reply With Quote
  #15  
Old 07-12-2008, 06:52 PM
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
Quote:
Originally Posted by TheStan View Post
Just to go over a few things that were said here, "clientr." and "client." can definitely NOT be made into TStaticVars, lol.

Also, this is quite a bit insecure. Anything Mudlib related should be done completely serverside with copies of the information sent clientside for reading usage from systems.
Yes they can, they just lose their functionality as special variable headers .
__________________
Do it with a DON!
Reply With Quote
  #16  
Old 07-13-2008, 12:49 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by zokemon View Post
Yes they can, they just lose their functionality as special variable headers .
Indeed, they can be.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #17  
Old 07-13-2008, 08:21 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by xXziroXx View Post
Indeed, they can be.
So, don't do something just because you can.
__________________
Reply With Quote
  #18  
Old 07-14-2008, 12:11 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Inverness View Post
So, don't do something just because you can.
I agree.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #19  
Old 07-14-2008, 01:12 AM
Vimerge Vimerge is offline
Banned
Join Date: Sep 2007
Posts: 628
Vimerge will become famous soon enough
Heh this all seems so complicated e_e
I really wanna learn GS2, I don't know where to start..
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:37 AM.


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