![]() |
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. |
You could do something like:
PHP Code:
|
Well this is the script.
PHP Code:
|
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. |
Also try using == for if check statements.
|
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:
|
Hmm its not adding clientr.item.NAME=QUANTITY
|
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.
|
Could someone else help me?
|
PHP Code:
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. |
if ( player.level == "jamerson-shovel.nw" )
= is equals 1 + 1 = 2 == is for comparisons if a is like b if ( a == b ) |
Dusty your script doesn't even add the weapons!
help? |
Quote:
|
Quote:
|
-
[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. |
Quote:
|
LOL'd at the deleted posts.
Jamerson, you may want to make a success rate on this. So maybe try PHP Code:
|
Quote:
|
Remember that random also creates a floating point, so you'd most likely want to check if 'success' was <=1, instead of just == 1. Can also simplify the matter by using int() on the random value.
|
Quote:
|
Hm... I don't remember seeing that before. Oh well! Still better to use <= though, as you can then create higher chances and such.
|
To clarify on what Dusty said, you really should have a player class with some basic item functions, e.g.
PHP Code:
PHP Code:
PHP Code:
Also, you should use player.level.name, not player.level. The former is a string, which is what you want, while the latter is an object. Unfortunately, Graal does some funny stuff which will let that work, but it's poor scripting to do so. |
Quote:
|
Quote:
|
Quote:
|
All times are GMT +2. The time now is 07:50 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.