SA-MP Forums Archive
problem with the code - 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: problem with the code (/showthread.php?tid=637855)



problem with the code - kronka - 22.07.2017

Good day, when this public is called, will teleport only one person, and in fact should teleport all.
Player[playerid][lobby_gamer] - works fine I checked.
The problem is somewhere in the public

Код:
public game(playerid)
{
	SetTimer("bot_stop", 120000, false);

	Player[playerid][LastKills] = 0;
	lobby_start = 0;
	print("Match started");
	SendClientMessageToAll(0x00FF40FF,"game starting");
	game_start = 1;
	spawn_loot();
	SetTimer("inplane", 120000, false);
	foreach(new i:Player)
	{
		if(IsPlayerNPC(i)) return true;
		if(Player[i][lobby_gamer] == 1)
		{
			TogglePlayerSpectating(i, 1);
			PlayerSpectateVehicle(i, AirplaneNPC);
			SendClientMessage(i, 0x00FFFFFF, "{FF8000}la la la la: {00FF00}F");
			Player[i][InPlane] = 1;
			max_gamers++;
			max_top++;
			printf("All survivals: %d", max_gamers);
			SetPlayerPos(i, 0, 0, 2);
			return 1;
		}
 	}
	return 1;
}



Re: problem with the code - Kaperstone - 22.07.2017

you have `return 1;` which stops the callback.


Re: problem with the code - iLearner - 22.07.2017

Its supposed to teleport only 1 player.


Re: problem with the code - Paulice - 22.07.2017

Replace the first return with continue. Remove the second return.

Returning a value in a loop, breaks the loop and exists the function.


Re: problem with the code - kronka - 22.07.2017

Quote:
Originally Posted by Kaperstone
Посмотреть сообщение
you have `return 1;` which stops the callback.
what should I do? I do not understand


Re: problem with the code - Paulice - 22.07.2017

Quote:
Originally Posted by kronka
Посмотреть сообщение
what should I do? I do not understand
Above your post!


Re: problem with the code - kronka - 22.07.2017

warning 209: function "game" should return a value


Re: problem with the code - kronka - 22.07.2017

Quote:
Originally Posted by Paulice
Посмотреть сообщение
Above your post!
warning 209: function "game" should return a value


Re: problem with the code - Paulice - 22.07.2017

Quote:
Originally Posted by kronka
Посмотреть сообщение
warning 209: function "game" should return a value
Leave the last return there. You have 3 returns fyi.