Need some help on a /defuse command
#4

notsure if it will work but here

pawn Код:
if (strcmp(cmd, "/plantbomb", true) ==0 )
        {
            if(PlayerInfo[playerid][pBomb] < 1)
            {
                SendClientMessage(playerid, COLOR_BLUE, "You don't have bombs");
                return 1;
            }
            if(IsPlayerInAnyVehicle(playerid))
            {
                PlayerInfo[playerid][pBomb] = 0;
                TogglePlayerControllable(playerid, 0);
                SetTimerEx("BombTimer2", 5000, 0, "d", playerid);
                format(string, sizeof(string), "%s begins to plant a bomb.", GetPlayerNameEx(playerid));
                ProxDetector(5.0, playerid, string,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
                return 1;
            }
            PlayerInfo[playerid][pBomb] = 0;
            TogglePlayerControllable(playerid, 0);
            ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,1,0,0,0,0);
            SetTimerEx("BombTimer2", 5000, 0, "d", playerid);
            format(string, sizeof(string), "%s begins to plant a bomb.", GetPlayerNameEx(playerid));
            ProxDetector(5.0, playerid, string,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
            return 1;
        }

forward BombTimer2(playerid);
public BombTimer2(playerid)
{
    GetPlayerPos(playerid, bombx, bomby, bombz);
    TheBomb[playerid] = CreatePickup(1252, 1, bombx, bomby, bombz, -1);
    TogglePlayerControllable(playerid, 1);
    ClearAnimations(playerid);
    SendClientMessage(playerid, COLOR_SPRINGGREEN, "The Bomb explodes in 20 Seconds! RUN!");
    BombExplosion[playerid] = 20;
    BombingTime2[playerid] = SetTimerEx("BombTimer3", 1000, 1, "d", playerid);
    return 1;
}

forward BombTimer3(playerid);
public BombTimer3(playerid)
{
    new string[128];
    if(BombExplosion[playerid] == 0)
    {
        CreateExplosion(bombx, bomby, bombz, 6, 100.0);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerInRangeOfPoint(i, 100.0, bombx, bomby, bombz))
            {

                SendClientMessage(i, COLOR_SPRINGGREEN, "You have been caughten up in the bomb explosion");
                ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
                GivePlayerHealth(i, -90);
                DestroyPickup(TheBomb[i]);
                ApplyAnimation(i, "WUZI", "CS_Dead_Guy", 4.0, 0, 0, 0, 0, 0); // Dead Crawling
            }
        }
        KillTimer(BombingTime2[playerid]);
        return 1;
    }
    PlayerPlaySound(playerid, 1132, bombx, bomby, bombz);
    BombExplosion[playerid] --;
    format(string, 256, "~g~~>~Time Left~w~ - %d~<~", BombExplosion[playerid]);
    GameTextForPlayer(playerid, string, 1000, 4);
    return 1;
}

forward BombTimer(playerid);
public BombTimer(playerid)
{
    new string[128];
    if(BombTime[playerid] == 0)
    {
        KillTimer(BombingTime[playerid]);
        TogglePlayerControllable(playerid, 1);
        ClearAnimations(playerid);
        SendClientMessage(playerid, COLOR_SPRINGGREEN, "You have made yourself a bomb!");
        PlayerInfo[playerid][pBomb] = 1;
        PlayerInfo[playerid][pBombMats] = 0;
        return 1;
    }
    BombTime[playerid] --;
    format(string, 256, "~r~~>~Time Left~w~ - %d~<~", BombTime[playerid]);
    GameTextForPlayer(playerid, string, 1000, 4);
    return 1;
}




if(strcmp(cmd, "/defuse", true) == 0)
    {
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                if(PlayerInfo[playerid][pFaction] != 255 && DynamicFactions[PlayerInfo[playerid][pFaction]][fType] != 1)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[Error:] Invalid faction");
                    return 1;
                }
                if(CopOnDuty[playerid] == 0)
                {
                    SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not on duty");
                    return 1;
                }
                if(IsPlayerInAnyVehicle(playerid))
                {
                    return 1;
                }
                new Float:bx[MAX_PLAYERS], Float:by[MAX_PLAYERS], Float:bz[MAX_PLAYERS];
                GetObjectPos(TheBomb[i], bx[i], by[i], bz[i]);
                if(IsPlayerInRangeOfPoint(playerid, 2.0, bx[i], by[i], bz[i]))
                {
                    new rand = random(2)+1;
                    if(rand == 1)
                    {
                        GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                        ApplyAnimation(playerid, "BOMBER","BOM_Plant_Loop",4.0,0,0,0,0,1000);
                        SendClientMessage(playerid, COLOR_WHITE, "[Info:] You have defused the bomb safely");
                        format(string, sizeof(string), "%s successfully cuts the wires and defuses the bomb", giveplayer);
                        ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
                        TextDrawHideForPlayer(i, Meter1[playerid]);
                        TextDrawHideForPlayer(i, Meter2[playerid]);
                        TextDrawHideForPlayer(i, Meter3[playerid]);
                        KillTimer(BombTimer3[i]);
                        BombTimer3[i]=0;
                        BombExplosion=0;
                        DestroyObject(i, TheBomb[i]);
                        Planted[playerid] = 0;
                        KillTimer(UpdateMeterTimer[playerid]);
                    }
                    else
                    {
                        GameTextForPlayer(playerid, "~r~Wrong Wire!", 2000, 1);
                        CreateExplosion(bx[playerid], by[playerid], bz[playerid], 6, ExplosionRadius);
                        TextDrawHideForPlayer(i, Meter1[playerid]);
                        TextDrawHideForPlayer(i, Meter2[playerid]);
                        TextDrawHideForPlayer(i, Meter3[playerid]);
                        KillTimer(UpdateMeterTimer[playerid]);
                        DestroyObject(TheBomb[i]);
                        Planted[playerid] = 0;
                        KillTimer(BombingTime2[i]);
                    }
                }
                else
                {
                    SendClientMessage(playerid, COLOR_GREY, "[Error:] You are not in range of a bomb");
                }
            }
        }// not connected
        return 1;
    }
changed some vars here and there
Reply


Messages In This Thread
Need some help on a /defuse command - by kujox222 - 08.12.2011, 04:06
Re: Need some help on a /defuse command - by THE_KNOWN - 08.12.2011, 04:19
Re: Need some help on a /defuse command - by kujox222 - 08.12.2011, 04:34
Re: Need some help on a /defuse command - by THE_KNOWN - 08.12.2011, 04:48
Re: Need some help on a /defuse command - by kujox222 - 08.12.2011, 05:08
Re: Need some help on a /defuse command - by THE_KNOWN - 08.12.2011, 05:19
Re: Need some help on a /defuse command - by kujox222 - 08.12.2011, 06:20

Forum Jump:


Users browsing this thread: 1 Guest(s)