Author Topic: Finding player to plant a brick  (Read 926 times)

How would I make it so that whenever I place a brick, it plants where a different player is?
I tried a code but it didn't work, and when I thought about it I wasn't able to think of anything
that could work.

This is mostly for coding practice, thanks.


Could we see the code?
Alright
Code: [Select]
serverCmdShiftBrick(findClientByName("Radiowave"), findClientByName("Radiowave").player);

So obviously there's multiple errors in this. I can see for myself.
And I also tried player.position and stuff like that to make sure
it wouldn't work. Now all I can think of is some mathematical problem
to make this work, and I don't even know what that would be.

You want to plant a brick at the position of another player?

You want to plant a brick at the position of another player?
Yes

if(isObject(%pl = (%cl = findClientByName("Radiowave")).player) && isObject(%temp = %pl.tempbrick))
    %temp.setTransform(vectorAdd(%pl.getPosition(), "0 0 "@%temp.getDatablock().brickSizeZ / 10) SPC getWords(%pl.getTransform(), 3, 6));

If you already understand that, well done. You're amazing. If not, then there's no shame involved, that's a lot of stuff happening in a very small space.

Let's break it down into something more manageable.


%cl = findClientByName("Radiowave");   //Get the client.
%pl = %cl.player;   //Get the client's player.
if(!isObject(%pl)) return;   //There is no player, so we don't want to continue. Exit. Note: This is actually the inverse of the above.
%temp = %pl.tempbrick;   //Get the player's tempbrick.
if(!isObject(%temp)) return;   //No tempbrick, so again, exit.
%shiftZ = "0 0 "@%temp.getDatablock().brickSizeZ;   //If you want the brick to be plantable you'll want to shift it up so the brick doesn't get put inside the ground
%targetTrans = vectorAdd(%pl.getPosition(), %shiftZ) SPC getWords(%pl.getTransform(), 3, 6);   //Add everything together so we know where we want to put the tempbrick
%temp.setTransform(%targetTrans);   //Put the brick where we want to put it.


EDIT: @below: So I did.
« Last Edit: December 09, 2013, 03:38:00 AM by Xalos »

%pl.getPosition()

you forgot the parentheses

Alright
Code: [Select]
serverCmdShiftBrick(findClientByName("Radiowave"), findClientByName("Radiowave").player);

also these are the wrong arguments for the function
it's client and then the direction ie: serverCmdShiftBrick(findClientByName("Radiowave"), "0 1 0");