Blockland Forums > Modification Help
How do I tell if a specific playertype is currently in use on the server
YourBuddyBill:
Good call, Treynolds. How about if there's no player using a given datablock? What should I do for that?
Treynolds416:
--- Quote from: YourBuddyBill on June 19, 2012, 02:16:00 PM ---Good call, Treynolds. How about if there's no player using a given datablock? What should I do for that?
--- End quote ---
What do you mean? What do you want to happen if it's the playertype you're looking for, and what do you want to have happen if nobody is using it? You can also separate this into a different function, like this:
--- Code: ---function someoneIsUsingThisDataBlock(%datablock)
{
for(%i=0;%i<clientGroup.getCount();%i++)
{
%obj = %clientGroup.getObject(%i).player;
if(isObject(%obj) && %obj.getDataBlock() $= "%datablock")
return true;
}
return false;
}
--- End code ---
And you can then use lines like if(someoneIsUsingThisDataBlock("dataBlockName")) or if(!someoneIsUsingThisDataBlock("dataBlockName"))
YourBuddyBill:
--- Quote from: Treynolds416 on June 19, 2012, 02:22:17 PM ---What do you mean? What do you want to happen if it's the playertype you're looking for, and what do you want to have happen if nobody is using it? You can also separate this into a different function, like this:
--- Code: ---function someoneIsUsingThisDataBlock(%datablock)
{
for(%i=0;%i<clientGroup.getCount();%i++)
{
%obj = %clientGroup.getObject(%i).player;
if(isObject(%obj) && %obj.getDataBlock() $= "%datablock")
return true;
}
return false;
}
--- End code ---
And you can then use lines like if(someoneIsUsingThisDataBlock("dataBlockName")) or if(!someoneIsUsingThisDataBlock("dataBlockName"))
--- End quote ---
Cool, thanks! I want it for a server mod where the server (nicknamed Ted) will every now and again decide to boost a player, and he'll change their datablock to the first datablock in the list that isn't in use and then modify their stats depending on the type of boost. Like the "Lord of Leaping" would get higher jumps and less fall dmg.
jes00:
--- Quote from: Treynolds416 on June 19, 2012, 02:22:17 PM ---What do you mean? What do you want to happen if it's the playertype you're looking for, and what do you want to have happen if nobody is using it? You can also separate this into a different function, like this:
--- Code: ---function someoneIsUsingThisDataBlock(%datablock)
{
for(%i=0;%i<clientGroup.getCount();%i++)
{
%obj = %clientGroup.getObject(%i).player;
if(isObject(%obj) && %obj.getDataBlock() $= "%datablock")
return true;
}
return false;
}
--- End code ---
And you can then use lines like if(someoneIsUsingThisDataBlock("dataBlockName")) or if(!someoneIsUsingThisDataBlock("dataBlockName"))
--- End quote ---
Umm, shouldn't the %datablock in if(isObject(%obj) && %obj.getDataBlock() $= "%datablock") not be in quotes?
Treynolds416:
--- Quote from: jes00 on June 19, 2012, 02:36:31 PM ---Umm, shouldn't the %datablock in if(isObject(%obj) && %obj.getDataBlock() $= "%datablock") not be in quotes?
--- End quote ---
What the hell do you think
He isn't that bad at scripting, you don't need to try to pick out every little thing that isn't exactly perfect in an obvious example. This isn't the first time I've seen you do something like this.