Taze Command (dcmd)
#1

Can someone debug the command? / Make it on a smater way!

pawn Код:
dcmd_taze(playerid, params[])
{
    if(gTeam[playerid] == TEAM_COP || gTeam[playerid] == TEAM_AIRCOP || gTeam[playerid] == TEAM_MARINECOP || gTeam[playerid] == TEAM_SWAT || gTeam[playerid] == TEAM_ARMY)
    {
        new targetid, string[128];

        new playername[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, playername, sizeof(playername));
        GetPlayerName(targetid, targetname, sizeof(targetname));

        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_USAGE, "USAGE: /taze (id)");
        else if(gTeam[targetid] == TEAM_COP && gTeam[targetid] == TEAM_AIRCOP && gTeam[targetid] == TEAM_MARINECOP && gTeam[targetid] == TEAM_SWAT && gTeam[targetid] == TEAM_ARMY) return SendClientMessage(playerid, COLOR_ERROR, "You cannot taze another Law Enforcement agent");
        else if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_ERROR, "Invalid ID");
        else if(playerid == targetid) return SendClientMessage(playerid, COLOR_ERROR, "You cannot taze yourself!");
        else if(IsSpawned[playerid] == 0) return SendClientMessage(playerid, COLOR_ERROR, "You are dead. You cannot use this command");
        else if(Jailed[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "You cannot use this command in jail");
        else if(GetPlayerWantedLevel(targetid) <= 3)
        {
            format(string, sizeof(string), "%s(%d) Does not have a warrant. You cannot use your tazer on this player", targetname, targetid);
            SendClientMessage(playerid, COLOR_ERROR, string);
            return 1;
        }
        else if(Tazed[targetid] == 1)
        {
            format(string, sizeof(string), "%s(%d) Is being tazed right now. You cannot taze a player while the player is being tazed", targetname, targetid);
            SendClientMessage(playerid, COLOR_ERROR, string);
        }
        else if(GetDistanceBetweenPlayers(playerid, targetid) > 10)
        {
            format(string, sizeof(string), "%s(%d) Is not close enough to taze", targetname, targetid);
            SendClientMessage(playerid, COLOR_ERROR, string);
            return 1;
        }
        else if(Cuffed[targetid] == 1)
        {
            format(string, sizeof(string), "%s(%d) Is in handcuffs and is restrained. You cannot taze a handcuffed player", targetname, targetid);
            SendClientMessage(playerid, COLOR_ERROR, string);
            return 1;
        }
        else if(IsPlayerInAnyVehicle(targetid))
        {
            format(string, sizeof(string), "%s(%d) Is in a vehicle. Get the player out the vehicle then use your tazer", targetname, targetid);
            SendClientMessage(playerid, COLOR_ERROR, string);
            return 1;
        }
        else if(IsPlayerInAnyVehicle(playerid))
        {
            SendClientMessage(playerid, COLOR_ERROR, "You cannot taze a player from inside a vehicle");
            return 1;
        }
        else
        {
            new FileL[68];

            format(FileL, sizeof(FileL) , SERVER_USER_FILE , playername);
            dini_IntSet(FileL, "Taze" , UserInfo[playerid][Taze]);
            UserInfo[playerid][Taze] ++;

            Tazed[targetid] =1;
            TogglePlayerControllable(targetid, 0);

            format(string, sizeof(string), "Law Enforcement agent %s(%d) Has tazed suspect %s(%d)", playername, playerid, targetname, targetid);
            SendClientMessageToAll(0x00C7FFAA, string);

            format(string, sizeof(string), "Officer %s(%d) Has tazed you", playername, playerid);
            SendClientMessage(targetid, COLOR_DODGERBLUE, string);

            ApplyAnimation(targetid,"PED","BIKE_fall_off",4.1,0,1,1,1,1);
            SetTimer("Tazingtime", 3000, false);
            return 1;
        }
    }
    return 0;
}
Reply
#2

Thanks for the help everyone xD

Problem: Solved
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)