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 03-29-2009, 01: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
Storing Flags

I've got a few questions relating to storing information


1,) If I were to set an attr of an NPC (class) and was to use it to transfer data from server to client, could a player edit this information from the client side to effect the script?

2,) I'm wanting to store alot of information inside a string in the players attributes, I'm just wondering what the best way would be
Method A:
PHP Code:
  this.item_Knife = {
    {
"damage"3},
    {
"displayname""Knife"}, 
    {
"weight", {0.150.04}}
  }; 
Method B: (Not too sure if this can be done with clientr and also if it's secure...)
PHP Code:
  this.item_Knife.damage 3;
  
this.item_Knife.displayname "Knife";
  
this.item_Knife.weight = {0.150.04}; 
Any suggestions? thanks
Reply With Quote
  #2  
Old 03-29-2009, 02:24 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
You can create an object on the player object :]

PHP Code:
function onCreated() {
  
this.item_Knife = {
    {
"damage"3},
    {
"displayname""Knife"}, 
    {
"weight", {0.150.04}}
  };
  
this.item_Gun = {
    {
"damage"6},
    {
"displayname""Gun"}, 
    {
"weight", {0.60.1}}
  };
}
function 
getItems(items) {
  if (
items.type() != 3) {
    return 
this.(@ "item_"items);
  }
  else {
    
temp.out 0;
    for (
temp.item items) {
      
temp.itemdata this.(@ "item_"temp.item);
      if (
temp.itemdata.size() > 1) {
        
temp.out.add(temp.item);
        
temp.out.add(temp.itemdata);
      }
    }
  }
}
function 
onActionServerside() {
  if (
params[0] == "syncitems") {
    
// get all the player's items here
    
temp.items getItems({"Knife""Gun"});

    
triggerclient("gui""syncitems"temp.items);
  }
}
//#CLIENTSIDE
function onCreated() {
  
player.items = new TStaticVar("Items");
  
triggerserver("gui"this.name"syncitems");
}

function 
onActionClientside() {
  if (
params[0] == "syncitems") {
    
temp.size params[1].size();
    for(
temp.0size+= 2;) {
      
Items.(@ params[1][i]) = params[1][i+1];
    }
  }

I haven't tested it, but it can give you a basic idea of what I meant.
__________________
Reply With Quote
  #3  
Old 03-29-2009, 02:42 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
I pretty much do the same that Chompy suggested for my systems, keeping a clientsided object cache. Only thing that's cross checked with serverside when something is altered, is the ID or other unique information.
__________________
Follow my work on social media post-Graal:Updated august 2025.
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 07:45 PM.


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