Raised This Month: $51 Target: $400
 12% 

Problem with freezing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-27-2021 , 15:37   Problem with freezing
Reply With Quote #1

It's part of the code, there's some command I can freeze player / team \ and all players

If I make a !freeze <name> for for player <name> it works and if I do again it unfreeze him well
Everything works just the glitch below:

Once I !freeze <player> then I want to freeze his team it causes a problem that after that I can not at all unfreeze, the freeze it gets stuck for everyone or we just get stuck for a person who got a freeze before his team
Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <fakemeta>
#include <fun>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define	PREFIX			"^4[Cmd]^1"

enum _:CMD_STRUCT
{
	CMD_NAME	[32],
	CMD_INCHAT	[32],
	CMD_SRV		[32],
	CMD_USAGE	[128],
	CMD_LEVEL,
};

enum _:Commands
{
	FREEZE,
};

new const CommandsList[Commands][CMD_STRUCT] = 
{
	{"Freeze",			"freeze",	"",	"<^3@all/@t/@ct/target^1>", 		ADMIN_LEVEL_C		},	// !freeze	- flag b
};

new Float:fAngles	[MAX_PLAYERS + 1][3];
new bool:g_gFrozen; // frozen in game.
new bool:g_bFrozen	[MAX_PLAYERS + 1]; // frozen in player.
new gCmdPointer		[Commands];

public plugin_init()
{
	register_plugin	(PLUGIN, VERSION, AUTHOR);
	register_clcmd	("say", "HandleSay");
	register_clcmd	("say_team", "HandleSay");
	
	register_forward(FM_PlayerPreThink, "FreezeSpeed");
	
	RegisterHam		(Ham_Spawn, "player", "StartRoundPlayer");
	register_logevent("StartRound", 2, "1=Round_Start");
	
	for (new i = 0; i < Commands; i++)
	{
		if (strlen(CommandsList[i][CMD_SRV]) > 0)
			gCmdPointer[i] = get_cvar_pointer(CommandsList[i][CMD_SRV]);
	}
}

// Say Command Handler.
public HandleSay(client)
{
	new said[32];
	new param[32];
	new szMessage[charsmax(said) + charsmax(param) + 2];
   
	read_argv(1, szMessage, charsmax(szMessage));
	argbreak(szMessage, said, charsmax(param), param, charsmax(param));
 
	for (new i = 0; i < Commands; i++)
	{
		if (equali(said[1], CommandsList[i][CMD_INCHAT]))
		{
			if (!(get_user_flags(client) & CommandsList[i][CMD_LEVEL]))
			{
				client_print_color(client, print_team_default, "%s ^3Error^1: You don't have Access Level.", PREFIX);
				continue;
			}
			CommandSelector(i, client, param);
			return PLUGIN_HANDLED;
		}
	}
	return PLUGIN_CONTINUE;
}

public StartRoundPlayer(id)
{
	g_bFrozen[id] = false;
}

// Round Start: In Game.
public StartRound()
{
	g_gFrozen = false;
}

// Say Command Handler (Selector).
CommandSelector(cmd, client, param[])
{
	switch(cmd)
	{
		case FREEZE:        CmdFreeze       (client, param);
	}
}

// Check Parameter None.
bool:CheckUsage(client, cmd, param[])
{
	if (!param[0])
	{
		client_print_color(client, print_team_default, "%s Usage: '^4!%s ^1%s'", PREFIX, CommandsList[cmd][CMD_NAME], CommandsList[cmd][CMD_USAGE]);
		return false;		
	}
	return true;
}

// Command: Freeze Players.
CmdFreeze(client, param[])
{
	new players[32];
	new pnum = 0;
	new iFrozen = 0;
 
	// check param[] is none.
	if (!CheckUsage(client, FREEZE, param))
		return;

	g_gFrozen = !g_gFrozen;
 	if (GetMultiTargetPlayers(client, param, players, pnum, true, ALIVE_ONLY))
	{
		for (new i = 0; i < pnum; i++)
		{
			// Is Player Frozen?
			FreezePlayer(players[i], g_gFrozen);
			iFrozen++;
		}
		if (iFrozen)
			PrintFreeze(0, client, param, g_gFrozen);
		return;
	}

	new player;
	if (GetSingleTargetPlayer(client, param, player, true, ALIVE_ONLY))
	{
		g_bFrozen[player] = !g_bFrozen[player];
		FreezePlayer(player, g_bFrozen[player]);
		PrintFreeze(0, client, param, g_bFrozen[player]);
	}
 	return;
}

