Author Topic: Player function.  (Read 2335 times)

Well Randy's isn't working.

Typically, wouldn't you see a function like this as Player::Grow(%this,%obj,%max) ?

I would just do it this way.  I just tested this in my own server and it works beautifully.  I'll be keeping this as one of my random tidbits of code.  Thanks for the idea, here's some code in return.

:cookieMonster:

Btw, the basic form to call the method through the chat HUD is:

/scaleplayer <name> <x> <y> <z>

The method will do partial name match, but if you enter a string that matches the names of two players (e.g. 'John' for John or Johnson), the player with the lowest client object ID will see the effects of the method call.

Code: [Select]
function serverCmdScalePlayer(%client,%namestring,%x,%y,%z)
{
if(%client.isAdmin || %client.isSuperAdmin)
{
if(%x <= 100 && %y <= 100 && %z <= 100 && %x >= 0.1 && %y >= 0.1 && %z >= 0.1)
{
%scale = %x SPC %y SPC %z;
}
else
{
%scale = "1 1 1";
}

%victim = findClientByName(%namestring);
scaleObject(%victim.Player,%scale);
}
}

function scaleObject(%obj,%scale)
{
if(isObject(%obj))
{
cancel(%obj.scalesched);
%obj.scalesched = "";
%repeat = 0;

for(%i = 0; %i < 3; %i++)
{
if(getWord(%obj.getScale(), %i) <= getWord(%scale,%i) - 0.25)
{
%scale[%i] = getWord(%obj.getScale(), %i) + 0.25;
%repeat = 1;
}
else if(getWord(%obj.getScale(), %i) >= getWord(%scale,%i) + 0.25)
{
%scale[%i] = getWord(%obj.getScale(), %i) - 0.25;
%repeat = 1;
}
else
{
%scale[%i] = getWord(%obj.getScale(), %i);
}
}

%obj.setScale(%scale[0] SPC %scale[1] SPC %scale[2]);

if(%repeat)
{
%obj.scalesched = schedule(25,0,"scaleObject",%obj,%scale);
}
}
}
« Last Edit: October 07, 2007, 06:51:30 AM by Trader »

Apparently (I only found this yesterday) the loop through the client list isn't needed, just "%cl = findclientbyname(%namestring);" will do the same job.

Nice, I'll modify the above code.