### Trouble getting syntax for Player::getPose()

There are no stupid questions, just stupid answers.

#### Trouble getting syntax for Player::getPose()

Sir_Skurpsalot
Posts: 52
Joined: Tue Jan 28, 2020 6:32 pm
}

#### Re: Trouble getting syntax for Player::getPose()

Duion
Posts: 1602
Joined: Sun Feb 08, 2015 1:51 am

Before you try to make your complicated solution work, you should check if there is an easier solution or if what you are trying to do even makes sense.

First I would say having to cycle through duck, pron and standing is a bad solution, having a key for each is much simpler to use for the player.

Second if you want things to just toggle instead of having to hold down the button, this already exists in the engine, you just have to change it, but Azaezel already told you how that works.

And please try to avoid solutions where you "get player pose" and stuff and make functions based on that, since those things really like to produce glitches and you have to put in "get player pose" functions all over the scripts to avoid those, which just costs you lots of unnecessary work and performance.

So forget everything and just flip it from constant press to toggle as Azaezel said. All the trouble just to save one button is not worth it, modern games just do it because console peasants don't have enough buttons and I just noticed your solution would not even save a button, since to cycle through the positions you need two buttons and that is exactly what you need for duck and prone. So I don't see any advantages in that cycle through solution, it just makes everything more complicated to program and more complicated for the player to use.

#### Re: Trouble getting syntax for Player::getPose()

Sir_Skurpsalot
Posts: 52
Joined: Tue Jan 28, 2020 6:32 pm
Thanks for the responses.
Torque is pretty strange, so as long as you start a function's name with serverCmd you can call it from any script, and it has access to %client?
So the code snippet works, but now that I've got that I want to change it so it returns the pose to the function that called it, but it is not working.
If I change the server function to:
function serverCmdGetPlayerPose(%client)
{
return %client.player.getPose();
}


and then try to:
 echo(commandToserver('GetPlayerPose'));
I get the error:
scripts/client/default.bind.cs (292): Call to commandToServer in stanceDown uses result of void function call.
Why is it void?

#### Re: Trouble getting syntax for Player::getPose()

Azaezel
DEVGRU
Posts: 495
Joined: Tue Feb 03, 2015 9:50 pm

nah, commandoserver('somemethod') + serverCMDsomemethod it's what's known as an RPC or remote protocol command. just a way of saying to your aps conneciton class to transmit 'hey, run this method on the server', tagging methods to start with serverCMD gives it a shorter list of commands to hunt through to find and execute when it that side of the connection goes to figure out what you're requesting it does. there's similar for commandtoclient('SomeMethod2')+clientcmdSomeMethod2 for servers to tell clients to run commands that aren't built direct into the source.

"uses result of void function call" is pretty much what it says on the tin. the commandToserver method in and of itself is not returning anything, just going 'hey, other end of this network, do this'. so to further expand our in/out given the above:
function getMyPose()
{
commandToserver('GetPlayerPose');
}

function serverCmdGetPlayerPose(%client)
{
%pose = %client.player.getPose();
commandToclient(%client,'GotPlayerPose',%pose);
}
function clientcmdGotPlayerPose(%pose)
{
echo("my pose is " @ %pose);
}

which will let you hit ~, plug that
getMyPose()
into the console, and get back your pose even if you're on somebody else's server (provided they have that serverCmdGetPlayerPose defined their end)

#### Re: Trouble getting syntax for Player::getPose()

Duion
Posts: 1602
Joined: Sun Feb 08, 2015 1:51 am

Now if you want to make it even more complicated you implement all methods and let the player chose in options which one he wants to use.

#### Re: Trouble getting syntax for Player::getPose()

fLUnKnhaXYU
Posts: 158
Joined: Wed Nov 15, 2017 8:19 am
using $mvTriggercount4++ , placing the character in prone , if you use the getControlObject().getPose() , or the like , will return " prone " but , if while in prone you also set$mvTriggercount2++ , your character begins jumping and the pose will be "standing" and after another $mvTriggercount2++ (stop jump) will return to "prone" . So . I guess that while prone + jumping that an upPose would not result in crouch yet , a downpose should result in crouch . anybody got change for 2 cents ? Sir_Skurpsalot , I don't know if you can pass arguments to those key bind functions other than the one for %val . I see in the demo that some gamepad binds use "if" statements with serverConnection methods , but I don't have one , and I haven't messed with them . But i cant get serverconnection.getID() so , IDK . #### Re: Trouble getting syntax for Player::getPose() Sir_Skurpsalot Posts: 52 Joined: Tue Jan 28, 2020 6:32 pm Azaezel - ok so return statements do not work with server functions is what you are saying? I found a way to do this without bothering with any server functions, just made a global variable to track pose without actually getting the pose. Any downside to doing it this way from a client-server relation perspective? $pose = "Standing";
function stanceDown(%val)
{
if (%val)
{
if($pose$= "Standing")
{
$mvTriggerCount3++;$pose = "Kneeling";
}
else if ($pose$= "Kneeling")
{
$mvTriggerCount3++;$mvTriggerCount4++;
$pose = "Prone"; } } } function stanceUp(%val) { if (%val) { if($pose $= "Kneeling") {$mvTriggerCount3++;
$pose = "Standing"; } else if ($pose $= "Prone") {$mvTriggerCount4++;
$mvTriggerCount3++;$pose = "Kneeling";
}
}
}

#### Re: Trouble getting syntax for Player::getPose()

Azaezel
DEVGRU
Posts: 495
Joined: Tue Feb 03, 2015 9:50 pm

Azaezel - ok so return statements do not work with server functions is what you are saying?

I found a way to do this without bothering with any server functions, just made a global variable to track pose without actually getting the pose. Any downside
to doing it this way from a client-server relation perspective?
No, I'm saying return statements don't even make sense when you're firing off a command from one machine to another (or mimicking doing so to save yourself migraines down the line trying to hunt down why guy A sees one thing and guy B another). Its a one way communication each way. Hence that middle method from example 2.

In a competitive environment you'll want to lean on the server more as referee. If you don't particularly care about that kinda thing, by all means, do what makes the most sense to you. Personally, I'd probably just alter the source end to cut down on the script kiddies hacking a short circuit into it, but you'd mostly asked about how to parse script, so that's been the focus.

#### Re: Trouble getting syntax for Player::getPose()

Sir_Skurpsalot
Posts: 52
Joined: Tue Jan 28, 2020 6:32 pm
Ok, gotcha. Thanks for the help

#### Who is online

Users browsing this forum: No registered users and 15 guests