Help BUUG
#1

why bomb can explode when is defused


Код:
#include <a_samp>
#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000BBAA

new PostaviTim[MAX_PLAYERS];
new PlantedBomb = 0;
new Explode[MAX_PLAYERS];
new SetpScore[MAX_PLAYERS];
new dbomb[MAX_PLAYERS];


public OnGameModeInit()
{
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

public OnPlayerConnect(playerid)
{
    PostaviTim[playerid] = 0;
    SetpScore[playerid] = 0;
    dbomb[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    PostaviTim[playerid] = 0;
    SetpScore[playerid] = 0;
    dbomb[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if (PostaviTim[playerid] == 0)
    {
        new Tim = random(2);
        switch(Tim)
        {
            case 0:
            {
                PostaviTim[playerid] = 1;
                //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
            }
            case 1:
            {


                PostaviTim[playerid] = 2;
                //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
            }
        }
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/plantbomb", cmdtext, true, 10) == 0)
    {
        if (PostaviTim[playerid] == 2) return SendClientMessage (playerid, COLOR_RED, "Cops can't plant bomb");
        if (!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
        if (PlantedBomb == 1) return SendClientMessage(playerid,COLOR_RED,"Bomb is already planted!");
        PlantedBomb = 1;
        SetpScore[playerid] = 1;
        GameTextForAll("~r~Bomb has been planted!",3000,5);
        Explode[playerid] = SetTimerEx("Explosion", 300000, false, "i", playerid);
    }


    if (strcmp("/defusebomb", cmdtext, true, 10) == 0)
    {
        if (PostaviTim[playerid] == 2)
        {
            if (!IsPlayerInRangeOfPoint(playerid,2.0,212.9239,1820.3402,6.4216)) return SendClientMessage(playerid,COLOR_RED,"You are not in the place for planting the bomb");
            if (PlantedBomb == 0) return SendClientMessage(playerid,COLOR_RED,"Bomb is not planted!");
            SendClientMessage(playerid,COLOR_RED,"You are defusing a bomg, please wait...");
            dbomb[playerid] = 1;
            SetTimerEx("Defusion", 20000, false, "i", playerid);
        }
        else
        {
            SendClientMessage (playerid, COLOR_RED, "Only cops can defuse bomb");
        }
    }
    return 0;
}

forward Explosion(playerid);
public Explosion(playerid)
{
    if(SetpScore[playerid] == 1)
    {
        SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
        SetpScore[playerid] = 0;
        GivePlayerMoney(playerid, 10000);
        SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
        SendClientMessage(playerid, COLOR_RED, "Bomb:you got +5 score and 10000$ for planting bomb");
    }
    GameTextForAll("~r~Bomb exploded",6000,5);
    CreateExplosion(212.9239,1820.3402,6.4216,12,20.0);
    PlantedBomb = 0;
    return 1;
    KillTimer(Explode[playerid]);
}

forward Defusion(playerid);
public Defusion(playerid)
{
    if(dbomb[playerid] == 1)
    {
        GivePlayerMoney(playerid, 10000);
        SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
        SendClientMessage(playerid, COLOR_RED, "Bomb:you got +5 score and 10000$ for defusing bomb");
        dbomb[playerid] = 0;
    }
    GameTextForAll("~r~Bomb defused",6000,5);
    PlantedBomb = 0;
    return 1;
    KillTimer(Explode[playerid]);
}
Reply
#2

bump
Reply
#3

bump
Reply
#4

Please wait at least 24 hours before bumping your topics... Give us some time to look at it...
Reply
#5

Here's the problem: 'return 1' ends the function, but you have the killtimer-function after "return 1;" so it won't get executed. So just move the killtimer-function above the return 1 and it should work.
This applies to both Explosion(playerid) and Defusion(playerid) callbacks.
Reply
#6

pawn Код:
#include <a_samp>
#define COLOR_RED 0xFF0000AA
#define COLOR_BLUE 0x0000BBAA

new PostaviTim[MAX_PLAYERS];
new bool:PlantedBomb;
new ExplodeTimer;

public OnGameModeInit()
{
    PlantedBomb = false;
    return 1;
}

public OnPlayerConnect(playerid)
{
    PostaviTim[playerid] = 0;
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(!PostaviTim[playerid])
    {
        switch(random(2))
        {
            case 0: PostaviTim[playerid] = 1;
            case 1: PostaviTim[playerid] = 2;
        }
        //SetPlayerSkin(playerid, ID Skina); // Ovo stavi ako hoces
    }
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp("/plantbomb", cmdtext, true))
    {
        if(PostaviTim[playerid] == 2) return SendClientMessage (playerid, COLOR_RED, "Cops can't plant bomb");
        if(!IsPlayerInRangeOfPoint(playerid, 2.0, 212.9239, 1820.3402, 6.4216)) return SendClientMessage(playerid, COLOR_RED, "You are not in the place for planting the bomb");
        if(PlantedBomb) return SendClientMessage(playerid, COLOR_RED, "Bomb is already planted!");
        PlantedBomb = true;
        GameTextForAll("~r~Bomb has been planted!", 3000, 5);
        ExplodeTimer = SetTimerEx("Explosion", 300000, false, "i", playerid);
        return 1;
    }
    if(!strcmp("/defusebomb", cmdtext, true))
    {
        if(PostaviTim[playerid] != 2) return SendClientMessage (playerid, COLOR_RED, "Only cops can defuse bomb");
        if(!IsPlayerInRangeOfPoint(playerid, 2.0, 212.9239, 1820.3402, 6.4216)) return SendClientMessage(playerid, COLOR_RED, "You are not in the place for planting the bomb");
        if(!PlantedBomb) return SendClientMessage(playerid, COLOR_RED, "Bomb is not planted!");
        SendClientMessage(playerid, COLOR_RED, "You are defusing a bomg, please wait...");
        SetTimerEx("Defusion", 20000, false, "i", playerid);
        return 1;
    }
    return 0;
}

forward Explosion(playerid);
public Explosion(playerid)
{
    if(!IsPlayerConnected(playerid))
    {
        GameTextForAll("~r~Bomb destroyed", 6000, 5);
        PlantedBomb = false;
        return 1;
    }
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
    GivePlayerMoney(playerid, 10000);
    SendClientMessage(playerid, COLOR_RED, "Bomb:you got +5 score and 10000$ for planting bomb");
    GameTextForAll("~r~Bomb exploded", 6000, 5);
    CreateExplosion(212.9239, 1820.3402, 6.4216, 12, 20.0);
    PlantedBomb = false;
    return 1;
}

forward Defusion(playerid);
public Defusion(playerid)
{
    if(!IsPlayerConnected(playerid)) return 1;
    GivePlayerMoney(playerid, 10000);
    SetPlayerScore(playerid, GetPlayerScore(playerid) + 5);
    SendClientMessage(playerid, COLOR_RED, "Bomb:you got +5 score and 10000$ for defusing bomb");
    GameTextForAll("~r~Bomb defused", 6000, 5);
    PlantedBomb = false;
    KillTimer(ExplodeTimer);
    return 1;
}
-_-
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)