Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Clientsided Server-Interaction Reference
- ! Important notes will be presented like this
- # Working code will be presented like this
- ##
- Code blocks will be surrounded by two hash symbols
- ##
- == Subject breaks will be presented like this
- == ServerConnection
- ! ServerConnection is a GameConnection object that is spawned when you join a server and it is the main focus
- Useful methods:
- GameConnection::getControlObject() - returns the object you are controlling (usually player)
- GameConnection::getCount() - The amount of objects currently ghosted to your client
- GameConnection::getObject(index) - returns an object of the given index
- ! Every object that is ghosted to your client is part of this group. Every brick. Every emitter. Everything.
- Example (returns closest brick):
- ##
- %myPosition = ServerConnection.getControlObject().getPosition();
- for(%i = 0; %i < ServerConnection.getCount(); %i++)
- {
- %object = ServerConnection.getObject(%i);
- if(%object.getClassname() $= "fxDTSBrick")
- {
- %position = %object.getPosition();
- %distance = vectorDist(%myPosition, %position);
- if(%distance < %closestDistance || %closestDistance $= "")
- {
- %closestDistance = %distance;
- %closestBrick = %object;
- }
- }
- }
- ##
- ! Some objects such as players and projectiles may not have their positions retrieved client-side through getPosition. This is to prevent aimbots and such.
- == Aiming
- Aiming is usually done through two variables:
- $mvYaw - (-3.14159) through 3.14159
- $mvPitch - (-3.14159) through 3.14159
- ! $mvYaw and $mvPitch accept radians not 0-360 degree euler rotational values. Use eulerToAxis and axisToEuler to convert.
- ! Entering values outside their domain will result in limitation.
- Aiming code is given here, just provide position to aim at:
- ##
- function aimAtPos(%pos)
- {
- %player = serverConnection.getControlObject();
- %fv = %player.getMuzzleVector(0);
- %x = getWord(%fv,0);
- %y = getWord(%fv,1);
- %vv = vectorNormalize(vectorSub(%pos,%player.getPosition()));
- %xx = getWord(%vv,0);
- %yy = getWord(%vv,1);
- $mvYaw = mATan(%xx,%yy)-mATan(%x,%y);
- $mvPitch = mATan(getWord(%fv,2),mSqrt(%x*%x+%y*%y))-mATan(getWord(%vv,2),mSqrt(%xx*%xx+%yy*%yy));
- }
- ##
- ! It may be necessary to run this twice to ensure proper alignment.
- == Movement / Interaction
- Movement is done through functions or variables:
- $mvForwardAction - Boolean - Move forward
- $mvBackwardAction - Boolean - Move backward
- $mvRightAction - Boolean - Move right
- $mvLeftAction - Boolean - Move left
- $mvTriggerCount2 - Boolean - Jump
- $mvTriggerCount3 - Boolean - Crouch
- $mvTriggerCount4 - Boolean - Jet
- $mvTriggerCount0 - Boolean - Fire main weapon
- $mvTriggerCount1 - Boolean - Fire alt. weapon
- moveForward() - Boolean - Move fowrad
- moveBackward() - Boolean - Move backward
- moveLeft() - Boolean - Move left
- moveRight() - Boolean - Move right
- Jump() - Boolean - Jump
- Crouch - Boolean - Crouch
- Jet() - Boolean - Jet
- mouseFire() - Boolean - Fire main weapon
- altTrigger() - Boolean - Fire alt. weapon
- ! All of these are toggleable boolean values, the following are valid:
- ## $mvForwardAction = true;
- ## $mvForwardAction = false;
- ## Jet(1);
- ## Jet(0);
- == Building
- Building can be done through server commands or clientside functions. I perfer server commands:
- shiftBrick - Vector (3-arguments) - Shift the brick normally
- superShiftBrick - Vector (3-arguments) - Super Shift the brick
- rotateBrick - Integer - Amount of times to rotate the brick (negative for rotating left)
- plantBrick - Void - Plant the brick. No argument required.
- ! The following can be used through this method:
- commandToServer('serverCommandHere', "arguments", "go", "here");
- ! serverCmdShiftBrick and serverCmdSuperShiftBrick both use 3 arguments, like so:
- # commandToServer('shiftBrick', 0, 0, 3);
- == Credits / Contact Me
- Slicksilver555
- Centhra Game Design, etc.
- If you believe I have forgotten anything or improperly stated something, or any reason at all you want to contact me, please use the above method. Other methods such as Private Messages are not guaranteed to reach me.
Advertisement
Add Comment
Please, Sign In to add comment