SA-MP Forums Archive
Need Help with this Script - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need Help with this Script (/showthread.php?tid=282362)



Need Help with this Script - Tigerbeast11 - 10.09.2011

pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{
    if(Team[playerid] == TEAM_RED)
    {
        if(bombing == 0)
        {
            if(bombed == 0)
            {
                bombing = 1;
                bombingtimer = SetTimer("Bombing",1000,1);
            }
        }
        else
        {
            GameTextForPlayer(playerid,"~w~The ~r~ship ~w~is already being ~r~bombed!",3500,4);
        }
    }  
    else
    {
        GameTextForPlayer(playerid,"~w~Protect this ~r~area!",3500,1);
    }
    return 1;
}

forward Bombing(playerid);
public Bombing(playerid)
{
    gameseconds--;
    new name[24];
    new string[128];
    GetPlayerName(playerid,name,sizeof(name));
    format(string,sizeof(string),"%s is now placing explosives.~N~It will take %d seconds.",name,gameseconds);
    TextDrawSetString(bombingtxt,string);
    new explosion = 31;
    if(gameseconds <= -1)
    {
        explosion--;
        new string2[128];
        format(string2,sizeof(string2),"The ship will explode~N~in %d seconds.",explosion);
        TextDrawSetString(bombingtxt,string2);
        KillTimer(countdown);
        bombing = 0;
        bombed = 1;
        DisablePlayerCheckpoint(playerid);
    }
    if(explosion <= -1)
    {
        CreateExplosion(-2370,1552,3,0,80);
        CreateExplosion(-2371,1553,4,0,80);
        CreateExplosion(-2369,1551,2,0,80);
        TextDrawSetString(bombingtxt,"The ship is being exploded!");
        SetTimer("RedsWin",8000,0);
        KillTimer(bombingtimer);
        SetTimer("HideBomber",5500,0);
    }
    TextDrawShowForAll(bombingtxt);
}

forward RedsWin();
public RedsWin()
{
    for(new i; i < MAX_PLAYERS; i++)
    if(Team[i] == TEAM_RED)
    {
        GameTextForPlayer(i,"Mission Passed! ~N~~g~$7500",0,4500);
        GivePlayerMoney(i,7500);
    }
    else
    {
        GameTextForPlayer(i,"~r~Mission Failed!",0,4500);
    }
    SetTimer("OnGameModeExit",4500,0);
}

public OnPlayerLeaveCheckpoint(playerid)
{
    if(Team[playerid] == TEAM_RED)
    {
        if(bombed == 0)
        {
            new name[24];
            new string[128];
            GetPlayerName(playerid,name,sizeof(name));
            format(string,sizeof(string), "%s has stopped placing explosives",name);
            TextDrawSetString(bombingtxt,string);
            bombing = 0;
            KillTimer(bombingtimer);
            TextDrawShowForAll(bombingtxt);
            SetTimer("HideBomber",4500,0);
            gameseconds = 9;
        }
    }
    return 1;
}

forward HideBomber();
public HideBomber()
{
    TextDrawHideForAll(bombingtxt);
}
Now, what is mean to happen is this:
A player from the red team enters the checkpoint and it says it will take 7,6,5,4,etc. seconds to plant the bomb. Then after the bomb has been planted, the checkpoint should disappear and it should say, the ship will explode in 30, 29, 28, 27 etc. seconds. After 30 seconds, the ship will explode.

But what happens is that when I finish placing the bomb, it says the ship will explode in 29 seconds but it doesn't actually count down from 30. It works fine when it counts down from 8 but not from 30... What should I change?


Re: Need Help with this Script - [M]onsieur - 10.09.2011

Put
pawn Code:
new explosion = 31;
out of the public Bombing.

(set the variable explosion to 31 on init count down)


Re: Need Help with this Script - Tigerbeast11 - 10.09.2011

Quote:
Originally Posted by [M]onsieur
View Post
Put
pawn Code:
new explosion = 31;
out of the public Bombing.

(set the variable explosion to 31 on init count down)
Thanks, let me test it!


Re: Need Help with this Script - [M]onsieur - 10.09.2011

I hope, good luck.
If you can explain your situation/problem.

Thanks


Re: Need Help with this Script - Tigerbeast11 - 10.09.2011

Thanks, it works


Re: Need Help with this Script - Tigerbeast11 - 10.09.2011

Oh, wait, I found a problem:

pawn Code:
forward RedsWin();
public RedsWin()
{
    for(new i; i < MAX_PLAYERS; i++)
    if(Team[i] == TEAM_RED && IsPlayerConnected(i))
    {
        GameTextForPlayer(i,"Mission Passed! ~N~~g~$7500",0,4500);
        GivePlayerMoney(i,7500);
    }
    else
    {
        GameTextForPlayer(i,"~r~Mission Failed!",0,4500);
    }
    SetTimer("OnGameModeExit",4500,0);
}
After the explosion, it should say Mission Passed, but it only gave me the money and the game text didnt come up :/


Re: Need Help with this Script - [M]onsieur - 10.09.2011

Error maybe occurring with style gametext .. try it

pawn Code:
GameTextForPlayer(i,"Mission Passed! ~n~ ~g~$7500", 1, 4500);



Re: Need Help with this Script - Tigerbeast11 - 10.09.2011

Edit: FIXED