static
fix_TargetVehicle[MAX_PLAYERS],
Float: fix_Progress[MAX_PLAYERS];
hook OnPlayerConnect(playerid)
{
fix_TargetVehicle[playerid] = INVALID_VEHICLE_ID;
}
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);
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;
}
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
hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(oldkeys & 16)
{
StopFixing(playerid);
}
}
Are you trying to repair the vehicle when the player enter's the vehicle? Or are you doing a type of pay and spray where you are at a specific location, press enter and then it repairs the vehicle?
|
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
if((newkeys & KEY_LOOK_LEFT)) //press Q
{
//Search or make some code to grab the nearest vehicle ID (very easy to find/do)
StartFixing(playerid, /*Returned closest vehID*/);
}
if((oldkeys & KEY_LOOK_LEFT)) //releases Q
{
StopFixing(playerid);
}