03.12.2018, 17:16
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
Principal:
My Functions:
My OnHoldActionFinish
My KeyStateChange hook:
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
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;
}
PHP код:
public OnPlayerInteractVehicle(playerid, vehicleid, Float:angle)
{
if(angle < 25.0 || angle > 335.0)
{
new
Float:vehiclehealth,
ItemType:itemtype;
GetVehicleHealth(vehicleid, vehiclehealth);
itemtype = GetItemType(GetPlayerItem(playerid));
if(itemtype == item_Spanner)
{
if(CLASSEmecanico[playerid] == true)
{
CancelPlayerMovement(playerid);
StartFixing(playerid, vehicleid);
}
else
{
SendClientMessage(playerid, RED, "[ > ] Vocк nгo tem capacidade para realizar esta aзгo.");
return 1;
}
}
}
return CallLocalFunction("rep_OnPlayerInteractVehicle", "ddf", playerid, vehicleid, Float:angle);
}
#if defined _ALS_OnPlayerInteractVehicle
#undef OnPlayerInteractVehicle
#else
#define _ALS_OnPlayerInteractVehicle
#endif
#define OnPlayerInteractVehicle rep_OnPlayerInteractVehicle
forward rep_OnPlayerInteractVehicle(playerid, vehicleid, Float:angle);
PHP код:
StartFixing(playerid, vehicleid)
{
ApplyAnimation(playerid, "INT_SHOP", "SHOP_CASHIER", 4.0, 1, 0, 0, 0, 0, 1);
StartHoldAction(playerid, 5000);
ShowActionText(playerid, sprintf("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;
}
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
PHP код:
hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(oldkeys & 16)
{
StopFixing(playerid);
}
}