Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Something I can't figure out... (https://forums.graalonline.com/forums/showthread.php?t=70147)

xAndrewx 11-16-2006 05:32 PM

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? :(

Chompy 11-16-2006 05:38 PM

try something like
PHP Code:

temp.load = {curBiz.curMembers};
if (
temp.load.index(temp.curPlayer) > -1) {
  ...



Skyld 11-16-2006 05:39 PM

Assuming that temp.curBiz.curMembers is an array:
PHP Code:

if (temp.curPlayer.account in temp.curBiz.curMembers)
{
  
// code


... might be slightly more acceptable.

xAndrewx 11-16-2006 05:40 PM

Quote:

Originally Posted by Chompy (Post 1244072)
try something like
PHP Code:

temp.load = {curBiz.curMembers};
if (
temp.load.index(temp.curPlayer) > -1) {
  ...



no fix :[

xAndrewx 11-16-2006 05:40 PM

Quote:

Originally Posted by Skyld (Post 1244073)
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?

Skyld 11-16-2006 05:42 PM

Quote:

Originally Posted by xAndrewx (Post 1244075)
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.

xAndrewx 11-16-2006 05:44 PM

Quote:

Originally Posted by Skyld (Post 1244077)
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 =]

Skyld 11-16-2006 05:45 PM

Quote:

Originally Posted by xAndrewx (Post 1244079)
Thought so
Thanks so much =]

You're welcome.


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.