Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Shovel Script (https://forums.graalonline.com/forums/showthread.php?t=87088)

[email protected] 07-26-2009 05:17 PM

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.

Pelikano 07-26-2009 05:29 PM

You could do something like:

PHP Code:

temp.shoveling_prizes = {"Treasure/Map""Treasure/Chest""Treasure/Key"};
addWeapon(shoveling_prizes[int(random(0,3))]); 


[email protected] 07-26-2009 05:35 PM

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!");



fowlplay4 07-26-2009 05:44 PM

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.

MysticX2X 07-26-2009 05:47 PM

Also try using == for if check statements.

[email protected] 07-26-2009 05:48 PM

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!");



[email protected] 07-26-2009 05:52 PM

Hmm its not adding clientr.item.NAME=QUANTITY

[email protected] 07-26-2009 05:52 PM

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.

[email protected] 07-26-2009 05:55 PM

Could someone else help me?

DustyPorViva 07-26-2009 06:43 PM

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.

ff7chocoboknight 07-26-2009 07:43 PM

if ( player.level == "jamerson-shovel.nw" )

= is equals
1 + 1 = 2

== is for comparisons
if a is like b
if ( a == b )

[email protected] 07-27-2009 12:29 PM

Dusty your script doesn't even add the weapons!

help?

Chompy 07-27-2009 01:53 PM

Quote:

Originally Posted by [email protected] (Post 1510808)
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

cbk1994 07-27-2009 03:29 PM

Quote:

Originally Posted by [email protected] (Post 1510808)
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.

Programmer 07-29-2009 09:02 PM

-
[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.


All times are GMT +2. The time now is 04:13 PM.

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