force a diffrent playertype using code

Author Topic: force a diffrent playertype using code  (Read 1654 times)

so uh yeah I need some help with making a player be forced to change into a diffrent playertype kinda like this
Code: [Select]
%client.player.setNodeColor(lhand, "0.6, 0, 0 1");except it's like client player setplayertype or idk

 It’s player.setDatablock();

what's the difference between changeDataBlock and setDataBlock

I suspect one is for the event
not entirely sure though

I suspect one is for the event
not entirely sure though
one is for the event since setDatablock isnt limited to players only

Code: [Select]
function Player::ChangeDataBlock(%player, %data, %client)
{
if (!isObject(%data))
{
return;
}
%oldData = %player.getDataBlock();
if (%data.getId() == %oldData.getId())
{
return;
}
%player.playThread(3, root);
if (%oldData.canRide && !%data.canRide)
{
if (%player.getObjectMount())
{
%player.getDataBlock().doDismount(%player, 1);
}
}
%player.setDatablock(%data);
%image = %player.getMountedImage(0);
if (%image)
{
if (%image.getId() == %oldData.brickImage.getId() && %oldData.brickImage.getId() != %data.brickImage.getId())
{
%player.mountImage(%data.brickImage, 0);
}
}
if (isObject(%player.client))
{
commandToClient(%player.client, 'ShowEnergyBar', %data.showEnergyBar);
}
}

it's probably better to use changeDataBlock
it seems like it handles things better

It simply is limited for the purpose of events and only works for players. I would use setDatablock personally and use my own checks to make sure it's not loving up such as ensuring the object exists etc.

Edit: Oops didn't realize I bumped this by that much. Oh well, it's all reference for searches anyways.