Timer is not killing checkpoint
#1

Well... it kills the checkpoint only for id 0 :/ not for the rest of the players
Code:
public OnPlayerEnterCheckpoint(playerid)
{

	if(gTeam[playerid] == TEAM_RED) {
    bomb = SetTimer("bomb2", 10000, false);
    SendClientMessageToAll(0xDEEE20FF, "The bomb is being planted, it will take 10 seconds to activate it");
    

	}

	else if(gTeam[playerid] == TEAM_BLUE) {
	    GameTextForPlayer(playerid,
		   "Don't let the terrorists plant a bomb here",
		   6000,5);
	}

    return 1;
}

public bomb2(playerid)
{
        SendClientMessageToAll(0xDEEE20FF, "The bomb has been planted, you have 10 seconds to run away");
        CreateObject(1654,2636.1999512,-2094.5000000,12.6000004,272.8234863,314.9780273,134.0114746); //object(dynamite) (1)
        CreateObject(1654,2636.1999512,-2095.1000977,12.6000004,272.8234863,314.9780273,17.2614746); //object(dynamite) (2)
        CreateObject(1654,2636.3000488,-2094.8000488,12.6000004,272.8234863,314.9780273,285.0114746); //object(dynamite) (3)
        DisablePlayerCheckpoint(playerid);
	SetTimer("exp",10000,false);
        SetTimer("exp2",12000,false);
        SetTimer("exp3",15000,false);
        
}
Reply
#2

bump* come on help me!
Reply
#3

That's because you need to SetTimerEx
pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{

    if(gTeam[playerid] == TEAM_RED) {
    bomb = SetTimerEx("bomb2",10000,0,"i",playerid);
    SendClientMessageToAll(0xDEEE20FF, "The bomb is being planted, it will take 10 seconds to activate it");


    }

    else if(gTeam[playerid] == TEAM_BLUE) {
        GameTextForPlayer(playerid,
           "Don't let the terrorists plant a bomb here",
           6000,5);
    }

    return 1;
}

public bomb2(playerid)
{
        SendClientMessageToAll(0xDEEE20FF, "The bomb has been planted, you have 10 seconds to run away");
        CreateObject(1654,2636.1999512,-2094.5000000,12.6000004,272.8234863,314.9780273,134.0114746); //object(dynamite) (1)
        CreateObject(1654,2636.1999512,-2095.1000977,12.6000004,272.8234863,314.9780273,17.2614746); //object(dynamite) (2)
        CreateObject(1654,2636.3000488,-2094.8000488,12.6000004,272.8234863,314.9780273,285.0114746); //object(dynamite) (3)
        DisablePlayerCheckpoint(playerid);
        //If these three timers also affect a specific player, change them to SetTimerEx, same method.
        SetTimer("exp",10000,false);
        SetTimer("exp2",12000,false);
        SetTimer("exp3",15000,false);

}
Reply
#4

But with SetTimerEx it will only set a timer for the guy who planted the bomb, and that's not what I want!
Isn't SetTimer a global thing?
Reply
#5

Oh, then you'd have to make a loop, here:
pawn Code:
public OnPlayerEnterCheckpoint(playerid)
{

    if(gTeam[playerid] == TEAM_RED) {
    bomb = SetTimer("bomb2", 10000, false);
    SendClientMessageToAll(0xDEEE20FF, "The bomb is being planted, it will take 10 seconds to activate it");


    }

    else if(gTeam[playerid] == TEAM_BLUE) {
        GameTextForPlayer(playerid,
           "Don't let the terrorists plant a bomb here",
           6000,5);
    }

    return 1;
}

public bomb2()
{
        for(new i = 0; i < MAX_PLAYERS; i++)//This loop through all players.
        {
        SendClientMessageToAll(0xDEEE20FF, "The bomb has been planted, you have 10 seconds to run away");
        CreateObject(1654,2636.1999512,-2094.5000000,12.6000004,272.8234863,314.9780273,134.0114746); //object(dynamite) (1)
        CreateObject(1654,2636.1999512,-2095.1000977,12.6000004,272.8234863,314.9780273,17.2614746); //object(dynamite) (2)
        CreateObject(1654,2636.3000488,-2094.8000488,12.6000004,272.8234863,314.9780273,285.0114746); //object(dynamite) (3)
        DisablePlayerCheckpoint(i);
        SetTimer("exp",10000,false);
        SetTimer("exp2",12000,false);
        SetTimer("exp3",15000,false);
        }

}
Reply
#6

It worked, thank you!
Can you explain me what is a loop and what it does?
Reply
#7

I'd rather not try to explain it myself, so here: http://whatis.techtarget.com/definition/loop
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)