PDA

View Full Version : Something I can't figure out...


xAndrewx
11-16-2006, 05:32 PM
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

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:
if (temp.curPlayer.account in temp.curBiz.curMembers)
{
// code
}
... might be slightly more acceptable.

xAndrewx
11-16-2006, 05:40 PM
try something like

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

no fix :[

xAndrewx
11-16-2006, 05:40 PM
Assuming that temp.curBiz.curMembers is an array:
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
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
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
Thought so
Thanks so much =]
You're welcome.