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 07-26-2009, 05:17 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Shovel Script

Hi, im working on my shovel script still and I am attempting to make it so that when you press d, it shovels, (<--that part alraedy works), and you
randomely get one of 3 weapons. Lets call them "Treasure/Map", "Treasure/Chest", and "Treasure/Key".

Basically, I would like to know how randomely adding a weapon would be dont with int ( random(.

Thanks.
Reply With Quote
  #2  
Old 07-26-2009, 05:29 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
You could do something like:

PHP Code:
temp.shoveling_prizes = {"Treasure/Map""Treasure/Chest""Treasure/Key"};
addWeapon(shoveling_prizes[int(random(0,3))]); 
Reply With Quote
  #3  
Old 07-26-2009, 05:35 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Well this is the script.


PHP Code:
function doAddItems()
{
temp.shoveling_prizes = {"Treasure/Map""Treasure/Chest""Treasure/Key"};
addWeapon(shoveling_prizes[int(random(0,3))]);  
}
//#CLIENTSIDE
function onWeaponFired()
{
if ( 
player.level ="jamerson-shoveling.nw" )
{
setani ven_shovel,NULL;
freezeplayer 1;
doAddItems();
}
else
player.addMsg2("You must be in the shovel room to use shovel!");

Reply With Quote
  #4  
Old 07-26-2009, 05:44 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
Search the forums for examples on how to use triggerserver, and on ActionServerSide.

You need to use them to call your doAddItems function on the serverside.
__________________
Quote:
Reply With Quote
  #5  
Old 07-26-2009, 05:47 PM
MysticX2X MysticX2X is offline
Prince
MysticX2X's Avatar
Join Date: Sep 2005
Posts: 2,529
MysticX2X will become famous soon enough
Also try using == for if check statements.
__________________
-Mystic

former acc: mystic2k


RIP Matt (NBK)
Reply With Quote
  #6  
Old 07-26-2009, 05:48 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
ok I got it to work, but on my systems, we use clientr.item.ITEMNAME=QUANTITY.

How would I get it to add 1 quantity when it adds the weapon? heres what I have right now.


PHP Code:
function onActionServerSidecmd )
{
  switch( 
cmd )
  {
    case 
"shovel":
    {
    
setani jamerson_shovel,NULL;
    
freezeplayer 1;
    
addWeapon(shoveling_prizes[int(random(0,3))]); 
  }
 }
}
//#CLIENTSIDE
function onWeaponFired()
{
if ( 
player.level ="jamerson-shovel.nw" )
{
triggerserver"weapon"name"shovel" );
temp.shoveling_prizes = {"Treasure/Map""Treasure/Chest""Treasure/Key"}; 
}
else
player.addMsg2("You must be in the shovel room to use shovel!");

Reply With Quote
  #7  
Old 07-26-2009, 05:52 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Hmm its not adding clientr.item.NAME=QUANTITY
Reply With Quote
  #8  
Old 07-26-2009, 05:52 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
basically, the quantity is nothing when it adds it to you, and that defeats the purpous of the script because after you make the treasure, you sell it for cash. And quantity counts.
Reply With Quote
  #9  
Old 07-26-2009, 05:55 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Could someone else help me?
Reply With Quote
  #10  
Old 07-26-2009, 06:43 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
PHP Code:
function onActionServerSidecmd )
{
  switch( 
cmd )
  {
    case 
"shovel":
    {
    
temp.shoveling_prizes = {"Treasure/Map""Treasure/Chest""Treasure/Key"}; 
    
findplayer(params[1]) {
      
setani jamerson_shovel,NULL;
      
freezeplayer 1;
      
clientr.item.( @ shoveling_prizes[int(random(0,3))])++;
    }
  }
 }
}
//#CLIENTSIDE
function onWeaponFired()
{
if ( 
player.level ="jamerson-shovel.nw" )
{
triggerserver"weapon"name"shovel",player.account);
}
else
player.addMsg2("You must be in the shovel room to use shovel!");

Should work. On the serverside, it is rare to have a reference to a player since the server deals with all players, so you must pass the account name of the player in the triggerserver() so you can find the player who triggered it, and then deal with them.

Also, if your servers systems are any good they would have a public function for adding items... like:
Inventory.additem(itemname,quantity);
If they don't, get them to add it.
Reply With Quote
  #11  
Old 07-26-2009, 07:43 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
if ( player.level == "jamerson-shovel.nw" )

= is equals
1 + 1 = 2

== is for comparisons
if a is like b
if ( a == b )
__________________
Reply With Quote
  #12  
Old 07-27-2009, 12:29 PM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Dusty your script doesn't even add the weapons!

help?
Reply With Quote
  #13  
Old 07-27-2009, 01:53 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
Dusty your script doesn't even add the weapons!

help?
He suggested that your system should get an additem() function to handle quantity of items ;o
__________________
Reply With Quote
  #14  
Old 07-27-2009, 03:29 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by [email protected] View Post
Dusty your script doesn't even add the weapons!

help?
You need to use player.addWeapon(). Perhaps you should learn the basics of Gscript before you try to script things that involve you coming to the forums and asking how to do everything.
__________________
Reply With Quote
  #15  
Old 07-29-2009, 09:02 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
-
[email protected], I suggest you look through the Graal Wikipedia. It will help you a lot quicker than asking for help here. It may also benefit you to collaborate with another scripter so you can learn more about the language.
__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ

Last edited by Darlene159; 07-30-2009 at 03:22 AM..
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 09:20 PM.


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