Author Topic: Object Loops  (Read 1375 times)

I looped an object and tried making it so every client part of the loop gets messaged that they have committed a crime, but when I test it out, nothing happens. There are no errors in the console so it made me confused. Any help would be appreciated:
Code: [Select]
if(%client.hasGang && %client.Gang !$= "")
{
for(%i = 0; %i < %clientCount; %i++)
{
%clientObject = clientGroup.getObject(%i);
%client = %clientObject.client;

%client.RPData.value["demerits"] += mFloor(%dems);
messageClient(%client, 'centerPrint', "\c6You and your gang have commited a crime [\c3" @ %text @ "\c6]", 3);
}
}

I looped an object and tried making it so every client part of the loop gets messaged that they have committed a crime, but when I test it out, nothing happens. There are no errors in the console so it made me confused. Any help would be appreciated:
Code: [Select]
if(%client.hasGang && %client.Gang !$= "")
{
for(%i = 0; %i < %clientCount; %i++)
{
%clientObject = clientGroup.getObject(%i);
%client = %clientObject.client;

%client.RPData.value["demerits"] += mFloor(%dems);
messageClient(%client, 'centerPrint', "\c6You and your gang have commited a crime [\c3" @ %text @ "\c6]", 3);
}
}

First, make sure %clientCount is defined, like so:
Code: [Select]
%clientCount = clientGroup.getCount();
Second, try calling .dump() on %clientObject and %client and see what comes up.

You're also defining the second argument in messageClient incorrectly, that is for message callbacks. if you want to display your message in center print you'll need to use:

Code: [Select]
centerPrint();

Nice try but no dice. I changed the messageClient command to an echo and I didn't get the echo. What could be the problem?

Objects in clientGroup are clients.

%clientObject = clientGroup.getObject(%i);
%client = %clientObject.client;


I'm not sure what you think you're doing here but it's your problem.

%client = clientGroup.getObject(%i);

This is what you want to use to get the client.

I tried that but I'll try it again, thanks.

Don't do that %client.client stuff.