Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 10-09-2011, 07:09 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Use a DB-NPC to store chest contents instead of serverr flags.

You can do that like this:

PHP Code:
function onCreated() {
  
this.db YourDatabaseNPCsName;
  if (!
this.chest_id) {
    echo(
"Chest created in " this.level.name " without chest id!");
    
destroy();
  }
}

function 
onActionAddItem(item) {
  
// Make sure item is in chest
  
if (item in getItems()) {
    
// Remove weapon from chest
    
takeItem(item);
    
// Add weapon to player
    
player.addweapon(item);
  }
}

function 
onActionTakeItem(item) {
  
// Make sure the item isn't already in chest
  
if (!(item in getItems())) {
    
// Remove weapon from Player
    
player.removeweapon(item);
    
// Add item to chest
    
addItem(item);
  }
}

/* Chest functions to interact with database */

function getItems() {
  return 
this.db.("chest_" this.chestid);
}

function 
addItem(item) {
  
this.db.("chest_" this.chestid).add(item);
}

function 
takeItem(item) {
  
this.db.("chest_" this.chestid).remove(item);

then when you add chests to levels:

PHP Code:
function onCreated() {
  
this.chest_id "someuniqueid";
  
join("your_chest_class");

You'll have to update how you send the chest data to the client though.
__________________
Quote:
Reply With Quote
 

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 11:50 PM.


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