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
  #16  
Old 04-28-2007, 07:01 AM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
Quote:
Originally Posted by oo_jazz_oo View Post
One last thing. ><
I cant get the weapon to add to the player. =/
I have tried everything....whats wrong with this?
My guess is this little bit right here

PHP Code:
triggeraction(0,0,"serverside","-Shop","addw",@this.item); 
for one you dont need the @ at the start of the param, nor do you need it on the serverside (addweapon).
You never actually set anywhere in any of your script what this.item is.

but if you did trying

PHP Code:
triggeraction(00"serverside""-Shop""addw"thiso.item); 
and

PHP Code:
function onActionServerside() {
 if (
params[0] == "addw") {
  
addweapon(params[1]);
 }

was what you were looking for?

Edit:

It also seems to me like you almost by Habit use @ at the start of variables for example

PHP Code:
if (client.money >=@this.price){ 
Might not work? Anyways that could/should be rewritten as

PHP Code:
if (client.money >= this.price){ 
__________________
Reply With Quote
  #17  
Old 04-28-2007, 07:09 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
It is a habit to write @ before variables. ><
I dont know why.
But, anyway, this.item is set in the level script as this.item = "Guns/Tommy Gun";
And it still doesnt work, even after your fixes. -.-
Reply With Quote
  #18  
Old 04-28-2007, 07:10 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Rapidwolve View Post
Use thiso.itemname for GUI Controls
About time someone saw that o_o
__________________
Do it with a DON!
Reply With Quote
  #19  
Old 04-28-2007, 07:28 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by oo_jazz_oo View Post
It is a habit to write @ before variables. ><
I dont know why.
But, anyway, this.item is set in the level script as this.item = "Guns/Tommy Gun";
And it still doesnt work, even after your fixes. -.-
Post the script and show us how it looks now?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #20  
Old 04-28-2007, 07:35 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Ok, heres the npc in the level:

HTML Code:
this.join("shops");

//#CLIENTSIDE

this.shopname = "John's Shop";

this.itemname = "Tommy Gun";

this.price = "15000";

this.image1 = "dh_tommygun-icon.gif";

this.item = "Guns/Tommy Gun";

The shops class:

HTML Code:
//#CLIENTSIDE
function onCreated(){
setTimer(.05);
}
function onActionLeftMouse(){
new GuiWindowCtrl("shopwin") {
  profile = GuiBlueWindowProfile;
  x = 10;
  y = 100;
  destroyonhide=true;
  canresize=false;
  canminimize=false;
  canmaximize=false;
  canclose=false;
  canmove=true;
  width = 160;
  height = 140;
  text = "";
  
new GuiMLTextCtrl("shopitem") {
  profile = GuiBlueMLTextProfile;
  x = 0;
  y = 25;
  width = 160;
  height = 1;
  text = "<center>"@thiso.itemname@"</center>";
}

new GuiMLTextCtrl(shoppri) {
  profile = GuiBlueMLTextProfile;
  x = 0;
  y = 45;
  width = 160;
  height = 1;
  text = "<center>Price:</center>";
}

new GuiMLTextCtrl(shopprice) {
  profile = GuiBlueMLTextProfile;
  x = 0;
  y = 65;
  width = 160;
  height = 1;
  text = "<center>"@thiso.price@" $</center>";
}

 new GuiFrameSetCtrl("Test_Frames") {
   x = 10;
   y = 65;
   width = 140;
   height = 15;
   rowcount = 1;
   columncount = 1;
   setColumnOffset(1,80);
   setRowOffset(1,80);
   bordercolor = {128,128,255,128};
   
   new GuiScrollCtrl("Test_Frame1") {
     profile = GuiBlueScrollProfile;
     hScrollBar = "dynamic";
     vScrollBar = "dynamic";
   }
 }
 
 new GuiButtonCtrl("cancelb") {
   profile = GuiBlueButtonProfile;
   x = 10;
   y = 90;
   width = 50;
   height = 20;
   text = "Cancel";
 }
 
  new GuiButtonCtrl("buyb") {
   profile = GuiBlueButtonProfile;
   x = 100;
   y = 90;
   width = 50;
   height = 20;
   text = "Buy";
 }

 
}
Test_Frames.PushtoBack();
}

function cancelb.onAction(){
shopwin.destroy();
}
function buyb.onAction(){
if (client.money >[email protected]){
client.money -=this.price;
triggeraction(0,0,"serverside","-Shop","addw",this.item);
}
}

The -shop npc:

HTML Code:
function onActionServerside(){
 if (params[0] == "addw") {
addweapon(params[1]);
      }
    }
But I cant get the weapon to add to the player.
Reply With Quote
  #21  
Old 04-28-2007, 10:25 AM
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 oo_jazz_oo View Post
Ok, heres the npc in the level:

HTML Code:
...

The shops class:

HTML Code:
...

The -shop npc:

HTML Code:
...
But I cant get the weapon to add to the player.
btw; onActionLeftMouse() is serverside :P

I just "modified" some of the script and added another way to add the weapon to the player (public functions in wnpcs)

level npc
PHP Code:
function onCreated()
  
this.join("shops");

//#CLIENTSIDE
function onCreated()
{
  
this.shopname "John's Shop";
  
this.itemname "Tommy Gun";
  
this.price "15000";
  
this.image1 "dh_tommygun-icon.gif";
  
this.item "Guns/Tommy Gun";

class "shops":
PHP Code:
function onCreated()
  
sethape(13232); // you need a shape for triggeractions

function onActionServerside()
{
  if (
params[0] == "addw")
    
ShopFunctions.addShopItem(params[1]);
}
//#CLIENTSIDE
function onCreated()
{
  
sethape(13232); // you need a shape for triggeractions
  
setTimer(0.05);
}
function 
onMouseDown(button)
{
  if (
button == "left")
    
openShopGui();
}
function 
openShopGui()
{
  new 
GuiWindowCtrl(shopwin) {
    
profile GuiBlueWindowProfile;
    
10;
    
100;
    
destroyonhide true;
    
canresize false;
    
canminimize false;
    
canmaximize false;
    
canclose false;
    
canmove true;
    
width 160;
    
height 140;
    
text "";
    new 
GuiMLTextCtrl(shopitem) {
      
profile GuiBlueMLTextProfile;
      
0;
      
25;
      
width 160;
      
height 1;
      
text "<center>" thiso.itemname "</center>";
    }
    new 
GuiMLTextCtrl(shoppri) {
      
profile GuiBlueMLTextProfile;
      
0;
      
45;
      
width 160;
      
height 1;
      
text "<center>Price:</center>";
    }
    new 
GuiMLTextCtrl(shopprice) {
      
profile GuiBlueMLTextProfile;
      
0;
      
65;
      
width 160;
      
height 1;
      
text "<center>" thiso.price " $</center>";
    }
    new 
GuiFrameSetCtrl(Test_Frames) {
      
10;
      
65;
      
width 140;
      
height 15;
      
rowcount 1;
      
columncount 1;
      
setColumnOffset(180);
      
setRowOffset(180);
      
bordercolor = {128128255128};
      new 
GuiScrollCtrl(Test_Frame1) {
        
profile GuiBlueScrollProfile;
        
hScrollBar "dynamic";
        
vScrollBar "dynamic";
      }
    }
    new 
GuiButtonCtrl("cancelb") {
      
profile GuiBlueButtonProfile;
      
10;
      
90;
      
width 50;
      
height 20;
      
text "Cancel";
    }
    new 
GuiButtonCtrl("buyb") {
      
profile GuiBlueButtonProfile;
      
100;
      
90;
      
width 50;
      
height 20;
      
text "Buy";
    }
  }
  
Test_Frames.PushtoBack();
}

function 
cancelb.onAction()
  
shopwin.destroy();

function 
buyb.onAction()
{
  if (
client.money >= this.price){
    
client.money -= this.price;
    
triggeraction(this.0.5this.0.5"serverside""addw"thiso.item);
  }

weapon npc "ShopFunctions":
PHP Code:
public function addShopItem(item)
  
addweapon(params[1]); 
Make the shops class trigger a wnpc to add the weapon to the player,
instead of using triggeractions to get to an other wnpc, use triggeraction to get serverside in the class, then
trigger to the wnpc using the magic of object-oriented and public functions
__________________

Last edited by Chompy; 04-28-2007 at 10:44 AM..
Reply With Quote
  #22  
Old 04-28-2007, 11:51 PM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
Still wont work. =/
Its the triggeraction that isnt working...cause, if you replace
ShopFunctions.addShopItem(params[1]);
with
player.chat = "Test";
Nothing happens, so there is a problem in the triggeraciotn. -.-
Reply With Quote
  #23  
Old 04-29-2007, 03:24 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
It would be params[0] wouldn't it? either do addWeapon(params[0]) or addWeapon(temp.item)
Reply With Quote
  #24  
Old 04-29-2007, 03:37 AM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
most of the corrections made are right but not put into the script correctly
__________________

Last edited by ff7chocoboknight; 04-29-2007 at 03:37 AM.. Reason: spelling
Reply With Quote
  #25  
Old 04-29-2007, 04:46 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
Quote:
Originally Posted by Chompy View Post
btw; onActionLeftMouse() is serverside :P
Actions occur on both sides as long as the object has a shape on both sides.
__________________
Reply With Quote
  #26  
Old 04-29-2007, 03:30 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 oo_jazz_oo View Post
Still wont work. =/
Its the triggeraction that isnt working...cause, if you replace
ShopFunctions.addShopItem(params[1]);
with
player.chat = "Test";
Nothing happens, so there is a problem in the triggeraciotn. -.-
two things

first:
I changed the styling and some vars from the original (your script), but didn't see this:
PHP Code:
if (client.money >= this.price){ 
try change it to
PHP Code:
if (client.money >= thiso.price){ 
(They are right before the triggeraction)

second:

change addWeapon(params[1]); to addWeapon(item); in ShopFunctions,
I was using params[1] because I was thinking of the class (params[1] was the item there)

class "shops":
PHP Code:
function onCreated()
  
sethape(13232); // you need a shape for triggeractions

function onActionServerside()
{
  if (
params[0] == "addw")
    
ShopFunctions.addShopItem(params[1]);
}
//#CLIENTSIDE
function onCreated()
{
  
sethape(13232); // you need a shape for triggeractions
  
setTimer(0.05);
}
function 
onMouseDown(button)
{
  if (
button == "left")
    
openShopGui();
}
function 
openShopGui()
{
  new 
GuiWindowCtrl(shopwin) {
    
profile GuiBlueWindowProfile;
    
10;
    
100;
    
destroyonhide true;
    
canresize false;
    
canminimize false;
    
canmaximize false;
    
canclose false;
    
canmove true;
    
width 160;
    
height 140;
    
text "";
    new 
GuiMLTextCtrl(shopitem) {
      
profile GuiBlueMLTextProfile;
      
0;
      
25;
      
width 160;
      
height 1;
      
text "<center>" thiso.itemname "</center>";
    }
    new 
GuiMLTextCtrl(shoppri) {
      
profile GuiBlueMLTextProfile;
      
0;
      
45;
      
width 160;
      
height 1;
      
text "<center>Price:</center>";
    }
    new 
GuiMLTextCtrl(shopprice) {
      
profile GuiBlueMLTextProfile;
      
0;
      
65;
      
width 160;
      
height 1;
      
text "<center>" thiso.price " $</center>";
    }
    new 
GuiFrameSetCtrl(Test_Frames) {
      
10;
      
65;
      
width 140;
      
height 15;
      
rowcount 1;
      
columncount 1;
      
setColumnOffset(180);
      
setRowOffset(180);
      
bordercolor = {128128255128};
      new 
GuiScrollCtrl(Test_Frame1) {
        
profile GuiBlueScrollProfile;
        
hScrollBar "dynamic";
        
vScrollBar "dynamic";
      }
    }
    new 
GuiButtonCtrl("cancelb") {
      
profile GuiBlueButtonProfile;
      
10;
      
90;
      
width 50;
      
height 20;
      
text "Cancel";
    }
    new 
GuiButtonCtrl("buyb") {
      
profile GuiBlueButtonProfile;
      
100;
      
90;
      
width 50;
      
height 20;
      
text "Buy";
    }
  }
  
Test_Frames.PushtoBack();
}

function 
cancelb.onAction()
  
shopwin.destroy();

function 
buyb.onAction()
{
  if (
client.money >= thiso.price) { // Changed this to thiso
    
client.money -= this.price;
    
triggeraction(this.0.5this.0.5"serverside""addw"thiso.item);
  }

wnpc "ShopFunctions":
PHP Code:
public function addShopItem(temp.item)
  
addweapon(item); 
Quote:
Originally Posted by Rapidwolve View Post
It would be params[0] wouldn't it? either do addWeapon(params[0]) or addWeapon(temp.item)
You're right typo

should be addWeapon(item); in ShopFunctions



Quote:
Originally Posted by Inverness View Post
Actions occur on both sides as long as the object has a shape on both sides.
:O didn't know
__________________
Reply With Quote
  #27  
Old 04-29-2007, 04:37 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
w00t go Chompy
__________________
Reply With Quote
  #28  
Old 04-29-2007, 05:41 PM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Chompy View Post
You're right typo
should be addWeapon(item); in ShopFunctions
Hmm, I always do it like this and it works fine.

PHP Code:
public function addShopItem(item)
{
  
addWeapon(temp.item);  // I put the 'temp.' here

Reply With Quote
  #29  
Old 04-29-2007, 06:17 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
I've used it both ways it really depends on what the scripts are for (GUIs and chests for example)
__________________
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 12:23 PM.


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