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

Performance Issue


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerM
BANNED
Join Date: Nov 2019
Old 04-05-2022 , 06:44   Performance Issue
Reply With Quote #1

Hello.

I uploaded my addons to a host, and i get just 2 simple errors/warns idk, but with a continues spamming.
I used Pod Bot to test the host.

Code:
L 04/04/2022 - 20:54:00: [G-MIX-PUBLIC.amxx] performance issue. Function client_PostThink executed more than 3.5ms.
L 04/04/2022 - 20:53:57: [G-MIX-PUBLIC.amxx] performance issue. Function client_PreThink executed more than 1.1ms.
Code:
// vip sistem
public client_PostThink(id)
{
	if(!is_user_alive(id)) return PLUGIN_HANDLED;

	if(HeJumped[id] == 1 && Vip[id] != 0)
	{
		new Float:velocity[3];
		entity_get_vector(id, EV_VEC_velocity, velocity), velocity[2] = random_float(265.0, 285.0), entity_set_vector(id, EV_VEC_velocity, velocity), HeJumped[id] = 0;
		return PLUGIN_CONTINUE;
	}
	return PLUGIN_CONTINUE
}
public client_PreThink(id)
{
	if(!is_user_alive(id) || Vip[id] < 1) return PLUGIN_HANDLED;


	new nbut = get_user_button(id), obut = get_user_oldbutton(id);
	if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP)) if(JumpCounter[id] < 1) HeJumped[id] = 1, JumpCounter[id]++
	if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND)) JumpCounter[id] = 0;

	if(get_user_button(id) & IN_USE)
	{
		if(!(get_entity_flags(id) & FL_ONGROUND))
		{
			new Float:velocity[3];
			entity_get_vector(id, EV_VEC_velocity, velocity);
			if(velocity[2] < 0)
			{
				if(ParachuteObject[id] == 0)
				{
					ParachuteObject[id] = create_entity("info_target");
					if(ParachuteObject[id] > 0) return entity_set_int(ParachuteObject[id], EV_INT_movetype, MOVETYPE_FOLLOW), entity_set_edict(ParachuteObject[id], EV_ENT_aiment, id);
				}
				if(ParachuteObject[id] > 0)
				{
					velocity[2] = (velocity[2] + 40.0 < -100) ? velocity[2] + 40.0 : -100.0, entity_set_vector(id, EV_VEC_velocity, velocity);
					if(entity_get_float(ParachuteObject[id], EV_FL_frame) < 0.0 || entity_get_float(ParachuteObject[id], EV_FL_frame) > 254.0)
					{
						if(entity_get_int(ParachuteObject[id], EV_INT_sequence) != 1) entity_set_int(ParachuteObject[id], EV_INT_sequence, 1);
						entity_set_float(ParachuteObject[id], EV_FL_frame, 0.0);
					}
					else return entity_set_float(ParachuteObject[id], EV_FL_frame, entity_get_float(ParachuteObject[id], EV_FL_frame) + 1.0)
				}
			}
			else if(ParachuteObject[id] > 0) remove_entity(ParachuteObject[id]), ParachuteObject[id] = 0;
		}
		else if(ParachuteObject[id] > 0) remove_entity(ParachuteObject[id]), ParachuteObject[id] = 0;
	}
	else if(get_user_oldbutton(id) & IN_USE) { if(ParachuteObject[id] > 0) remove_entity(ParachuteObject[id]), ParachuteObject[id] = 0; }
	return PLUGIN_CONTINUE;
}

Last edited by StrikerM; 04-05-2022 at 06:46.
StrikerM is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 04-05-2022 , 06:48   Re: Performance Issue
Reply With Quote #2

Using float natives without float numbers and why you are using comma instead of ; or enter space?
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
StrikerM
BANNED
Join Date: Nov 2019
Old 04-05-2022 , 06:54   Re: Performance Issue
Reply With Quote #3

Quote:
Originally Posted by Supremache View Post
Using float natives without float numbers and why you are using comma instead of ; or enter space?
Yea, i use comma instead of ; because it's one after another one and dosen't matter at all.

But the thing about float yea, idk.
StrikerM is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 04-05-2022 , 08:04   Re: Performance Issue
Reply With Quote #4

you clearly have more plugins that slow the execution times down

Code:
public client_PreThink(id) {     new nbut = get_user_button(id), obut = get_user_oldbutton(id);     if(get_user_button(id) & IN_USE)     else if(get_user_oldbutton(id) & IN_USE)

no reason to call get_user_(old)button multiple times in prethink

Code:
velocity[2] = (velocity[2] + 40.0 < -100) ? velocity[2] + 40.0 : -100.0, entity_set_vector(id, EV_VEC_velocity, velocity);

awful readability and no performance gain over if () else

[G-MIX-PUBLIC.amxx] could be reporting false information and there's nothing to worry about. you could go through all the plugins and optimize the code to reduce execution times. or just get a more powerful cpu on your host machine

you're creating an entity for a parachute, but i don't see you ever assigning a model to that entity?
jimaway is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 04-05-2022 , 22:17   Re: Performance Issue
Reply With Quote #5

Quote:
Originally Posted by StrikerM View Post
Yea, i use comma instead of ; because it's one after another one and dosen't matter at all.

But the thing about float yea, idk.
Use new lines and braces. Absolutely no reason to not do this. Not doing this make code very hard to read and understand. It can also actually mask coding and/or logic issues in the code.
__________________
fysiks is offline
StrikerM
BANNED
Join Date: Nov 2019
Old 04-07-2022 , 08:00   Re: Performance Issue
Reply With Quote #6

good, thanks guys
StrikerM is offline
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 10:15.


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