Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Storing Flags (https://forums.graalonline.com/forums/showthread.php?t=84882)

[email protected] 03-29-2009 01:59 PM

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

Chompy 03-29-2009 02:24 PM

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. :)

xXziroXx 03-29-2009 02:42 PM

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.


All times are GMT +2. The time now is 12:24 AM.

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