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 09-10-2008, 06:14 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Angry shop script help once again

PHP Code:
function onCreated()
{
  
setshape 1,32,32;
}
function 
onActionbuy()
{
  if(
playerrupees>=100)
  {
    
addweapon Event/Headbob;
    
playerrupees-=100;
  }
}
//#CLIENTSIDE
function onPlayerchats()
{
  if(
player.chat=="buy Headbob")
  {
    
triggeraction(x,y,"buy","buy");
    
//the level npc triggeraction type
  
}

when i put this in a lvl npc and say buy Headbob nothing happens

how do i fix it???
Reply With Quote
  #2  
Old 09-10-2008, 08:27 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
Don't use that
Use this

HTML Code:
function onPlayerChats() {
  if (player.chat != "buy headbob") return false;
  if (player.rupees < 100) return false;
  if (player.findWeapon("headbob") != false) return false;
  player.addWeapon("headbob");
  player.rupees -= 100;
}
Reply With Quote
  #3  
Old 09-10-2008, 09:49 PM
Kristi Kristi is offline
Bowie's Deciple
Kristi's Avatar
Join Date: Dec 2003
Location: Boston, MA
Posts: 748
Kristi has a spectacular aura aboutKristi has a spectacular aura about
Send a message via AIM to Kristi Send a message via MSN to Kristi
Quote:
Originally Posted by [email protected] View Post
Don't use that
Use this

HTML Code:
function onPlayerChats() {
  if (player.chat != "buy headbob") return false;
  if (player.rupees < 100) return false;
  if (player.findWeapon("headbob") != false) return false;
  player.addWeapon("headbob");
  player.rupees -= 100;
}
Your code assumes his shopkeeper will only be selling that one item (which will most likely be false)
__________________
Reply With Quote
  #4  
Old 09-10-2008, 09:52 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 Kristi View Post
Your code assumes his shopkeeper will only be selling that one item (which will most likely be false)
you've not seen his server. it will, trust me
Reply With Quote
  #5  
Old 09-11-2008, 01:29 AM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
Nope im selling 3 items lolz
and i scripted them myself
*note they just play ganis well thats good for me *
IM LEARNING HOW TO SCRIPT YAY YAY YAY
Reply With Quote
  #6  
Old 09-11-2008, 02:32 AM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
I was really bored so I made this. It supports multiple items sold. I stopped testing it once I got to the rupee and weapon check, but the command works fine.

Up for grabs, wasn't really making it specifically for Gulthex, I was just really bored and thought I would try it.

PHP Code:
function onPlayerChats()
{
  if (
player.chat.starts("buy"))
  {
    
this.saleItems = {
      {
"headbob"100"Event/Headbob"},
      {
"anotheritem"250"Event/Item"},
      {
"dance item"50"Event/Dance"}
    };

    for (
temp.ithis.saleItems)
    {
      if (
player.chat.substring(4) == temp.i[0])
      {
        
this.buyItem(temp.i[0], temp.i[1], temp.i[2]);
        break;
      }
    }
  }
}

function 
buyItem(itemNameitemPriceitemWeapon)
{
  if (
player.findWeapon(temp.itemWeapon) != false)
  {
    return;
  }
  if (
player.rupees temp.itemPrice)
  {
    
player.chat "You don't have enough money!";
    return;
  }
  
  
player.rupees -= temp.itemPrice;
  
player.addWeapon(temp.itemWeapon;
  
  
player.chat "You have bought" SPC temp.itemName SPC "for" SPC temp.itemPrice SPC "dollars!";

__________________
*Sum41Freeeeek
*Frankie

Last edited by Frankie; 09-11-2008 at 03:09 AM..
Reply With Quote
  #7  
Old 09-11-2008, 03:04 AM
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
Why are you tokenizing the array in buyItem()?

Also, since findweapon() is returning an object methinks you should compare it to null not false so its clear that it is not boolean.
__________________
Reply With Quote
  #8  
Old 09-11-2008, 03:05 AM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
not sure. i'll change it

I also took the findweapon part from andy's script because I've never really done anything like that before :P
__________________
*Sum41Freeeeek
*Frankie

Last edited by Frankie; 09-11-2008 at 03:20 AM..
Reply With Quote
  #9  
Old 09-11-2008, 08:59 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
nice method at Frankie, would have made it a temp. flag and parsed the array as an array, not individual, but other than that it's cool
Reply With Quote
  #10  
Old 09-11-2008, 09:27 AM
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
PHP Code:
function onCreated() {
  
this.saleitems = {
    {
"headbob"100"Event/Headbob"},
    {
"anotheritem"250"Event/Item"},
    {
"dance item"50"Event/Dance"}
  };
}
function 
onPlayerChats() {
  if (
player.chat.starts("buy ")) {
    for (
temp.ithis.saleitems) {
      if (
player.chat.substring(4) == temp.i[0]) {
        
this.buyitem(temp.i.link());
        break;
      }
    }
  }
}
function 
buyitem(item) {
  if (
player.findweapon(temp.item[2]) != null) {
    return 
false;
  }
  if (
player.rupees temp.item[1]) {
    
player.chat "You don't have enough money!";
    return 
false;
  }
  
player.rupees -= temp.item[1];
  
player.addweapon(temp.item[2]);
  
player.chat format("You have bought <percentsign>s for $<percentsign>s"temp.item[0], temp.item[1]);
  return 
true;

You would replace <percentsign> with an actual percent sign because the stupid forum has issues when you try to put it in a post.
__________________
Reply With Quote
  #11  
Old 09-11-2008, 05:26 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Why are you giving him a bunch of confusing methods, the kid's trying to learn how to script, not asking the best way to script his system.
Try this, Gulthex:
PHP Code:
triggeraction(0.50.5"buy"null); 
Also, here you are mixing GS1 with GS2 again... do this:
PHP Code:
function onCreated() { 
  
setshape(13232); 


function 
onActionbuy() { 
  if (
player.rupees >= 100) { 
    
addweapon("Event/Headbob"); 
    
player.rupees -= 100
  } 

__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #12  
Old 09-11-2008, 06:51 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 Tigairius View Post
Why are you giving him a bunch of confusing methods, the kid's trying to learn how to script, not asking the best way to script his system.
That doesn't make sense, we were helping him by teaching him a better method.
Reply With Quote
  #13  
Old 09-11-2008, 06:52 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
Quote:
Originally Posted by [email protected] View Post
That doesn't make sense, we were helping him by teaching him a better method.
Wut?

Quote:
Originally Posted by [email protected] View Post
Don't use that
Use this

HTML Code:
...
Very "teachy"
__________________
Reply With Quote
  #14  
Old 09-11-2008, 07:02 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
Judging from what scripts he have provided and scripting questions asked, I can safetly say that he is new to gscript2.
__________________

Last edited by Kristi; 09-11-2008 at 08:01 PM.. Reason: Edit out part related to deleted post
Reply With Quote
  #15  
Old 09-11-2008, 07:34 PM
Frankie Frankie is offline
xChugxLifex
Frankie's Avatar
Join Date: Feb 2008
Location: New York
Posts: 1,610
Frankie is a jewel in the roughFrankie is a jewel in the rough
Send a message via AIM to Frankie Send a message via MSN to Frankie
I made my code because I was bored hehe
__________________
*Sum41Freeeeek
*Frankie
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 10:14 PM.


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