// --------------- Utility Logic. --------------------------
//	Switching Freeze.
FreezePlayer(id, bool:iValue)
{
	pev(id, pev_v_angle, fAngles[id]);
	g_bFrozen[id] = iValue;
	if (iValue)
		set_user_maxspeed(id, -1.0);
}

//	Freeze logic.
public FreezeSpeed(id)
{
	if (g_gFrozen && g_bFrozen[id])
	if (is_user_alive(id))
	{
		set_pev(id, pev_v_angle, fAngles);
		set_user_maxspeed(id, -1.0);
	}
	return HAM_IGNORED;
}

PrintFreeze(id, client, target[], iFrozen)
{
	trim(target);
	if (target[0] == '@')
	{
		if (equali(target, "@all"))
			client_print_color(id, print_team_default, "%s ^3%n ^1has %s to ^4everyone^1.", 		PREFIX, client, iFrozen ? "Freeze" : "UnFreeze");
		else if(equali(target, "@admin"))
			client_print_color(id, print_team_default, "%s ^3%n ^1has %s to ^4Admin^1.", 			PREFIX, client, iFrozen ? "Freeze" : "UnFreeze");
		else if(equali(target, "@ct"))
			client_print_color(id, print_team_default, "%s ^3%n ^1has %s to ^4CT Team^1.", 			PREFIX, client, iFrozen ? "Freeze" : "UnFreeze");
		else if(equali(target, "@t"))
			client_print_color(id, print_team_default, "%s ^3%n ^1has %s to ^4Terrorist Team^1.",	PREFIX, client, iFrozen ? "Freeze" : "UnFreeze");
		else
		{
			new player = GetTargetPlayer(target);
			client_print_color(id, print_team_default, "%s ^3%n ^1has %s to ^4%n^1.",				PREFIX, client, iFrozen ? "Freeze" : "UnFreeze", player);
		}
		return;
	}
	new player = GetTargetPlayer(target);
	client_print_color(id, print_team_default, "%s ^3%n ^1has %s to ^4%n^1.",						PREFIX, client, iFrozen ? "Freeze" : "UnFreeze", player);
	return;
}

Last edited by Fuck For Fun; 08-30-2021 at 13:46.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-29-2021 , 11:37   Re: Problem with freezing
Reply With Quote #2

Where is HandleSay? How is CmdFreeze() getting linked to HandleSay()? Please post the full plugin.

Is this someone elses plugin that you're trying to modify? If so I'd just start from scratch.

It looks like there are 2 booleans, g_gFrozen and g_bFrozen[]. I would use only the player-level boolean and keep track of each individual players freeze status. My initial thought is there is a conflict between g_fFrozen and g_bFrozen.
__________________
Bugsy is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 08-29-2021 , 12:58   Re: Problem with freezing
Reply With Quote #3

https://forums.alliedmods.net/showpo...42&postcount=9
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 08-30-2021 , 13:52   Re: Problem with freezing
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
Where is HandleSay? How is CmdFreeze() getting linked to HandleSay()? Please post the full plugin.

Is this someone elses plugin that you're trying to modify? If so I'd just start from scratch.

It looks like there are 2 booleans, g_gFrozen and g_bFrozen[]. I would use only the player-level boolean and keep track of each individual players freeze status. My initial thought is there is a conflict between g_fFrozen and g_bFrozen.
EDIT: Added HandleSay
Sorry I forgot to added it after some checks, and yes it's a code I use' not of someone. The only problem with checking a player gets FREEZE and unfreeze

I'll try to do a test without the Global booleans, But directly to the player
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:32.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode