/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
#2

No, MAX_PLAYERS is correct. Since you are storing the vehicle id for each PLAYER, not storing something for each Vehicle, if that makes sense.
Reply
#3

Quote:
Originally Posted by randomkid88
Посмотреть сообщение
No, MAX_PLAYERS is correct. Since you are storing the vehicle id for each PLAYER, not storing something for each Vehicle, if that makes sense.
Yea, that was also my thourghts. Its just because a friend told me that it should be MAX_VEHICLES, and that made me doubt. Just wanted it confirmed.
Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)