Vehicle Break;

Started by FarisDon, Jan 25, 2016, 05:41 PM

Previous topic - Next topic

FarisDon

Well, is their anyway, when that the player sit in the car, and it won't start, until we press a button suppose : - 'X', so the basic thing i want to ask is their any code of it, cause i've searched it on squirrel functions wikipedia, and i'm unable to find it however i've seen some servers with the functions like that, well not asking for the whole code, simply the function of it.
P.S: Sorry, for my English.

Thijn

You can just freeze the player.

MacTavish

#2
well i didnt tested it but its a idea

BindKey
onScriptLoad()
{
keyid <- BindKey(true,0x58,0,0); // X
}

Freeze player when he enter vehicle as Driver
function onPlayerEnterVehicle( player, vehicle, door)
{
if(door == 0)
{
player.IsFrozen = true;
MessagePlayer("Press X to start vehicle",player);
}
}

function onPlayerExitVehicle( player, vehicle)
{
player.IsFrozen = false;
}

Start Car (unfreeze player) when press X
function onKeyDown( player, key )
{
if(key == X)
{
if(player.Vehicle && player.IsFrozen == true)
{
Announce("Vehicle Started",player);
PlaySound( player.UniqueWorld ,23, player.Pos );
player.IsFrozen = false;
}
else MessagePlayer("You Aren't In Any Vehicle",player); // to prevent unfreezing when any admin or server freeze player
}
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

function CVehicle::KillEngine()
{
    this.SetInstHandlingRule(this.ID, 13, 0);
    this.SetInstHandlingRule(this.ID, 14, 0);
}
function CVehicle::StartEngine()
{
    this.ResetInstHandlingRule(this.ID, 13);
    this.ResetInstHandlingRule(this.ID, 14);
}
Usage:-
//local VehicleInstance = FindVehicle(1);
VehicleInstance.KillEngine()
VehicleInstance.StartEngine()

Now when a player enters, use the killengine, when he does press 'X' use startengine.

Original functions by:- Ne.CrystalBlue. I just edited it a bit.
oh no

MacTavish

Quote from: KAKAN on Jan 25, 2016, 06:08 PM//local VehicleInstance = FindVehicle(1);

??? it should have to be //local VehicleInstance = FindVehicle(player.Vehicle.ID);

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

Quote from: Kusanagi on Jan 25, 2016, 06:13 PM
Quote from: KAKAN on Jan 25, 2016, 06:08 PM//local VehicleInstance = FindVehicle(1);

??? it should have to be //local VehicleInstance = FindVehicle(player.Vehicle.ID);
That was just for testing. Why would you use FindVehicle? Use player.Vehicle.function()

Btw that code is just untested
oh no

KAKAN

Well, those 2 functions won't work. Use this 2 instead:-
function CVehicle::KillEngine()
{
    this.SetHandlingData(13,0);
    this.SetHandlingData(14,0);
    return 1;
}
function CVehicle::StartEngine()
{
    this.ResetHandlingData(13);
    this.ResetHandlingData(14);
    return 1;
}
oh no

FarisDon

#7
Guys, I didn't even asked ,for codes! Okay, that's really a great idea to freeze the player, but the thing, actually not thing, it's the fact! that whenever i set in the car, and add the code, yes it don't move but it have some kinda problem thou, that is actually that i can't exit from the vehicle even thou, i make the function onPlayerExitVehicle( player, vehicle){player.IsFrozen=false;i can't unable exit from vehicle. lol, i prefer for making a array for it, but will it lag?
enter=false;
function onPlayerEnterVehicle( player, vehicle,pass)
{
if ( pinfo[player.ID].enter == false)
{
 player.IsFrozen=true;
pinfo[player.ID].enter =true;
VehInfo(player,vehicle)
}
}
function onPlayerExitVehicle( player, vehicle )
{
if ( pinfo[player.ID].enter == true
{ player.IsFrozen=false;pinfo[player.ID].enter =true;}
}
It works the same way, and it can cause definatly a lag, so isn't their any other way, cause i think Freeze, is useless, for the exiting way.

MacTavish

arrays wont lag you can use that without any problem

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

FarisDon

Quote from: Kusanagi on Jan 26, 2016, 10:31 AMarrays wont lag you can use that without any problem
So, I guess their isn't anyway, but to make an other blind key to check that if player is in vehicle, and press "BLA" to get exit of it, no?

MacTavish

well try binding ENTER and F key and unfreeze player on first line by checking if(key == F || key == ENTER)
{
if(player.Vehicle && player.Frozen == true) player.Frozen = false;
}

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

KAKAN

oh no

FarisDon

Quote from: Kusanagi on Jan 26, 2016, 11:33 AMwell try binding ENTER and F key and unfreeze player on first line by checking if(key == F || key == ENTER)
{
if(player.Vehicle && player.Frozen == true) player.Frozen = false;
}
Uhm, I just thought of it, but no need to give the codes thou ;) I'm not a noob.
Quote from: KAKAN on Jan 26, 2016, 12:27 PMhttp://forum.vc-mp.org/?topic=212.0
That might help ya^^
Well, as for you, Kakan, i'm not a new member over here, i know these things ._. already. but thanks guys Anyway Topic Lock.

KAKAN

Quote from: [TBS]Destroyer on Jan 26, 2016, 03:05 PM
Quote from: Kusanagi on Jan 26, 2016, 11:33 AMwell try binding ENTER and F key and unfreeze player on first line by checking if(key == F || key == ENTER)
{
if(player.Vehicle && player.Frozen == true) player.Frozen = false;
}
Uhm, I just thought of it, but no need to give the codes thou ;) I'm not a noob.
Quote from: KAKAN on Jan 26, 2016, 12:27 PMhttp://forum.vc-mp.org/?topic=212.0
That might help ya^^
Well, as for you, Kakan, i'm not a new member over here, i know these things ._. already. but thanks guys Anyway Topic Lock.
I never told that you're new. That topic is not upon 'onKeyBind', that's something else. It's about GTA VC's keys. That can help you better.
oh no

FarisDon

Quote from: KAKAN on Jan 27, 2016, 07:17 AM
Quote from: [TBS]Destroyer on Jan 26, 2016, 03:05 PM
Quote from: Kusanagi on Jan 26, 2016, 11:33 AMwell try binding ENTER and F key and unfreeze player on first line by checking if(key == F || key == ENTER)
{
if(player.Vehicle && player.Frozen == true) player.Frozen = false;
}
Uhm, I just thought of it, but no need to give the codes thou ;) I'm not a noob.
Quote from: KAKAN on Jan 26, 2016, 12:27 PMhttp://forum.vc-mp.org/?topic=212.0
That might help ya^^
Well, as for you, Kakan, i'm not a new member over here, i know these things ._. already. but thanks guys Anyway Topic Lock.
I never told that you're new. That topic is not upon 'onKeyBind', that's something else. It's about GTA VC's keys. That can help you better.
Well, I know that lol, but nevermind, Thanks Topic Locked.