Author Topic: Any way to force consoel commands on a player?  (Read 2641 times)

Change the client side variables $mvMoveForward and $mvMoveBackward to decimal values between 0 and 1 to change speed.
An example clientcmd script would be extremely helpful...
« Last Edit: August 31, 2013, 01:00:46 PM by Gordo12699 »

Server:

function serverCmdTest(%client)
{
     %someArgStuff = "Some Arg Stuff";
     commandToClient(%client,'Test',%someArgStuff);
}

Client:

function clientCmdTest(%someArgStuff)
{
     echo("Client received " @ %someArgStuff);
}

That wouldn't slow down the vehicle, try driving and enabling walk(1); in console
Or just pressing C. You can do the same thing with a vehicle though using maxWheelSpeed.

An example clientcmd script would be extremely helpful...

You can't do this entirely server-sided. The best way would be to make a client-sided add-on to go along with your server script.

EXAMPLE SERVER:
Code: [Select]
CommandToClient(%client,'doMouseFire', true);

EXAMPLE CLIENT:
Code: [Select]
function ClientCmddoMouseFire(%arg)
{
mouseFire(%arg);
}


You can't do this entirely server-sided. The best way would be to make a client-sided add-on to go along with your server script.

EXAMPLE SERVER:
Code:
CommandToClient(%client,'doMouseFire', true);

EXAMPLE CLIENT:
Code:
function ClientCmddoMouseFire(%arg)
{
   mouseFire(%arg);
}


Sorry for being vague Honorabl3, I meant with the lines that BlueToothBoy provided
Or just pressing C. You can do the same thing with a vehicle though using maxWheelSpeed.

That would change every vehicle on the server with that datablock's maxWheelSpeed, If I Recall Correctly.
« Last Edit: August 31, 2013, 01:06:29 PM by Gordo12699 »

Basically, you just need to set a new keybind; once you activate the keybind, it checks some variable keybindToggled and if false, sets $mvMoveForward and $mvMoveBackward to 0.5; if false, to 1. If you need more clarification than this, ask; but hopefully you can figure it out from here.

Also, instead of using if statements, you could use a single switch statement as such:

Code: [Select]
//Keybind stuff up here.
switch(%isToggled)
{
case 0;
    $mvMoveForward = 1;
    %isToggled = 1;
    return;
case 1;
    $mvMoveForward = 0.5;
    %isToggled = 0;
    return;
}

Obviously, you'd need %isToggled to not be a bool for this.

Also, instead of using if statements, you could use a single switch statement as such:

Code: [Select]
//Keybind stuff up here.
switch(%isToggled)
{
case 0;
    $mvMoveForward = 1;
    %isToggled = 1;
    return;
case 1;
    $mvMoveForward = 0.5;
    %isToggled = 0;
    return;
}
Using a switch is pointless if it's going to be so small.
Code: [Select]
//Keybind stuff up here.

if(!%isToggled)
{
$mvMoveForward = 1;
%isToggled = true;
}

else
{
$mvMoveForward = 0.5;
%isToggled = false;
}

Your using incorrect syntax for a switch anyways.
Obviously, you'd need %isToggled to not be a bool for this.
Why not? Looks like a bool to me.

Using a switch is pointless if it's going to be so small.
Code: [Select]
//Keybind stuff up here.

if(!%isToggled)
{
$mvMoveForward = 1;
%isToggled = true;
}

else
{
$mvMoveForward = 0.5;
%isToggled = false;
}

Your using incorrect syntax for a switch anyways.Why not? Looks like a bool to me.
I know it's pretty much pointless, some people just might like a switch statement better. And yes, I figured I had the syntax wrong, I now realize it should be colons and not semi-colons. And yes (again), it is technically a bool, but it is still read as an int, which can have values other than 1 or 0. Not that it really matters, I just wasn't completely sure if you could use an actual bool in a switch statement, as I've never tried.

That would change every vehicle on the server with that datablock's maxWheelSpeed, If I Recall Correctly.
It would, but if you created a new datablock and used %theirVehicle.setDatablock(SameVehicleButSlowed); you can select which vehicle to slow.

So now it just echos the server scripts echo I inputed, can anyone see whats wrong?

Server Scripts
Code: [Select]
package crpg_ChangeGears
{
function Armor::onTrigger(%this,%obj,%slot,%on)
{
%client = %obj.client;

if(%on && %slot == 0) //slot 4 is activated by right clicking
{
commandtoClient(%client,'crpg_ChangeGear');
echo("Server told client to change gears");
}

parent::onTrigger(%this,%obj,%slot,%on);
}
};
activatePackage(crpg_ChangeGears);


Client Scripts
Code: [Select]
function clientcmdcrpg_ChangeGear()
{
if(%isToggled)
{
$mvMoveForward = 0.5;
%isToggled = true;
echo("Client told client to moveforward slowly");
}
else
{
$mvMoveForard = 1;
%isToggled = false;
echo("Client told client to moveforward regularly");
}
}

you misspelled forward in the else statement in the client script

plus %istoggled is not defined anywhere

Fixed the client code for yah, just cause. Added in code to handle moving backwards as well. ;)

Code: [Select]
%isToggled = false; //Set to false initially so that the default movement is full speed.

function clientcmdcrpg_ChangeGear()
{
if(%isToggled)
{
$mvMoveForward = 0.5;
         $mvMoveBackward = 0.5;
%isToggled = true;
echo("Client told client to moveforward slowly");
}
else
{
$mvMoveForward = 1;
         $mvMoveBackward = 1;
%isToggled = false;
echo("Client told client to moveforward regularly");
}
}