Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-19-2007, 05:00 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Unhappy Prize Shop script

The Events Team Admin in the pw I work for asked me to make him a script for a prize shop. I made it and he sent this script back saying it didn't work. This isn't the script I sent him though.... Can someone fix the script before I go mad?
HTML Code:
//#CLIENTSIDE
function onPlayerChats() {
  if (player.chat == "buy Juggling") {
     if (clientr.etcoins >= "30") {
        clientr.etcoins -= "30";
        addweapon "*Prizes/Juggle";
     }
  }
  if (player.chat == "buy PK Heal") {
     if (clientr.etcoins >= "30") {
        clientr.etcoins -= "30";
        addweapon "*Prizes/PK Heal";
    }
  }
  if (player.chat == "buy Jump") {
    if (clientr.etcoins >= "50") {
       clientr.etcoins -= "50";
       addweapon "*Prizes/Jump";
    }
  }
    if (player.chat == "buy Light Mouse") {
     if (clientr.etcoins >= "150") {
        clientr.etcoins -= "150";
        addweapon "*Prizes/Light Mouse";
    }
  }
}
__________________
Reply With Quote
  #2  
Old 05-19-2007, 05:05 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
remove quotes from the number ("30" to 30 etc..)

addweapon("*Prizes/Light Mouse");
need ( )

addweapon is serverside
setting clientr. strings must be done serverside

__________________
Reply With Quote
  #3  
Old 05-19-2007, 05:15 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
So, it should be this...?
HTML Code:
//#SERVERSIDE
function onPlayerChats() {
  if (player.chat == "buy Juggling") {
     if (clientr.etcoins >= 30) {
        clientr.etcoins -= 30;
        addweapon ("*Prizes/Juggle");
     }
  }
  if (player.chat == "buy PK Heal") {
     if (clientr.etcoins >= 30) {
        clientr.etcoins -= 30;
        addweapon ("*Prizes/PK Heal");
    }
  }
  if (player.chat == "buy Jump") {
    if (clientr.etcoins >= 50) {
       clientr.etcoins -= 50;
       addweapon ("*Prizes/Jump");
    }
  }
    if (player.chat == "buy Light Mouse") {
     if (clientr.etcoins >= 150) {
        clientr.etcoins -= 150;
        addweapon ("*Prizes/Light Mouse");
    }
  }
}
It's what I sent him before, but without the //#SERVERSIDE
__________________
Reply With Quote
  #4  
Old 05-19-2007, 05:25 PM
godofwarares godofwarares is offline
Webmaster
godofwarares's Avatar
Join Date: Dec 2006
Location: Florida
Posts: 552
godofwarares is on a distinguished road
Send a message via ICQ to godofwarares Send a message via AIM to godofwarares Send a message via MSN to godofwarares Send a message via Yahoo to godofwarares
Quote:
Originally Posted by ff7chocoboknight View Post
So, it should be this...?
HTML Code:
//#SERVERSIDE
function onPlayerChats() {
  if (player.chat == "buy Juggling") {
     if (clientr.etcoins >= 30) {
        clientr.etcoins -= 30;
        addweapon ("*Prizes/Juggle");
     }
  }
  if (player.chat == "buy PK Heal") {
     if (clientr.etcoins >= 30) {
        clientr.etcoins -= 30;
        addweapon ("*Prizes/PK Heal");
    }
  }
  if (player.chat == "buy Jump") {
    if (clientr.etcoins >= 50) {
       clientr.etcoins -= 50;
       addweapon ("*Prizes/Jump");
    }
  }
    if (player.chat == "buy Light Mouse") {
     if (clientr.etcoins >= 150) {
        clientr.etcoins -= 150;
        addweapon ("*Prizes/Light Mouse");
    }
  }
}
It's what I sent him before, but without the //#SERVERSIDE
//#SERVERSIDE does not exist. You need to do a trigger from client to server to achieve what you are going after.
__________________
What signature? I see no signature?
Reply With Quote
  #5  
Old 05-19-2007, 05:29 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by godofwarares View Post
//#SERVERSIDE does not exist. You need to do a trigger from client to server to achieve what you are going after.
Actually, if it's a NPC in a shop: why use clientside? Remove the //#SERVERSIDE line as that does nothing and all shall be sweet.
Reply With Quote
  #6  
Old 05-19-2007, 05:29 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by godofwarares View Post
//#SERVERSIDE does not exist. You need to do a trigger from client to server to achieve what you are going after.
Why not just do it all serverside? There is nothing there that needs to be clientside at all.
__________________
Skyld
Reply With Quote
  #7  
Old 05-19-2007, 05:31 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Skyld View Post
Why not just do it all serverside? There is nothing there that needs to be clientside at all.


^Right, take a look at these:


PHP Code:
function onActionServerSide()
{
 if (
params[0] == "PurchaseItem")
  {
   switch(
params[1])
    {
     case 
"Juggling":
      if (
clientr.etcoins >= 30)
       {
        
clientr.etcoins -= 30;
        
addweapon("*Prizes/Juggle");
       }
      else
       {
        
player.chat "Insufficient funds!";
       }
      break;
    }
  }
}

