Author Topic: How would you make a player spawn at a named brick?  (Read 1821 times)

As the title suggests, I want to make a player spawn at a named brick, I know roughly it would be done
by using:

Code: [Select]
//code that gets a client

%client.player.position = BrickNameDataGoesHere;

//more code

I'm not too sure on how to get a named brick into a script though.

You need to package GameConnection::getSpawnPoint and return the position/rotation to use.

Use brick groups to get a random brick with the name to spawn at.
You can just use fxDTSBrick::getPosition to get the position to spawn at, but it's very likely that the player will be stuck.

Here's a better way of doing that:
vectorAdd(setWord(<brick>.getPosition(), 2, getWord(<brick>.getWorldBox(), 5)), "0 0 0.1")

Use brick groups to get a random brick with the name to spawn at.
You can just use fxDTSBrick::getPosition to get the position to spawn at, but it's very likely that the player will be stuck.

Here's a better way of doing that:
vectorAdd(setWord(<brick>.getPosition(), 2, getWord(<brick>.getWorldBox(), 5)), "0 0 0.1")

Just use %brick.getSpawnPoint();.

I'm not too sure on how to get a named brick into a script though.
If there's only one brick in the server with that name: _brickname

%client.player.position =
changing an object's position is called through Object.setTransform(<transform>);
a transform can be just a position, or a position and a rotation

changing an object's position is called through Object.setTransform(<transform>);
a transform can be just a position, or a position and a rotation

Actually, you can change a player's position by setting %pl.position = "some position"; - it's a stupid way to do it and you SHOULDN'T do it that way, but it technically works.

If there's only one brick in the server with that name: _brickname

Thanks for the help guys, locking.

 :cookieMonster:

Unlocked, Thanks Xalos for pointing that out.  :cookieMonster:

Actually, you can change a player's position by setting %pl.position = "some position"; - it's a stupid way to do it and you SHOULDN'T do it that way, but it technically works.
why shouldn't you do it? i've found it works fine?

Unlocked, Thanks Xalos for pointing that out.  :cookieMonster:
Yea. You shouldn't lock your topic in case there is either a better solution, or something else.

why shouldn't you do it? i've found it works fine?


function mCube(%val)
{
    return mPow(%val, mFloatLength(mFloor(getSubStr($PI, 0, 1)), 0));
}


Why shouldn't I do it that way? I've found it works fine.


Anyway, the one actual reason I've found for using .setTransform() as opposed to setting .position is that using .setTransform() pushes the update, while setting .position does not. Other than setting rotation, of course.


function mCube(%val)
{
    return mPow(%val, mFloatLength(mFloor(getSubStr($PI, 0, 1)), 0));
}


Why shouldn't I do it that way? I've found it works fine.


Anyway, the one actual reason I've found for using .setTransform() as opposed to setting .position is that using .setTransform() pushes the update, while setting .position does not. Other than setting rotation, of course.
what do you mean by pushes an update? and how is that comparable to setting position? what you've done is a load of unnecessary steps, when there are no unnecessary steps in setting .position; in fact, it's one less step (if you're counting the update as a step)

if you set .position you bypass any mods that packaged .setposition causing you to break mods

bad

what do you mean by pushes an update? and how is that comparable to setting position? what you've done is a load of unnecessary steps, when there are no unnecessary steps in setting .position; in fact, it's one less step (if you're counting the update as a step)

What the forget even is that argument. So you want every player on the server to NOT see the updated position until they either move or turn? Okay then.

"Unnecessary steps" my ass. Are you the kind of person who doesn't mind getting in a Cessna with known engine problems, WITHOUT going through the pre-flight checklist? It's just an unnecessary step!

if you set .position you bypass any mods that packaged .setposition causing you to break mods

bad
thank you. now i understand.
What the forget even is that argument. So you want every player on the server to NOT see the updated position until they either move or turn? Okay then.

"Unnecessary steps" my ass. Are you the kind of person who doesn't mind getting in a Cessna with known engine problems, WITHOUT going through the pre-flight checklist? It's just an unnecessary step!
your argument in that example was "why not just do a bunch of unnecessary steps to cube a number". there are no unnecessary steps in setting .position, but it DOES break the game. fine, i get that now, but your argument was totally invalid, because setting .position takes no unnecessary steps. and i never claimed that you shouldn't update the position; i was pointing out that your argument does not fit the case, because doing it the wrong way (setting .position) is actually one less step than doing it correctly, process wise. (setting position and updating vs setting position)