==>Auto Fix Problem<==
#1

Ok I have a small problem with my script. When i drive and hit stuff with vehicles the auto fix works pefectly but when my vehicle (car) is upside down and starts bunring it doesn't fix it so i blow up. If there is a way to do this i will be grateful.
HERE IS THE SCRIPT:
pawn Код:
//=====INCLUDES=====//
#include <a_samp>
//===================DEFINES====================//
#define HOLDING(%0) \
    ((newkeys & (%0)) == (%0))

#define RELEASED(%0) \
    (((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))

#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
//====================FORWARDS=================//
forward Repair(playerid);
//=============================================//
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n-----------------------------------------");
    print(" /AutoFix/Flip/InfinityNos/by ThePrograme/ ");
    print("-----------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n-----------------------------------------");
    print(" /AutoFix/Flip/InfinityNos/by ThePrograme/ ");
    print("-----------------------------------------\n");
}

#endif

public OnPlayerKeyStateChange( playerid, newkeys, oldkeys )
{
    if ( HOLDING( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
    {
          AddVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
    }

    if (  RELEASED( KEY_FIRE ) && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
    {
          RemoveVehicleComponent( GetPlayerVehicleID( playerid ), 1010 );
    }
    if((newkeys&KEY_CROUCH)&&!(oldkeys&KEY_CROUCH))
    {
        new VehicleID,Float:B;
        VehicleID = GetPlayerVehicleID(playerid);
        GetVehicleZAngle(VehicleID,B);
        SetVehicleZAngle(VehicleID,B);
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    SetTimerEx("Repair",1000,true,"i",playerid);
    return 1;
}
public Repair(playerid)
{
    if (IsPlayerInAnyVehicle(playerid))
    {
    new Float:health;
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid, health);
    if (health <= 1000)
        {
    SetVehicleHealth(vehicleid,1000);
    }
    }
}

public OnVehicleDamageStatusUpdate(vehicleid, playerid)
{
    #pragma unused playerid

    RepairVehicle(vehicleid);
    new panels, doors, lights, tires;
    GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
    tires = encode_tires(0, 0, 0, 0);
    panels = encode_panels(0, 0, 0, 0, 0, 0, 0);
    doors = encode_doors(0, 0, 0, 0, 0, 0);
    lights = encode_lights(0, 0, 0, 0);
    UpdateVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
    return 1;
}

encode_tires(tire1, tire2, tire3, tire4) return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
encode_panels(flp, frp, rlp, rrp, windshield, front_bumper, rear_bumper)
{
    return flp | (frp << 4) | (rlp << 8) | (rrp << 12) | (windshield << 16) | (front_bumper << 20) | (rear_bumper << 24);
}
encode_doors(bonnet, boot, driver_door, passenger_door, behind_driver_door, behind_passenger_door)
{
    #pragma unused behind_driver_door
    #pragma unused behind_passenger_door
    return bonnet | (boot << 8) | (driver_door << 16) | (passenger_door << 24);
}
encode_lights(light1, light2, light3, light4)
{
    return light1 | (light2 << 1) | (light3 << 2) | (light4 << 3);
}
Oh and this script also contains scripts for vehicles to FLIP and have NITRO
One more thing if you like to have this script and get more details for it go here:
https://sampforum.blast.hk/showthread.php?tid=373147
OR click [FilterScript] AutoFix/Flip/InfinityNos at the bottom.

========>THANKS IN ADVANCE<========
Reply
#2

Just use a timer and inside the callback a for loop through all the players. Check if they are connected and if they are drivers and repairvehicle by using the function to get the vehicle ID.
Reply
#3

Can you make that for this script? I'm not such a scripter, or anyone!!
Reply
#4

Can anyone at least help me make this in my script: ??
Quote:
Originally Posted by Dwane
Посмотреть сообщение
Just use a timer and inside the callback a for loop through all the players. Check if they are connected and if they are drivers and repairvehicle by using the function to get the vehicle ID.
Reply
#5

Sorry, I was on the mobile the time I replied and it would take ages to make it there.
pawn Код:
#define FILTERSCRIPT

new
    af_timer
;

public OnFilterScriptInit( )
{
    af_timer = SetTimer( "AutoRepair", 500, true );
    return 1;
}

public OnFilterScriptExit( )
{
    KillTimer( af_timer );
    return 1;
}

forward AutoRepair( );
public AutoRepair( )
{
    for( new playerid; playerid < MAX_PLAYERS; playerid ++ )
    {
        if( !IsPlayerConnected( playerid ) ) continue;
        if( GetPlayerState( playerid ) != PLAYER_STATE_DRIVE ) continue;
        RepairVehicle( GetPlayerVehicleID( playerid ) );
    }
    return 1;
}
Reply
#6

Oh no problem. You don't need to apologise!!
Reply
#7

Thanks man it works perfectly now :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)