/repair command
#1

Hello guys. This is just a fast question about a /repair command, that I made.
I made it like this: (You don't have to look into the code, look at the question at the buttom, its very simple).
pawn Код:
forward VehicleRepair(playerid, vehicleid);
 
public VehicleRepair(playerid, vehicleid) // Only used for mechanic job
{
    if(IsPlayerInVehicle(playerid, veh[playerid]))
    {
        RepairVehicle(veh[playerid]);
        SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Vehicle Repair successful");
        IsRepairing[playerid] = 0;
    }
    else
    {
        SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) Repair failed. You left the Vehicle");
        IsRepairing[playerid] = 0;
    }
    return 1;
}
pawn Код:
new veh[MAX_PLAYERS];
 
COMMAND:repair(playerid, params[])
{
    if(PlayerInfo[playerid][pJob] == 1)
    {
        if(PlayerInfo[playerid][pDuty] == 1)
        {
            if(IsRepairing[playerid] == 0)
            {
                new Float:health;
                veh[playerid] = GetPlayerVehicleID(playerid);
                GetVehicleHealth(veh[playerid], health);
                if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You must be in a Vehicle to use this Command");
                if(health == 1000) return SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) This vehicle is already fully repaired");
                else
                {
                    SetTimerEx("VehicleRepair", 10000, false, "d", playerid);
                    SendClientMessage(playerid, COLOR_YELLOW, "( ! ) Vehicle Repair in Progress. Please wait...");
                    IsRepairing[playerid] = 1;
                }
            }
            else SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You are already repairing a Vehicle");
        }
        else SendClientMessage(playerid, COLOR_NORMALRED, "( ! ) You must be on Duty to use this Command");
    }
    else return 0;
    return 1;
}
It works fine as it is now, but im in doubt about the "new veh[MAX_PLAYERS];"
Should it be MAX_VEHICLES in stead?

Thank you.
Reply


Messages In This Thread
/repair command - by sim_sima - 15.06.2011, 16:10
Re: /repair command - by randomkid88 - 15.06.2011, 16:16
Re: /repair command - by sim_sima - 15.06.2011, 16:18

Forum Jump:


Users browsing this thread: 1 Guest(s)