Author Topic: How would I, client-sidedly, see if a player is near me?  (Read 1671 times)

I need a code snippet to do a code if a player is infront of me, client-sidedly. Please help.

for(%i=0;%i<ServerConnection.getCount();%i++) {
                %obj=ServerConnection.getObject(%i);
                if(%obj.getClassName()$="Player") {
                        %temp=%obj.getShapeName();
                        if(%obj==ServerConnection.getControlObject()) {
                                %ownPos=getWords(%obj.getTransform(), 0, 2);
                        }
                }
        }

We meet again Alchemy er whatever your IGN is..
I hope this helps

for(%i=0;%i<ServerConnection.getCount();%i++) {
                %obj=ServerConnection.getObject(%i);
                if(%obj.getClassName()$="Player") {
                        %temp=%obj.getShapeName();
                        if(%obj==ServerConnection.getControlObject()) {
                                %ownPos=getWords(%obj.getTransform(), 0, 2);
                        }
                }
        }

We meet again Alchemy er whatever your IGN is..
I hope this helps
so do i just put my code below %ownpos=getWords(%obj.getTransform(),0,2); ?

for(%i=0;%i<ServerConnection.getCount();%i++) {
                %obj=ServerConnection.getObject(%i);
                if(%obj.getClassName()$="Player") {
                        %temp=%obj.getShapeName();
                        if(%obj==ServerConnection.getControlObject()) {
                                %ownPos=getWords(%obj.getTransform(), 0, 2);
                        }
                }
        }

We meet again Alchemy er whatever your IGN is..
I hope this helps
Too bad this doesn't work

you cannot get client's position without doing stuff with the DataBlock, I don't think Badspot wants people to know anything about it.

for(%i=0;%i<ServerConnection.getCount();%i++) {
                %obj=ServerConnection.getObject(%i);
                if(%obj.getClassName()$="Player") {
                        %temp=%obj.getShapeName();
                        if(%obj==ServerConnection.getControlObject()) {
                                %ownPos=getWords(%obj.getTransform(), 0, 2);
                        }
                }
        }

We meet again Alchemy er whatever your IGN is..
I hope this helps
I don't get what your trying to do at all
You get all the players names then you get your own position?
« Last Edit: November 04, 2012, 06:26:33 AM by Aide33 »

I don't get what your trying to do at all
You get all the players names then you get your own position?
What he's trying to do?
He's posting in every coding help topic, tries to help with a snippet of code that was never tested doesn't work often contains syntax errors and sometimes has nothing to do with what the op asked.

And he uses this gay horrible formatting.

you cannot get client's position without doing stuff with the DataBlock, I don't think Badspot wants people to know anything about it.
what
Player, not client
Datablocks don't store position, or anything relevent to it
All datablocks are easily listable, both serverside and clientside

Well, I'm surprised no one said it, but you can't get other players' positions client-sidedly. Badspot doesn't want people making aimbots. There are workarounds, but nothing anyone's gonna post on a public forum to be patched. You can get your own position via serverConnection.getControlObject().getPosition(); and you can check what bricks are near you or something that you can get the position of, though.
« Last Edit: November 04, 2012, 03:08:14 PM by Trinick »

Well, I'm surprised no one said it, but you can't get other players' positions client-sidedly. Badspot doesn't want people making aimbots. There are workarounds, but nothing anyone's gonna post on a public forum to be patched. You can get your own position via localClientConnection.getControlObject().getPosition(); and you can check what bricks are near you or something that you can get the position of, though.
ok, i was just making a client-sided vampire mod. but bricks would be fine too, how would i check for bricks near me?

ok, i was just making a client-sided vampire mod. but bricks would be fine too, how would i check for bricks near me?
Well, you have to loop through serverConnection, which holds every single object in the entire server. Obviously, this lags a bit. It's not the best method, you should store the bricks or something. But if there's a lot of bricks, it'll lag when looping through that too. So it's a lose-lose.

Code: [Select]
function getClosestBrick()
{
%myPos = serverConnection.getControlObject().getPosition();
for(%i = 0; %i < serverConnection.getCount(); %i++)
{
%obj = serverConnection.getObject(%i);
if(%obj.getClassname() $= "fxDTSBrick")
{
%distance = vectorDist(%obj.getPosition(),%myPosition);
if(%distance < %closestDist || %closestDist $= "")
{
%closestDist = %distance;
%closestBrick = %obj;
}
}
}
return %closestBrick;
}

-snip-

you can't get other players' positions client-sidedly. Badspot doesn't want people making aimbots. There are workarounds, but nothing anyone's gonna post on a public forum.
« Last Edit: November 04, 2012, 09:24:36 PM by Ipquarx »

pffffffAAAAAHAHahHAHhAHhAh
hahaha
ha....

Why are you laughing, he is right.

pffffffAAAAAHAHahHAHhAHhAh
hahaha
ha....

no but in all seriousness they actually do
I think you're confused, the object stores their position but the datablock doesn't.

Why are you laughing, he is right.
i was meaning the instance containing the datablock
but yeah it wasnt worded the best i'll edit that