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 01-02-2011, 11:37 PM
Twilikari Twilikari is offline
Registered User
Twilikari's Avatar
Join Date: Nov 2010
Location: America
Posts: 86
Twilikari is on a distinguished road
Shop Script help

I found this file saved in my computer, from about a month ago...
Is it any good, or junk? And I am aware that there's a bit of GS1 in there, i'm fixing it up.
PHP Code:
//Shop Script
//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat =="/buy Hikari Mask"); 
     if (
player[INDEX].rupee >= 100) {
      
setplayerprop #P1,hikari-mask.png;
      
player[INDEX].rupee -= 100;
      }
     else {
        
message You don't have enough money!;
      }
    }
  }

And I am aware that this is for one hat, I'm still not sure on how Parameters/tokens work...
Reply With Quote
  #2  
Old 01-02-2011, 11:58 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
junk.

PHP Code:
// Example Flexible Hat Shop Script

function onCreated() {
  
// Define Hat Shop Variables
  
this.hatimg "hat1.png";
  
this.buycmd "/buy hat";
  
this.amount 100;
}

function 
onPlayerChats() {
  
// Check for buy hat command chat.
  
if (player.chat == this.buycmd) {
   
// Check if Player has enough rupees
   
if (player.rupees >= this.amount) {
     
// Remove rupees from Player
     
player.rupees -= this.amount;
     
// Set Player's Hat
     
player.attr[1] = this.hatimg;
   } else {
     
// Player didn't have enough rupees
     // send sign message to player.
     
player.say2("You need " this.amount " rupees!");
   }
  }

Edit: Someone should really expand upon Novo's dialog system and make it more newb-friendly so we see more GUI prompts than chat commands in future servers.
__________________
Quote:
Reply With Quote
  #3  
Old 01-03-2011, 04:07 AM
Twilikari Twilikari is offline
Registered User
Twilikari's Avatar
Join Date: Nov 2010
Location: America
Posts: 86
Twilikari is on a distinguished road
Oh my gawd thanks

next project: figure out how to have a collection of hats(Hat Tool on UN)
Reply With Quote
  #4  
Old 01-03-2011, 04:39 AM
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
On the server-side you can write to player's clientr variables to store information.

PHP Code:
function onPlayerChats() {
  if (
player.chat == "/test") {
    
clientr.test int(random(010));
    
player.chat "clientr.test has been set to " clientr.test;
  }

Here's my quick run-through on Arrays which are useful in managing Collections or Lists of values.

Arrays

PHP Code:
function onCreated() {

  
// Creating an Array
  
this.array = {123};

  
// Reading from an Array (Reading Element in Position 1)
  // Syntax: this.array[element_index]
  // Arrays are 0-based so in our example:
  // this.array[0] is 1
  // this.array[1] is 2
  // this.array[2] is 3
  
temp.element this.array[1];
  echo(
"Element: " temp.element);

  
// Changing a Specific Element in an Array
  
this.array[2] = 3.14;
  
display_array();

  
// Adding to an Array
  
this.array.add(4);
  
display_array();

  
// Removing from an Array
  
this.array.remove(1);
  
display_array();

  
// Inserting into an Array (Inserts 2.5 into Position 1)
  
this.array.insert(12.5);
  
display_array();

  
// Deleting from an Array (Deletes Element in Position 1);
  
this.array.delete(1);
  
display_array();

  
// Combining Arrays
  
temp.newarray = {567};
  
this.array.addarray(temp.newarray);
  
display_array();

  
// Getting the Size / Number of Elements in Array
  
temp.elements this.array.size();
  echo(
"Array contains " temp.elements " elements!");
}

function 
display_array() {
  echo(
"Array: " this.array);

Hint: You can use clientr variables to store arrays of strings/text ("hat.png"), and numbers.
__________________
Quote:
Reply With Quote
  #5  
Old 01-03-2011, 05:59 AM
Twilikari Twilikari is offline
Registered User
Twilikari's Avatar
Join Date: Nov 2010
Location: America
Posts: 86
Twilikari is on a distinguished road
I should marry you. You have seriously no clue how much that helped. Or maybe you do. Thanks
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 06:14 PM.


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