How to make this command shorter and more simple?
#2

Well mostly, most of the code is needed but you can make it a bit smaller like this:
pawn Код:
dcmd_taze(playerid, params[])
{
    new taze = strval(params);
    if(!strlen(params)) return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /taze [ID]");
   
    if(gTeam[playerid] == COP || gTeam[playerid] == SWAT || gTeam[playerid] == ARMY || gTeam[playerid] == FBI)
    {
        if(GetDistanceBetweenPlayers(playerid, taze) <= 6)
        {
            if(tazetime[playerid] == 0)
            {
                new tehtaze = random(5);
                if(tehtaze == 1 || tehtaze == 2 || tehtaze == 3 || tehtaze == 4)
                {
                    new string[256], Float:thlth;
                    format(string, sizeof(string), "%s (%i) has tazed you.",ReturnPlayerName(playerid), playerid);
                    SendClientMessage(taze, COLOR_MSG, string);
                    format(string, sizeof(string), "You have tazed %s (%i).",ReturnPlayerName(taze), taze);
                    SendClientMessage(playerid, COLOR_MSG, string);
                    GetPlayerHealth(taze, thlth);
                    new Float:tehtaze3 = thlth-15-random(30);
                    SetPlayerHealth(taze, tehtaze3);
                    if(thlth < tehtaze3)
                    {
                        format(string, sizeof(string), "%s (%i) has been tazed to death", ReturnPlayerName(taze), taze);
                        SendClientMessageToAll(COLOR_KILLED, string);
                    }
                    else
                    {
                        SendClientMessage(taze, COLOR_MSG, "You are stunned for a while.");
                        TogglePlayerControllable(taze, 0);
                        stunned[taze] = 1;
                        tazetime[playerid] = 1;
                        SetTimerEx("tazetimer", ANTISPAM*1000, 0, "i", playerid);
                        SetTimerEx("stuntimer", STUNNED_TIME*1000, 0, "i", taze);
                    }
                }
                else
                {
                    new string[256], Float:phlth;
                    format(string, sizeof(string), "%s (%i) has accidentally held the tazer the wrong way and tazed himself",ReturnPlayerName(playerid), playerid);
                    SendClientMessage(taze, COLOR_MSG, string);
                    SendClientMessage(playerid, COLOR_MSG, "You accidentally held the tazer the wrong way and tazed yourself");
                    GetPlayerHealth(playerid, phlth);
                    new Float:tehtaze2 = phlth-25-random(30);
                    SetPlayerHealth(playerid, tehtaze2);
                    if(phlth < tehtaze2)
                    {
                        format(string, sizeof(string), "%s (%i) has been tazed to death",ReturnPlayerName(playerid), playerid);
                        SendClientMessageToAll(COLOR_KILLED, string);
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_MSG, "You are stunned for a while.");
                        TogglePlayerControllable(playerid, 0);
                        stunned[playerid] = 1;
                        SetTimerEx("stuntimer", STUNNED_TIME*1000, 0, "i", playerid);
                        SetTimerEx("tazetimer", ANTISPAM*1000, 0, "i", playerid);
                        tazetime[playerid] = 1;
                    }
                }
            }
            else return SendClientMessage(playerid, COLOR_MSG, "Please wait before tazing someone again!");
           
        }
        else
        {
            new string[256];
            format(string, sizeof(string), "%s (%i) is not close enough to taze!", ReturnPlayerName(taze), taze);
        }
       
        else return SendClientMessage(playerid, COLOR_MSG, "[ERROR] You are not a Police Officer!");
    }
    return 1;
}


AGAIN, this can't be any more simple else you'll need to remove some of the codes.
Reply


Messages In This Thread
How to make this command shorter and more simple? - by Uberanwar - 01.08.2013, 07:21
Re: How to make this command shorter and more simple? - by JimmyCh - 01.08.2013, 07:29
Re: How to make this command shorter and more simple? - by Necip - 01.08.2013, 07:32
Re: How to make this command shorter and more simple? - by Uberanwar - 01.08.2013, 22:31
Re: How to make this command shorter and more simple? - by DeMoX - 01.08.2013, 22:33
Re: How to make this command shorter and more simple? - by park4bmx - 01.08.2013, 22:41

Forum Jump:


Users browsing this thread: 1 Guest(s)