Which way is better?
#1

they both compile just not sure if the braces are needed,Please tell me what way is better..

A:

pawn Код:
CMD:cuff(playerid, params[])
{
    new targetid;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(sscanf(params, "U", targetid)) return SendClientMessage(playerid,RED, "USAGE: /cuff [id]");
    {
        if(gTeam[playerid] != CLASS_COPS) return SendClientMessage(playerid, RED,"Only Cops Can Cuff People!");
        {
            if(targetid == playerid) return SendClientMessage(playerid, RED, "You Cant Cuff Yourself!");
            {
                if (!ProxDetectorS(7.5, playerid, targetid)) return SendClientMessage(playerid, RED, "The Player Is Not Close Enough!");
                {
                    if(GetPlayerWantedLevel(targetid) < 4) return SendClientMessage(playerid, RED, "That Player Is Not Wanted!");
                    {
                        if(IsPlayerInAnyVehicle(targetid) && IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You Cant Cuff Players Through Vehicles!");
                        {
                            if(gTeam[targetid] == CLASS_COPS || gTeam[targetid] == CLASS_MEDIC) return SendClientMessage(playerid, RED, "You Cant Cuff Other Cops Or Medics!");
                            else
                            {
                                GameTextForPlayer(targetid, "\n\n\n~r~Cuffed!", 2500, 5);
                                GameTextForPlayer(playerid, "\n\n\n~g~Suspect Cuffed!", 2500, 5);
                                TogglePlayerControllable(targetid, false);
                            }
                        }
                    }
                }
            }
        }
    }
    return true;
}
B:

pawn Код:
CMD:cuff(playerid, params[])
{
    new targetid;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(sscanf(params, "U", targetid)) return SendClientMessage(playerid,RED, "USAGE: /cuff [id]");
    if(gTeam[playerid] != CLASS_COPS) return SendClientMessage(playerid, RED,"Only Cops Can Cuff People!");
    if(targetid == playerid) return SendClientMessage(playerid, RED, "You Cant Cuff Yourself!");
    if (!ProxDetectorS(7.5, playerid, targetid)) return SendClientMessage(playerid, RED, "The Player Is Not Close Enough!");
    if(GetPlayerWantedLevel(targetid) < 4) return SendClientMessage(playerid, RED, "That Player Is Not Wanted!");
    if(IsPlayerInAnyVehicle(targetid) && IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "You Cant Cuff Players Through Vehicles!");
    if(gTeam[targetid] == CLASS_COPS || gTeam[targetid] == CLASS_MEDIC) return SendClientMessage(playerid, RED, "You Cant Cuff Other Cops Or Medics!");
    else
    {
        GameTextForPlayer(targetid, "\n\n\n~r~Cuffed!", 2500, 5);
        GameTextForPlayer(playerid, "\n\n\n~g~Suspect Cuffed!", 2500, 5);
        TogglePlayerControllable(targetid, false);
    }
    return true;
}
A or B?

Thanks
Reply
#2

I would do it this way

Код:
CMD:cuff(playerid, params[])
{
    new targetid;
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    if(sscanf(params, "U", targetid)) SendClientMessage(playerid,RED, "USAGE: /cuff [id]");
    else if(gTeam[playerid] != CLASS_COPS) SendClientMessage(playerid, RED,"Only Cops Can Cuff People!");
    else if(targetid == playerid) SendClientMessage(playerid, RED, "You Cant Cuff Yourself!");
    else if(!ProxDetectorS(7.5, playerid, targetid)) SendClientMessage(playerid, RED, "The Player Is Not Close Enough!");
    else if(GetPlayerWantedLevel(targetid) < 4) SendClientMessage(playerid, RED, "That Player Is Not Wanted!");
    else if(IsPlayerInAnyVehicle(targetid) && IsPlayerInAnyVehicle(playerid)) SendClientMessage(playerid, RED, "You Cant Cuff Players Through Vehicles!");
    else if(gTeam[targetid] == CLASS_COPS || gTeam[targetid] == CLASS_MEDIC) SendClientMessage(playerid, RED, "You Cant Cuff Other Cops Or Medics!");
    else
    {
        GameTextForPlayer(targetid, "\n\n\n~r~Cuffed!", 2500, 5);
        GameTextForPlayer(playerid, "\n\n\n~g~Suspect Cuffed!", 2500, 5);
        TogglePlayerControllable(targetid, false);
    }
    return true;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)