boolean command
#1

Код:
CMD:radiusfreeze(playerid, params[])
{
	new string[128], bool:toggle, admin[MAX_PLAYER_NAME], radi;
	
	if( Player[playerid][pAdmin] < 1 ) return SCM(pid, ADMIN_COLOR, ADMIN_MESSAGE);
	
	if( radi > 100 && Player[playerid][pAdmin] < 1337 ) return SCM(pid, ADMIN_COLOR, " You cannot use more than 100!");
	
	if(sscanf(params, "f", radi)) return SCM(pid, -1, "{00E6FF}USAGE:{FFFFFF} /radiusfreeze [Range] {FF0000}(( USE AGAIN TO UNFREEZE ))");

	GetPlayerName(playerid, admin, sizeof(admin));
	
	for(new i = 0; i < MAX_PLAYERS; i++)
	{
		if(i == playerid) continue;
		if( bool:toggle == false )
		{
			RadiusDetector(radi, playerid, i);
			TogglePlayerControllable(i, 1);
			format(string, sizeof(string), "{FF6347}[EVENT]{33CCFF} Admin {FF0000}%s {33CCFF}has unfrozen you", admin);
			SCM(i, -1, string);
			toggle = false;
		}
		else
		{
			RadiusDetector(radi, playerid, i);
			TogglePlayerControllable(i, 0);
			format(string, sizeof(string), "{FF6347}[EVENT]{33CCFF} Admin {FF0000}%s {33CCFF}has frozen you.", admin);
			SCM(i, -1, string);
			toggle = true;
		}
	}
	return 1;
}
I want to have this command to toggle the "radiusfreeze" command - if it is entered once it will freeze the player, and if it is entered again it will unfreeze the player. I tried to make this command to make my learning of booleans expand - I know that they are 2 switches - true and false, and it is automatically set to false.

What is wrong with this script? Whenever I type "radiusfreeze" twice it sends the message with "Admin %s has unfrozen you" , and unfreezes the player.
Reply


Messages In This Thread
boolean command - by JXF - 11.07.2016, 18:14
Re: boolean command - by Freaksken - 11.07.2016, 18:23
Re: boolean command - by Vince - 11.07.2016, 18:33
Re: boolean command - by JXF - 11.07.2016, 18:39
Re: boolean command - by Freaksken - 11.07.2016, 18:40
Re: boolean command - by JXF - 11.07.2016, 19:08

Forum Jump:


Users browsing this thread: 1 Guest(s)