Author Topic: SetVelocity of Players Speedcart?  (Read 2714 times)

I have a code snippet here:
Code: [Select]
function servercmdVelocity(%client,%x,%y,%z,%name)
{
    %target = %client.player;

if(%client.isAdmin && %name !$= "")
{
%target = findClientByName(%name).player;
}

if(isObject(%target))
{
%target.setVelocity(vectorAdd(%target.getVelocity(),%x SPC %y SPC %z));
}
}
But I'd like it to work with speed carts. Is there a %player.cart object or something similar that I can use? Thanks.

   if(isObject(%target))
   {
      while(isobject(%target.getobjectmount()))
         %target = %target.getobjectmount();
      %target.addVelocity(%x SPC %y SPC %z);
   }

I think it should work
Also no need for the vectoradd

Not having any luck. I've messed with it a little you can see my commented out edits:
Code: [Select]
if(isObject(%target))
{
while(isobject(%target.getobjectmount()))
%target = %target.getobjectmount();
//%target.addVelocity(%x SPC %y SPC %z);
//%target.setVelocity(vectorAdd(%target.getVelocity(),%x SPC %y SPC %z));
%target.setVelocity(%x SPC %y SPC %z);
}
I'm not getting any errors but it doesn't do anything.

Not having any luck. I've messed with it a little you can see my commented out edits:
Code: [Select]
if(isObject(%target))
{
while(isobject(%target.getobjectmount()))
%target = %target.getobjectmount();
//%target.addVelocity(%x SPC %y SPC %z);
//%target.setVelocity(vectorAdd(%target.getVelocity(),%x SPC %y SPC %z));
%target.setVelocity(%x SPC %y SPC %z);
}
I'm not getting any errors but it doesn't do anything.

Post the complete code.

Code: [Select]
function servercmdTTM(%client)
{
%target = %client.player;
%x = 0;
%y = 0;
%z = 9999;

if(%client.isAdmin && %name !$= "")
{
%target = findClientByName(%name).player;
}

if(isObject(%target))
{
while(isobject(%target.getobjectmount()))
%target = %target.getobjectmount();
%target.setVelocity(vectorAdd(%target.getVelocity(),%x SPC %y SPC %z));
}
I think that's it.

You have a syntax error. You never closed the brackets on your if statement on line 13.

Also, you are using the variable %name, but you never defined it.

I think my error lies within my checks:
Code: [Select]
function servercmdTest(%client, %name)
{
%name = "mickers";
if(%client.isAdmin && %name !$= "")
{
//talk(%name);
%target = findClientByName(%name);
//talk(%target.name);
if(%client.isAdmin)
talk("client is admin");
if (%target.isAdmin)
talk("target is admin");
if (%name == "")
talk("name is blank");
else talk("name is not blank");
}
}
I can't execute my script for reason "if(%client.isAdmin && %name !$= "")" always returns 0?

function servercmdTest(%client,%target)
{
    %target=findClientByName(%target);
    if(!isObject(%target))
        return;
    //do what you want
}
« Last Edit: September 19, 2013, 05:31:05 PM by MARBLE MAN »

setVelocity doesn't work on vehicles too well. Use apply impusle.

setVelocity doesn't work on vehicles too well. Use apply impusle.

applyImpulse just calls setVelocity.

Would setLinearVelocity be of any help?

What am I doing wrong here?
Code: [Select]
function servercmdTest(%client, %target)
{
//%name = "mickers";
//%target = findClientByName(%target);
//talk(%target);
if(%client.isAdmin && %target !$= "")
{
//talk(%target);
//talk(%client);

//talk(%target.name);
if(%client.isAdmin)
talk(%client.name SPC "client is an admin");

if (%target.isAdmin)
talk(%target.name SPC "target is an admin");
else
talk(%target.name SPC "target is not an admin");

if (%target == "")
talk(%target.name SPC "name is blank");
else
talk(%target.name SPC "name is not blank");
}
}
If I input "/test test":
Mickers client is an admin,
target is not an admin,
name is blank.

If I input "/test test test":
Mickers client is an admin,
target is not an admin,
name is blank.

If I input "/test mickers":
Mickers client is an admin,
target is not an admin,
name is blank.

If I input "/test mickers mickers":
same stuff...

Why can I not send a target to my function? What am I missing?

Edit:
I'm throwing that code out the window. Using MARBLE MAN's although he has a couple of syntax error he must have overlooked.
« Last Edit: September 19, 2013, 05:09:53 PM by Mickers »

I'm throwing that code out the window. Using MARBLE MAN's although he has a couple of syntax error he must have overlooked.
I forgot a space between function and servercmd