[Help] OnPlayerInteractVehicle
#1

So, I have these functions just below, to repair a vehicle, where the "enter" key is pressed, thus activating a HoldingaAction of a certain time, at the end of it, the car should be repaired (damage restored), but none of this happens, I press "enter" in the right place but the HoldingAction starts and stops instantly.

However, it executes the "StartFixing" function because ActionText appears on the screen, which is inbuilt in it, but HoldingAction does not work, so it does not give proceeding to the code.


On Top of include
PHP код:
static
        
fix_TargetVehicle[MAX_PLAYERS],
Float:    fix_Progress[MAX_PLAYERS];
hook OnPlayerConnect(playerid)
{
    
fix_TargetVehicle[playerid] = INVALID_VEHICLE_ID;

Principal:
PHP код:
public OnPlayerInteractVehicle(playeridvehicleidFloat:angle)
{
    if(
angle 25.0 || angle 335.0)
    {
        new
            
Float:vehiclehealth,
            
ItemType:itemtype;
        
GetVehicleHealth(vehicleidvehiclehealth);
        
itemtype GetItemType(GetPlayerItem(playerid));
        if(
itemtype == item_Spanner)
        {
            if(
CLASSEmecanico[playerid] == true)
            {
                
CancelPlayerMovement(playerid);
                
StartFixing(playeridvehicleid);
            }
            else
            {
                
SendClientMessage(playeridRED"[ > ] Vocк nгo tem capacidade para realizar esta aзгo.");
                return 
1;
            }
        }
    }
    return 
CallLocalFunction("rep_OnPlayerInteractVehicle""ddf"playeridvehicleidFloat:angle);
}
#if defined _ALS_OnPlayerInteractVehicle
    #undef OnPlayerInteractVehicle
#else
    #define _ALS_OnPlayerInteractVehicle
#endif
#define OnPlayerInteractVehicle rep_OnPlayerInteractVehicle
forward rep_OnPlayerInteractVehicle(playeridvehicleidFloat:angle); 
My Functions:
PHP код:
StartFixing(playeridvehicleid)
{
    
ApplyAnimation(playerid"INT_SHOP""SHOP_CASHIER"4.0100001);
    
StartHoldAction(playerid5000);
    
ShowActionText(playeridsprintf("Consertando..."));
    
fix_TargetVehicle[playerid] = vehicleid;
    return 
1;
}
StopFixing(playerid)
{
    if(
fix_TargetVehicle[playerid] == INVALID_VEHICLE_ID)
        return 
0;
    
StopHoldAction(playerid);
    
ClearAnimations(playerid);
    
HideActionText(playerid);
    
fix_TargetVehicle[playerid] = INVALID_VEHICLE_ID;
    return 
1;

My OnHoldActionFinish
PHP код:
public OnHoldActionFinish(playerid)
{
    if(
fix_TargetVehicle[playerid] != INVALID_VEHICLE_ID)
    {
        new
        
itemid,
        
ItemType:itemtype;
        
itemid GetPlayerItem(playerid);
        
itemtype GetItemType(itemid);
        if(
itemtype == item_Spanner)
        {
            
SetVehicleHealth(fix_TargetVehicle[playerid], 990.0);
        }
        
        return 
1;
    }
    
#if defined repair_OnHoldActionFinish
        
return repair_OnHoldActionFinish(playerid);
    
#else
        
return 0;
    
#endif
}
#if defined _ALS_OnHoldActionFinish
    #undef OnHoldActionFinish
#else
    #define _ALS_OnHoldActionFinish
#endif
#define OnHoldActionFinish repair_OnHoldActionFinish
#if defined repair_OnHoldActionFinish
    
forward repair_OnHoldActionFinish(playerid);
#endif 
My KeyStateChange hook:
PHP код:
hook OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
oldkeys 16)
    {
        
StopFixing(playerid);
    }

I know it's a lot, but I'm lost and I do not know what to do, if anyone can help me, I'd be grateful
Reply


Messages In This Thread
[Help] OnPlayerInteractVehicle - by ApolloScripter - 03.12.2018, 17:16
Re: [Help] OnPlayerInteractVehicle - by ItsRobinson - 03.12.2018, 18:21
Re: [Help] OnPlayerInteractVehicle - by ApolloScripter - 03.12.2018, 18:27
Re: [Help] OnPlayerInteractVehicle - by ItsRobinson - 03.12.2018, 18:34
Re: [Help] OnPlayerInteractVehicle - by ApolloScripter - 03.12.2018, 19:44

Forum Jump:


Users browsing this thread: 1 Guest(s)