Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: FarisDon on Jan 25, 2016, 05:41 PM

Title: Vehicle Break;
Post by: FarisDon on Jan 25, 2016, 05:41 PM
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.
Title: Re: Vehicle Break;
Post by: Thijn on Jan 25, 2016, 05:55 PM
You can just freeze the player.
Title: Re: Vehicle Break;
Post by: MacTavish on Jan 25, 2016, 06:05 PM
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
}
}
Title: Re: Vehicle Break;
Post by: KAKAN on Jan 25, 2016, 06:08 PM
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.
Title: Re: Vehicle Break;
Post by: MacTavish 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);
Title: Re: Vehicle Break;
Post by: KAKAN on Jan 25, 2016, 06:26 PM
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
Title: Re: Vehicle Break;
Post by: KAKAN on Jan 25, 2016, 06:32 PM
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;
}
Title: Re: Vehicle Break;
Post by: FarisDon on Jan 26, 2016, 10:09 AM
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.
Title: Re: Vehicle Break;
Post by: MacTavish on Jan 26, 2016, 10:31 AM
arrays wont lag you can use that without any problem
Title: Re: Vehicle Break;
Post by: FarisDon on Jan 26, 2016, 10:36 AM
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?
Title: Re: Vehicle Break;
Post by: MacTavish on Jan 26, 2016, 11:33 AM
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;
}
Title: Re: Vehicle Break;
Post by: KAKAN on Jan 26, 2016, 12:27 PM
http://forum.vc-mp.org/?topic=212.0
That might help ya^^
Title: Re: Vehicle Break;
Post by: FarisDon 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.
Title: Re: Vehicle Break;
Post by: 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.
Title: Re: Vehicle Break;
Post by: FarisDon on Jan 28, 2016, 03:27 PM
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.