Quote:
Originally Posted by Equinox
I'm not very good at scripting so...
im trying to make a npc in a shop that takes gralats from you when you say Buy arrows. the script is like this:
if (player.chat=Buyarrows);
(playerdarts += 30);
(tokenize 10);
say2 here you go.;
It gives me the arrows but it does not deduct it from my gralats.
Help please? 
|
This should work:
PHP Code:
function onPlayerChats()
{
if (player.chat == "Buyarrows")
{
player.darts += 30;
player.rupees -= 30;
say2("Here you go!");
}
}
However, that raises another issue. Players will be able to buy darts even if they have no gralats. So you have to add an if statement to check for that.
New Script:
PHP Code:
function onPlayerChats()
{
if (player.chat == "Buyarrows")
{
if (player.rupees >= 30)
{
player.darts += 30;
player.rupees -= 30;
say2("Here you go!");
}
else
{
say2("You do not have enough gralats.");
}
}
}
That ought to stop players from buying arrows when they have no money.
Oh, and that is GS2, not GS1 which you used in your post. GS2 works better, so I suggest you learn that instead. There are some guides for GS2 scripting here:
http://wiki.graal.net/index.php/Creation/Dev/GScript