Hotkey P

Started by PsyChO_KiLLeR, Mar 01, 2015, 09:17 AM

Previous topic - Next topic

PsyChO_KiLLeR

Description: Well i create a new function of HotKey of Fixing a vehicle by Button P but its not working it dont give any error in console but when i sit in vehicle and press p nothing happen what is error

Function: There is function this i add in scriptload 
P <- BindKey(true, 0x5D,0,0);and this on KeyDown
if( key == P )
{
         local veh = player.Vehicle;
if ( !veh ) ePrivMessage( "You must be in a Vehicle.", player );
else if ( player.Cash < 300 ) ePrivMessage( "You need $300 to Fix your vehicle!", player );
else
{
    DecCash( player, 300 );
veh.Health = 1000;
ePrivMessage( "Fixed!", player );
}
}




ScreenShot of error: No error comes so no screenshot



karan20000000000

Your car must be fixed but it won't be looking fixed.
So to do that you need to add
veh.Damage=0;
With regards,
KP
------------------------------------------

.

Try reading the following post and see if it helps.
.

Sebastian

Quote from: karan20000000000 on Mar 01, 2015, 09:21 AMYour car must be fixed but it won't be looking fixed.
So to do that you need to add
veh.Damage=0;

This should be right.
vehicle.Health is no longer repairing the vehicle, just setting it's health value.
vehicle.Damage should be called, to also repair the car, but you have to use both functions to have a fully fixed vehicle.

That's why, Gudio, made a function to fix the vehicle at all, with full health and no visual damage.
It is called: vehicle.Fix( )

soulshaker

function onScriptLoad()
{
Fix <- BindKey( false, 0, 0, 80 );
}

function onKeyDown( player, key )
{
if ( key == Fix )
    {
local veh = player.Vehicle
        else if ( !veh ) MessagePlayer( "Error, You must be in a vehicle to use fix hotkey.", player );
else if ( player.Cash < 300 ) MessagePlayer( "Error, You need $300 to Fix your vehicle!", player );
else
{
DecCash( player, 300 );
veh.Fix();
        MessagePlayer( "Vehicle repaired.", player );
}
    }
}

PsyChO_KiLLeR

thnx S.L.C , SoulShaker, Seby and Karan
It works
Topic Lock