Graal Forums  

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

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #28  
Old 08-09-2011, 07:17 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
Here's one way of doing it, you assign a shop id to your npc.

I.e: this.shop_id = "basicshop";

PHP Code:
function onCreated() {
  
this.shop_id "basicshop";
  
this.join("shopkeeper");

DB-NPC: DB_Shops (For this example)

PHP Code:
function onCreated() {
  
// Setup Basic Shop's Item List
  
this.shop_basicshop = {
    {
"Fireball""split_fireball""split_fireball.png""split_fireball_selected.png"30}, 
    {
"Sword""split_sword""split_sword.png""split_sword_selected.png"20},
    {
"Bow""split_bow""split_bow.png""split_bow_selected.png"10}
  };
}

// Public method to retrieve the items for a specific shop
public function getShopItems(shop_id) {
  return 
this.("shop_" shop_id);

then in your NPC:

PHP Code:
// other code..

function getShopItems() {
  return 
DB_Shops.getShopItems(this.shop_id);
}

function 
onPlayerTouchsMe() {
  
// You don't need to specify "gui", you can just use the weapon's name.
  
player.triggerclient("-shopcontrol"this.shop_idgetShopItems(), this.xthis.y);

Then in your script you can just store the shop id, and display the items, and then trigger your DB-NPC, verify the purchase against the list of items for that shop, and allow the player to purchase the item.
__________________
Quote:
Reply With Quote
 


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 05:31 AM.


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