Author Topic: How do you make a keybind for a vehicle? spacebar: heli goes up, ect.  (Read 1316 times)

I want to have a helicopter that has 2 keybinds, spacebar for up, and shift for down, Instead of flying like a plane.


Thanks,


Rein
« Last Edit: April 25, 2010, 10:01:54 PM by Reinforcements »

This belongs in suggestions and requests.


He's not even asking for help; he hasn't even tried it. He just wants us to write a script for him :/

I want to have a helicopter that has 2 keybinds, spacebar for up, and shift for down, Instead of flying like a plane.


Thanks,


Rein

Keybinds have to be set clientside. AKA, you can't force the players to keybind Enter to Quit();. If you want to make this, you need an alternative set up for people who manually download it.

Okay, I was looking at the turbo jeep today, is this the piece of code that makes it speed up?



Code: [Select]
function ServerCmdTurbo(%client)
{
%pmount = %client.player.getObjectMount();
if(%pmount.getDataBlock().GetName() $= "TjeepVehicle"){
if(%client.Turbo){
messageclient(%client,"","You do not have Turbo charged.");
return;
}
%vec = %pmount.getForwardVector();
%vec = VectorAdd(%vec, "0 0" SPC 0.0);
%vec = VectorNormalize(%vec);
%vec = VectorScale(%vec, 200);
%pmount.setVelocity(%vec);
%client.Turbo = 1;
schedule(3500,0,"Turboit",%client);
}else{
messageclient(%client,"","You are not in a Turbo Jeep.");
}
}

function Turboit(%client)
{
%client.Turbo = 0;
}

function TjeepVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){
      ServerCmdTurbo(%obj.spawnbrick.client);
  }
   }
}
I think its this one, but wheres the one that when you press spacebar, it speeds up?

I don't know much about scripting... but I believe you can't specifically assign to keys, but can assign it to functions... Eg Jump, Light Toggle, Crouch?

That turbo jeep probably doesn't even work

I don't know much about scripting... but I believe you can't specifically assign to keys, but can assign it to functions... Eg Jump, Light Toggle, Crouch?

Thats EXACTLY what I want! Great!

function TjeepVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){
      ServerCmdTurbo(%obj.spawnbrick.client);
     }
   }
}

When %triggerNum is 2, the spacebar was pressed inside the vehicle.

function TjeepVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){
      ServerCmdTurbo(%obj.spawnbrick.client);
     }
   }
}

When %triggerNum is 2, the spacebar was pressed inside the vehicle.
damn, beat me to it..

I think GSF had an old topic of it.
« Last Edit: May 06, 2010, 08:33:01 PM by Placid »


function TjeepVehicle::OnTrigger(%this, %obj, %triggerNum, %val)
{
   if(%val){
      if(%triggerNum == 2){
      ServerCmdTurbo(%obj.spawnbrick.client);
     }
   }
}

When %triggerNum is 2, the spacebar was pressed inside the vehicle.

Some people change their keybinds. Instead of telling us the default key for it, tell us the default function that's associated to it. I moved most of my keybinds to the center on my keyboard. I move with the arrow keys and such. I'm sure there is at least a few others who have also rebinded some keys.

I guess what I'm saying is: What does Spacebar do, again? I haven't had Spacebar binded to anything for years.

I guess what I'm saying is: What does Spacebar do, again? I haven't had Spacebar binded to anything for years.
Jump