Author Topic: /Warp on bricks  (Read 1258 times)

I have decided to make a /warpbrick cmd that works like /warp, but works with bricks. Here is what I have so far:
Code: [Select]
function serverCmdWarpBrick(%client)
{
if(%client.isAdmin)
{
%raycast = containerRayCast(%client.player.getEyePoint(),vectorAdd(%client.player.getEyePoint(),vectorScale(%client.player.getEyeVector(),200)),$TypeMasks::FxBrickObjectType);
if(isObject(%raycast))
{
%pos = posFromRaycast(%raycast);
%pos2 = %pos;
while(containerBoxEmpty($TypeMasks::FxBrickObjectType,%pos2,%client.player.getWorldBox) == 1)
{
%pos2 = %pos;
%pos2 = vectorAdd(%pos,getRandom(-3,3) SPC getRandom(-3,3) SPC getRandom(-3,3));
}
%client.player.position = %pos2;
}
}
}

I want it to send the player to the position of the raycast, but not halfway inside of the brick. Thats where the while statement comes in. If a brick is within the size of the world box of the player, then it generates a random position around the raycast position until a brick is no longer within the box. I have tried this in-game, but I either end up within the brick, or my game crashes. What am I doing wrong?

Er, if you know the object id and position of a brick you shouldn't have to randomly move the player around forever until it coincidentally stands on top of the brick. You can just calculate it using the position and size ...

Er, if you know the object id and position of a brick you shouldn't have to randomly move the player around forever until it coincidentally stands on top of the brick. You can just calculate it using the position and size ...
I'm not exactly trying to place them on top of the brick. Just where the raycast hits and not within the brick.


Also doing player.position isn't going to move the player for anyone but the non-dedicated host.
Use player.setTransform(stuff)

Also doing player.position isn't going to move the player for anyone but the non-dedicated host.
Use player.setTransform(stuff)
Oh alright, thanks.

This:
Code: [Select]
if(%client.isAdmin || %client.isSuperAdmin)

This:
Code: [Select]
if(%client.isAdmin || %client.isSuperAdmin)

More often than not a super admin will also have isAdmin set to true.

More often than not a super admin will also have isAdmin set to true.
I don't think I've ever seen this happen. It would be best to check with what was in Plornt's post.

I don't think I've ever seen this happen. It would be best to check with what was in Plornt's post.

It has always been the case that a super admin also has admin. Any mod that doesn't follow this is incorrect.

I don't think I've ever seen this happen. It would be best to check with what was in Plornt's post.
isAdmin == 1 and isSuperAdmin == 1 when super admin.

Any answers related to my problem?

Could you possibly move the player slightly higher then the brick? Though you'd have to make it about 9 studs higher then the brick its still better then spawning inside the brick.

Could you possibly move the player slightly higher then the brick? Though you'd have to make it about 9 studs higher then the brick its still better then spawning inside the brick.
Its not spawning you inside of the brick. When you type the command, it shoots out a raycast from your line of sight. Once the raycast hits a brick, your player is transported to the position of the raycast, which puts your body halfway inside of the brick. I am trying to get it to place your body in a position around the raycast where you are not overlapping a brick.

Its not spawning you inside of the brick. When you type the command, it shoots out a raycast from your line of sight. Once the raycast hits a brick, your player is transported to the position of the raycast, which puts your body halfway inside of the brick. I am trying to get it to place your body in a position around the raycast where you are not overlapping a brick.
Try calculating the brick's height from attributes of its datablock.