Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-09-2012, 01:28 AM
iCoke iCoke is offline
Registered User
Join Date: Jun 2012
Posts: 5
iCoke is on a distinguished road
Help me please

Hello, I posted it here because I didnt see anywere else to post it, but anyways I need help with this script. The problem is there is a syntax error.

Script:

function onPlayerchats()
{
if (player.chat == "/open")
{
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
  #2  
Old 09-09-2012, 01:35 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Quote:
Originally Posted by iCoke View Post
Hello, I posted it here because I didnt see anywere else to post it, but anyways I need help with this script. The problem is there is a syntax error.

Script:

function onPlayerchats()
{
if (player.chat == "/open")
{
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 are missing a }. Should style it, makes those type of errors obvious and makes things just generally easier to read.

PHP Code:
function onPlayerchats(){
  if (
player.chat == "/open"){
    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");
    }
  } 
__________________
-Ph8
Reply With Quote
  #3  
Old 09-09-2012, 02:03 AM
iCoke iCoke is offline
Registered User
Join Date: Jun 2012
Posts: 5
iCoke is on a distinguished road
Now it says

"missing ] after element list"
Reply With Quote
  #4  
Old 09-09-2012, 02:18 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
try using something like this:
PHP Code:
function onPlayerchats(){
  if (
player.chat == "/open"){
    if (!(
"-Bank/Account" in player.weapons)){
      
say2("You already have a bank account");
    }
    else{
      
say2("You have opened a bank account!");
      
player.addWeapon("-Bank/Account");
    }
  } 

__________________
MEEP!
Reply With Quote
  #5  
Old 09-09-2012, 03:25 AM
iCoke iCoke is offline
Registered User
Join Date: Jun 2012
Posts: 5
iCoke is on a distinguished road
Nope not working :O :'(... I wonder why?
Reply With Quote
  #6  
Old 09-09-2012, 03:31 AM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
if you are trying this in the offline editor, ignore the errors there and upload it. the offline editor just debugs that for the GS1 scripts, not GS2
__________________
MEEP!
Reply With Quote
  #7  
Old 09-09-2012, 04:09 AM
iCoke iCoke is offline
Registered User
Join Date: Jun 2012
Posts: 5
iCoke is on a distinguished road
Im not, I am putting it on as a "Weapon" on a server.
Reply With Quote
  #8  
Old 09-09-2012, 05:06 AM
Starfire2001 Starfire2001 is offline
Unholy Nation
Starfire2001's Avatar
Join Date: Dec 2010
Location: The streets.
Posts: 156
Starfire2001 will become famous soon enough
Quote:
Originally Posted by iCoke View Post
Im not, I am putting it on as a "Weapon" on a server.
onPlayerChats doesn't work serverside in weapons, so you have to make the script you have clientside. However you can't add weapons to the player clientside, so you are going to have to use triggerserver to add the weapon. If you don't know anything about triggering try this thread.

http://forums.graal2001.com/forums/s...ad.php?t=84321

Using callimuc's script, you'll end up with something like...

PHP Code:
function onActionserverside(){
  
//add the weapon
}

//#CLIENTSIDE
function onPlayerchats(){
  if (
player.chat == "/open"){
    if (!(
"-Bank/Account" in player.weapons)){
      
say2("You already have a bank account");
    }
    else{
      
say2("You have opened a bank account!");
      
//triggerserver goes here
    
}
  } 

__________________
-Ph8
Reply With Quote
  #9  
Old 09-09-2012, 03:20 PM
iCoke iCoke is offline
Registered User
Join Date: Jun 2012
Posts: 5
iCoke is on a distinguished road
So would it be like this?

Script:

PHP Code:
function onActionserverside(){
  
//add the weapon
}

//#CLIENTSIDE
function onPlayerchats(){
  if (
player.chat == "/open"){
    if (!(
"-Bank/Account" in player.weapons)){
      
say2("You already have a bank account");
    }
    else{
      
say2("You have opened a bank account!");
      
//// This is my clientside part of the script.
//#CLIENTSIDE
function onCreated() {
  
this.myatm "myatm.png";
  
triggerserver("png"this.name"myatm.png"this.myatm);
}
    }
  } 

Last edited by iCoke; 09-09-2012 at 06:04 PM..
Reply With Quote
  #10  
Old 09-09-2012, 04:08 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
Please wrap your code in [PHP] tags when you post here. That way it's formatted nicely (look at callimuc and Starfire2001's posts). I have to strain to read the code you're posting because there's no indentation.
__________________
Reply With Quote
  #11  
Old 09-09-2012, 07:06 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by iCoke View Post
So would it be like this?

Script:

PHP Code:
function onActionserverside(){
  
//add the weapon
}

//#CLIENTSIDE
function onPlayerchats(){
  if (
player.chat == "/open"){
    if (!(
"-Bank/Account" in player.weapons)){
      
say2("You already have a bank account");
    }
    else{
      
say2("You have opened a bank account!");
      
//// This is my clientside part of the script.
//#CLIENTSIDE
function onCreated() {
  
this.myatm "myatm.png";
  
triggerserver("png"this.name"myatm.png"this.myatm);
}
    }
  } 
maybe you should start with more basic stuff
__________________
MEEP!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 12:41 PM.


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