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-04-2009, 07:55 AM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
Post Help with bank script.

Ok, so I started making this bank script and I got a little confused.

Basically when you walk into a bank, you say '/create account' and when you say that, it adds a weapon called '-Bank/Account' to your attributes. Im trying to set it to where if you already have a bank account and you say '/create account' and you have the weapon '-Bank/Account' in your attributes already, it will say2 You already have a bank account. Here is what I have so far.

PHP Code:
//#CLIENTSIDE
function onPlayerchats()
{
if (
player.chat="/open account")
{
if (
hasweapon(-Bank/Account))
say2 You already have a bank account!;
}
else if (
player.chat="/open account")
{
say2 You have created a bank account!;
player.addWeapon("-Bank/Account");
 }

If you know the problem, please reply and tell me so I can finish this system.

Thanks alot

-Jamerson =]
Reply With Quote
  #2  
Old 07-04-2009, 08:00 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
First off, addweapon can only be done serverside, depending on if this is a level npc, or another weapon npc, you might just want to make the entire script serverside.

For detecting player chat, use if (player.chat == "chat")
One = sign denotes changing the variable.

And you shouldnt mix gs1 with gs2.
PHP Code:
say2 You already have a bank account!; 
should be
PHP Code:
say2("You already have a bank account!"); 
And for detecting if a player already has the weapon, you can use
PHP Code:
if (player.weapons.index(findweapon("Weapon Name")) > 0
Since if the player has the weapon, its index in the player.weapons array would be more than 0.

And you dont need to check the players chat again if the player doesnt have the weapon.
A simple "else" statement would do.


Edit: And i just read that the script is in the bank level, so you should just make the entire script serverside (Remove //#CLIENTSIDE), and it would work.
__________________

Reply With Quote
  #3  
Old 07-04-2009, 08:03 AM
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
An easier way to do what Jazz said about finding if they have the weapon would be

PHP Code:
if (("Weapon Name") != null) {
  
// code here

or even

PHP Code:
if (findWeapon("Weapon Name") != null) {
  
// code here

though the findWeapon is technically unneeded.
__________________
Reply With Quote
  #4  
Old 07-04-2009, 08:06 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
I actually never thought of doing it that way.

I started detecting weapons my way when I saw it done on a friends server, and always used that method, since it worked.

Altho, i've seen alot of worse methods to detect it...I'll probably start doing it that way. Thanks. ;]
__________________

Reply With Quote
  #5  
Old 07-04-2009, 08:13 AM
[email protected] jamerson61894@yahoo.com is offline
Banned
Join Date: Jul 2008
Posts: 83
jamerson61894@yahoo.com is an unknown quantity at this point
so is this right?


function onPlayerchats()
{
if (player.chat == "/open account")
{
if (player.weapons.index(findweapon("-Bank/Account")) > 0)
{
say2("You already have a bank account");
}
else
say2("You have opened a bank account!");
player.addWeapon("-Bank/Account");
}
}
Reply With Quote
  #6  
Old 07-04-2009, 08:15 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
PHP Code:
function onPlayerchats()
{
  if (
player.chat == "/open account")
  {
    if (
player.weapons.index(findweapon("-Bank/Account")) > 0
    {
      
say2("You already have a bank account");
    }
    else
    {
      
say2("You have opened a bank account!");
      
player.addWeapon("-Bank/Account");
    }

You should use php tags for your code, and styling the code makes it easier to read.

And you were also missing an opening bracket in your else statement.
__________________

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 11:21 AM.


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