Author Topic: Forcing a player to equip a brick?  (Read 1126 times)

How do you make a player equip a brick to build with?

Not sure what your asking.

Can you be more specific?

Like, for a script that makes you build something, how do I make a player use a certain brick?

trace(1);
Equpt brick
trace(0);
Observe

i think that's client sided though, for the brick cart
or do you mean which brick they're actualy currently building with? like their ghost brick?

serverCmdUseInventory(%client, %id) IIRC

I prefer servercmdinstantusebrick(%client, %brickdatablock);

I prefer servercmdinstantusebrick(%client, %brickdatablock);
is there a way to get the brick that you're looking at clientsided?
like...
commandtoserver('instantusebrick', getLookingAtBrick());

is there a way to get the brick that you're looking at clientsided?
like...
commandtoserver('instantusebrick', getLookingAtBrick());

It is simple serversided

Clientsided not so much.
My preferred method of isolating bricks through the client is the way I did it in the buildbot duplicator, where you use your ghostbrick to select the brick you want.

Code: [Select]
if(!isobject(serverconnection))

{

echo("Warning! You are not connected to a server.");

return 0;

}


if(!isobject(%pl = serverconnection.getcontrolobject()))
{
echo("Warning! You are not spawned.");
return 0;
}
%group = %pl.getgroup(); //I'm sure there is a better way, but meh.

%ppos = %pl.getposition();

for(%a=0; %a<%group.getcount(); %a++)

{

if((%b=%group.getobject(%a)).getclassname() $= "fxDTSBrick")

{

if(%b.isplanted() $= "0")

{

%gdist = vectordist(%b.getposition(), %ppos);

if(%gdist < %bestgdist || %bestgdist $= "")
{
%bestgdist = %gdist;
%ghost = %b;
}
}

}

}


if(%ghost $= "")
{
echo("No ghost bricks were found!");
return 0;
}
%pos = %ghost.getposition();

for(%a=0; %a<%group.getcount();  %a++)

{

if((%b=%group.getobject(%a)).getclassname() $= "fxDTSBrick" && %b.isplanted())

{

if(!$buildbot::dupfilter || %b.getdatablock() == %ghost.getdatablock())
{
%bpos = %b.getposition();

%dist = vectorDist(%pos, %bpos);

if(%dist < %bestdist || %bestdist $= "")
{

%bestdist = %dist;

%bestid = %b;

}
}

}

}


if(%bestid $= "")
{
echo("No bricks were found.");
return 0;
}

once you have the brick it should be super simple to get the datablock

I think there is also a client sided function that gets the point that you are looking at, but I already forgot it
« Last Edit: March 14, 2012, 06:26:50 PM by Nexus »

damn that's big, i'll have to start figuring out how it works :D
I think there is also a client sided function that gets the point that you are looking at, but I already forgot it
aww, that'd be very useful
« Last Edit: March 14, 2012, 07:07:47 PM by phflack »

damn that's big, i'll have to start figuring out how it works :Daww, that'd be very useful
you can get your players coordinates, and you can get the direction they're looking, and you can get the distance between the eye point and the target

serverConnection.getcontrolob ject()

Don't know about the angle, but I'm positive it's possible

getFocusDistance()

then math

aww, that'd be very useful

you can get your players coordinates, and you can get the direction they're looking, and you can get the distance between the eye point and the target

serverConnection.getcontrolob ject()

Don't know about the angle, but I'm positive it's possible

getFocusDistance()

then math

yea that

although realize that that alone doesn't get the brick, it just is another way to help figure out where to start looking for the brick.

If you want a brief explanation of how the code works:

1. Set groups to look through
2. Search through group to find ghostbricks
3. Identify nearest ghostbrick (keep in mind nearest =/= yours)
4. Use position of nearest ghostbrick to find nearest planted brick
5. gat

you can get positions of bricks clientsided? the forget

you can get positions of bricks clientsided? the forget

It is a requirement for saving the bricks, yes.

so, you can search through the brick groups based on position? handy
also, does this mean that you can get a specific position based on where the camera is pointing? at the ground/bricks/air (with a max distance)