SA-MP Forums Archive
Bomb cp - 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: Bomb cp (/showthread.php?tid=590245)



Bomb cp - Face9000 - 27.09.2015

Can someone tell me why if i enter the checkpoint i get the message: "Someone is already planting the bomb" but i can plant it however?

Код:
public OnPlayerEnterCheckpoint(playerid)
{
	if(gTeam[playerid] == TEAM_DEFENDERS)
	{
	    GameTextForPlayer(playerid,"~w~Defend this bomb checkpoint from ~b~terrorists!",5000,4);
	}
	else if(gTeam[playerid] == TEAM_TERRORISTS)
	{
 		new name[MAX_PLAYER_NAME], string[128];
    	GetPlayerName(playerid, name, sizeof(name));
    	format(string, sizeof(string), "~r~%s ~w~will plant the ~r~bomb ~w~in 15 seconds!",name);
    	GameTextForAll(string,5000,4);
		BombTimer = SetTimer("Explode",15000,false);
		AlreadyPlanting[playerid] = 1;
		if(AlreadyPlanting[playerid] == 1)
		{
	    SendClientMessage(playerid, -1, "* Someone is already planting the {F2C80C}bomb, {FFFFFF}please wait.");
	    return 0;
		}
		if(Planted[playerid] == 1)
		{
	    SendClientMessage(playerid, -1, "* The {F2C80C}bomb {FFFFFF}has been planted already and it will explode soon.");
	    return 0;
		}
    }
	return 1;
}
Thanks.


Re: Bomb cp - J0sh... - 27.09.2015

Quote:
Originally Posted by Face9000
Посмотреть сообщение
Can someone tell me why if i enter the checkpoint i get the message: "Someone is already planting the bomb" but i can plant it however?

Код:
public OnPlayerEnterCheckpoint(playerid)
{
	if(gTeam[playerid] == TEAM_DEFENDERS)
	{
	    GameTextForPlayer(playerid,"~w~Defend this bomb checkpoint from ~b~terrorists!",5000,4);
	}
	else if(gTeam[playerid] == TEAM_TERRORISTS)
	{
		if(AlreadyPlanting[playerid] == 1)
		{
	    SendClientMessage(playerid, -1, "* Someone is already planting the {F2C80C}bomb, {FFFFFF}please wait.");
	    return 0;
		}
		if(Planted[playerid] == 1)
		{
	    SendClientMessage(playerid, -1, "* The {F2C80C}bomb {FFFFFF}has been planted already and it will explode soon.");
	    return 0;
		}
 		new name[MAX_PLAYER_NAME], string[128];
    	GetPlayerName(playerid, name, sizeof(name));
    	format(string, sizeof(string), "~r~%s ~w~will plant the ~r~bomb ~w~in 15 seconds!",name);
    	GameTextForAll(string,5000,4);
		BombTimer = SetTimer("Explode",15000,false);
		AlreadyPlanting[playerid] = 1;
    }
	return 1;
}
Thanks.
You checked after planting the bomb.


You might want to check the AlreadyPlanting[playerid] == 1 and loop through all players and check if they're planting.


Re: Bomb cp - Face9000 - 27.09.2015

Can you make me an example please?


Re: Bomb cp - J0sh... - 27.09.2015

Quote:
Originally Posted by Face9000
Посмотреть сообщение
Can you make me an example please?
Of the loop?
PHP код:
for(new 0MAX_PLAYERSi++) { //foreach(new i : Player) or GetPlayerPool(); for better preformance
    
if(gTeam[i] == TEAM_TERRORISTS) {
        
AlreadyPlanting[i] = 1;
    }

Then you would change AlreadyPlanting[i] = 0; in the bomb explosion timer.