//#CLIENTSIDE
function onPlayerChats()
{
 
tokens player.chat.tokenize();
 if (
tokens[0] == "buy")
  {
   
this.t_chat tokens.substring(4);
   switch(
this.t_chat)
    {
     case 
"Juggling":
      
triggerserver("gui",name,"PurchaseItem","Juggling");
      break;
    }
  }


Compared to:

PHP Code:
function onPlayerChats()
{
 
tokens player.chat.tokenize();
 if (
tokens[0] == "buy")
  {
   
this.t_chat tokens.substring(4);
   switch(
this.t_chat)
    {
     case 
"Juggling":
      if (
clientr.etcoins >= 30)
       {
        
clientr.etcoins -= 30;
        
addweapon("*Prizes/Juggle");
       }
      else
       {
        
player.chat "Insufficient funds!";
       }
      break;
    }
  }


Get the picture?
Reply With Quote
  #8  
Old 05-19-2007, 05:35 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Gambet View Post
I would probably do so for better organization:
Why not this?
PHP Code:
function purchaseItem(temp.itemID

  switch (
temp.itemID
  { 
    case 
"Juggling"
    {
       if (
clientr.etcoins >= 30
       { 
         
player.clientr.etcoins -= 30
         
player.addweapon("*Prizes/Juggle"); 
       } 
         else 
       { 
         
player.chat "Insufficient funds!"
       } 

       break; 
     } 
  } 


function 
onPlayerChats() 

  
temp.tokens player.chat.tokenize(); 

  if (
temp.tokens[0] == "buy"
  {
    if (
temp.tokens[0in {"Juggling"})
    {
      
this.purchaseItem(player.chat.substring(4));
    }
  }

The clientside does not need to be involved, therefore there is no reason to involve it.
__________________
Skyld
Reply With Quote
  #9  
Old 05-19-2007, 05:38 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Skyld View Post
Stuff



I fixed my post before you posted, your page just wasn't refreshed.


I was trying to find a way to word it correctly and realized I had worded it incorrectly. Fixed it just in time, though
Reply With Quote
  #10  
Old 05-19-2007, 05:45 PM
Deadly_Killer Deadly_Killer is offline
Registered User
Join Date: Feb 2002
Posts: 227
Deadly_Killer is on a distinguished road
PHP Code:
function onCreated() {
  
this.items = {{"Juggling"30"*Prizes/Juggle"}, {"PK Heal"30"*Prizes/PK Heal"}, {"Jump"30"*Prizes/Jump"}, {"Light Mouse"150"*Prizes/Light Mouse"}};
}

function 
onPlayerChats() {
  if (
player.chat.starts("buy")) {
    
temp.item player.chat.substring(4);
    
    for (
temp.var : this.items) {
      if (
temp.item == temp.var[0]) {
        
temp.iteminfo temp.var;
        
        break;
      }
    }
    
    if (
temp.iteminfo != NULL) {
      if (
clientr.etcoins >= temp.iteminfo[1]) {
        
clientr.etcoins -= temp.iteminfo[1];
        
addWeapon(temp.iteminfo[2]);
        
        
player.chat format("You bought %s for %d event coins!"temp.iteminfo[0], temp.iteminfo[1]);
      }
      else 
player.chat format("You require %d event coins for this item!"temp.iteminfo[1]);
    }
  }

or the:
{
}
format

PHP Code:
function onCreated()
{
  
this.items = {{"Juggling"30"*Prizes/Juggle"}, {"PK Heal"30"*Prizes/PK Heal"}, {"Jump"30"*Prizes/Jump"}, {"Light Mouse"150"*Prizes/Light Mouse"}};
}

function 
onPlayerChats()
{
  if (
player.chat.starts("buy"))
  {
    
temp.item player.chat.substring(4);
    
    for (
temp.var : this.items)
    {
      if (
temp.item == temp.var[0])
      {
        
temp.iteminfo temp.var;
        
        break;
      }
    }
    
    if (
temp.iteminfo != NULL)
    {
      if (
clientr.etcoins >= temp.iteminfo[1])
      {
        
clientr.etcoins -= temp.iteminfo[1];
        
addWeapon(temp.iteminfo[2]);
        
        
player.chat format("You bought %s for %d event coins!"temp.iteminfo[0], temp.iteminfo[1]);
      }
        else
      {
        
player.chat format("You require %d event coins for this item!"temp.iteminfo[1]);
      }
    }
  }

__________________
- Zidane / Zidaya
Reply With Quote
  #11  
Old 05-19-2007, 05:48 PM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by Deadly_Killer View Post
Stuff


I avoided doing such since you would only do so assuming everything for each and every item would be the same (I.E, the same chat messages and so forth). Unless everything is going to be the same, you'd have to break it up as I did. Else, your method would be the way to go.


Since he didn't group everything as such, I just took his method and fixed it up.



EDIT: Though now that I think about it, you could set it all up in the arrays, so I guess it would work either way. The only thing you should do is break up your array so it doesn't extend far across the script as such.
Reply With Quote
  #12  
Old 05-19-2007, 05:59 PM
Deadly_Killer Deadly_Killer is offline
Registered User
Join Date: Feb 2002
Posts: 227
Deadly_Killer is on a distinguished road
Quote:
Originally Posted by Gambet View Post
EDIT: Though now that I think about it, you could set it all up in the arrays, so I guess it would work either way. The only thing you should do is break up your array so it doesn't extend far across the script as such.
Widescreen monitor ftw ;D
__________________
- Zidane / Zidaya
Reply With Quote
  #13  
Old 05-19-2007, 07:31 PM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Holy shizzle! I started a scripting war!
__________________
Reply With Quote
  #14  
Old 05-21-2007, 03:00 AM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of lightff7chocoboknight is a glorious beacon of light
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
Where would I put the script to make it work?
__________________
Reply With Quote
  #15  
Old 05-21-2007, 03:42 AM
Gambet Gambet is offline
Registered User
Join Date: Oct 2003
Posts: 2,712
Gambet is on a distinguished road
Quote:
Originally Posted by ff7chocoboknight View Post
Where would I put the script to make it work?


You say you scripted the system to begin with and now you don't know where scripts go? x-x
Reply With Quote
Reply

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 06:35 PM.


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