Which one of these 2 commands would be most efficient?
#1

Hello, I have 2 ways of making the commands but I would want to know which one is the best. They both work.

Command 1 Example:
pawn Код:
CMD:fix(playerid, params[])
{
    new target, string[80];
    if(sscanf(params, "u", target)) target = playerid;
    if (!IsPlayerConnected(target)) return SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s is not connected to the server.", params);
    if(!IsPlayerInAnyVehicle(target))
    {
        if(target != playerid)
        {
            SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s(%d) is not in a vehicle.",Name(target),target);
        }
        else
        {
            SendClientMessage(playerid, COLOR_DARKRED, "You must be in a vehicle to use this command.");
        }
        return 1;
    }
    if(IsPlayerInAnyVehicle(target))
    {
        new vid;
        vid = GetPlayerVehicleID(target);
        RepairVehicle(vid);
        if(target != playerid)
        {
            format(string, 128, "You repaired %s(%d)'s vehicle.", Name(target), target);
            SendClientMessage(playerid, COLOR_ADMIN, string);
        }
        else
        {
            SendClientMessage(playerid, COLOR_ADMIN, "Your vehicle has been fixed.");
        }
    }
    return 1;
}

Command 2 Example:
pawn Код:
CMD:fix(playerid, params[])
{
    new target, string[80], vid;
    if(sscanf(params, "u", target))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_DARKRED, "You must be in a vehicle to use this command.");
        SendClientMessage(playerid, COLOR_ADMIN, "Your vehicle has been fixed.");
        RepairVehicle(vid);
    }
    else
    {
        if (!IsPlayerConnected(target)) return SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s is not connected to the server.", params);
        if(!IsPlayerInAnyVehicle(target)) return SendClientMessageFormatted(playerid, COLOR_DARKRED, "%s(%d) is not in a vehicle.",Name(target),target);
        vid = GetPlayerVehicleID(playerid);
        format(string, 128, "You repaired %s(%d)'s vehicle.", Name(target), target);
        SendClientMessage(playerid, COLOR_ADMIN, string);
        RepairVehicle(vid);
    }
    return 1;
}
Reply
#2

Command 2 seems like the faster one to process?
Reply
#3

The 2nd command.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)