Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-16-2006, 05:32 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Something I can't figure out...

HTML Code:
function onPlayerChats()
{
  curBiz.loadVars("levels/archtype/businesses/business_" @ this.bizName @ ".arc"); 
  temp.playerChat = player.chat.tokenize();      
  switch(temp.playerChat[0].lower())
  {
    case ":addmember":
      temp.curPlayer = findPlayer(temp.playerChat[1]);
      if (temp.curPlayer == "")
      {
        return false;
      }
      if (curBiz.curMembers.index(temp.curPlayer) >= 0)
      {
        return false; 
      }
      curBiz.curMembers.add(temp.curPlayer);
    break;
           
    default: 
      temp.notSave = true; 
    break;
  }
  if (temp.notSave)
  {
    return false;
  }
  curBiz.saveVars("levels/archtype/businesses/business_" @ this.bizName @ ".arc", 0);  
  chat = curBiz.curMembers;
}
I removed a few things, as most isn't necessary for what is wrong.
Basically, it shouldn't be able to add a member that is already a member. Apparantly, 'if (curBiz.curMembers.index(temp.curPlayer) >= 0)' doesn't seem to be working. Anyone have any clues?
__________________
Reply With Quote
  #2  
Old 11-16-2006, 05:38 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
try something like
PHP Code:
temp.load = {curBiz.curMembers};
if (
temp.load.index(temp.curPlayer) > -1) {
  ...

__________________
Reply With Quote
  #3  
Old 11-16-2006, 05:39 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Assuming that temp.curBiz.curMembers is an array:
PHP Code:
if (temp.curPlayer.account in temp.curBiz.curMembers)
{
  
// code

... might be slightly more acceptable.
__________________
Skyld
Reply With Quote
  #4  
Old 11-16-2006, 05:40 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Chompy View Post
try something like
PHP Code:
temp.load = {curBiz.curMembers};
if (
temp.load.index(temp.curPlayer) > -1) {
  ...

no fix :[
__________________
Reply With Quote
  #5  
Old 11-16-2006, 05:40 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Skyld View Post
Assuming that temp.curBiz.curMembers is an array:
PHP Code:
if (temp.curPlayer.account in temp.curBiz.curMembers)
{
  
// code

... might be slightly more acceptable.
I love you
I guess it was the .account which did it?
__________________
Reply With Quote
  #6  
Old 11-16-2006, 05:42 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xAndrewx View Post
I love you
I guess it was the .account which did it?
It is possible; findPlayer() returns an object of the player, not just the account name. obj.index() might be trying to maintain consistency between datatypes while searching.
__________________
Skyld
Reply With Quote
  #7  
Old 11-16-2006, 05:44 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Skyld View Post
It is possible; findPlayer() returns an object of the player, not just the account name. obj.index() might be trying to maintain consistency between datatypes while searching.
Thought so
Thanks so much =]
__________________
Reply With Quote
  #8  
Old 11-16-2006, 05:45 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xAndrewx View Post
Thought so
Thanks so much =]
You're welcome.
__________________
Skyld
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 01:31 AM.


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