Raised This Month: $ Target: $400
 0% 

Resetting values


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 05-29-2014 , 04:44   Resetting values
Reply With Quote #1

Hello,

I would like to know if it has any use to reset all variables that I assign to players upon their leaving. Would this make it easier on your memory? I'm asking because I got a bunch of variables and maybe this is a way to optimize the plugin.

Code:
new flashlight[33]
new flashbattery[33]
new DemageTake[33]
new player_xp[33] = 0	
new player_lvl[33] = 1			
new player_point[33] = 0	
new player_intelligence[33]
new player_strength[33]
new player_agility[33]
new player_power[33]
new player_vampyric[33]
new Float:player_damreduction[33]
new player_dextery[33]
new player_class[33]		
new Float:player_huddelay[33]
new player_b_gravity[33] = 1	
new player_sorc_heal[33] = 0
new player_ultra_armor[33]
new player_ultra_armor_left[33]
new bool:new_class[33]
new bool:paladin_bullet[33]
new bool:HunterUlt_active[33]
new bool:NinjaUlt_active[33]
new NecroRevive[33]
new bool:BarbUlt[33] 
new bool:BarbUlt_used[33] 
new jumpnum[33] = 0
new bool:dojump[33] = false
new bool:autobuyxp[33] 
new GodLeft[33]
new AssassinUlt[33]
new HunterUlt[33]
new NecroUlt[33]
new NinjaUlt[33]
new loaded_xp[33]
new asked_sql[33]
new asked_klass[33]
new player_class_lvl[33][8]
new player_class_lvl_save[33]
new player_xp_old[33]
new database_user_created[33]
new last_update_xp[33]
new Float:last_update_perc[33]
new max_knife[33]
new player_knife[33]
new Float:tossdelay[33]
new Float:bowdelay[33]
new bow[33]
new button[33]
new trace_bool[33]
new g_TrapMode[33]
new Float:g_PreThinkDelay[33]
new casting[33]
new Float:cast_end[33]
new Float:HunterUlt_end[33]
new on_knife[33]
new golden_bulet[33]
new ultra_armor[33]
new after_bullet[33]
new invisible_cast[33]
new player_dmg[33]
If I were to put these on 0 upon client leave would this clear memory or would the space still be reserved?
egbertjan is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-29-2014 , 04:52   Re: Resetting values
Reply With Quote #2

The space is reserved as soon as that line is initialized if they're global or static.
If they're inside a function the memory is reset when the function ends. (I assume)
__________________

Last edited by Black Rose; 05-29-2014 at 04:54.
Black Rose is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 05-29-2014 , 05:15   Re: Resetting values
Reply With Quote #3

If they are global, just set them to zero when player disconnescts in client_disconnect.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-29-2014 , 07:13   Re: Resetting values
Reply With Quote #4

That will not release the memory.
__________________
Black Rose is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 05-29-2014 , 10:39   Re: Resetting values
Reply With Quote #5

memory isn't really an issue with hlds
we're talking about kilobytes here, nowadays it's useless to save a couple of em

what resetting all those values would do would increase cpu usage and nothing more
if you don't need them null for the next player that joins on that slot, then don't
if you already clear them when a client joins, don't

as stated above, global and static variables reserve memory and it will never be released until the server is closed(or the map changes which I'm not sure of but as soon as new map starts same thing)
aron9forever is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 05-29-2014 , 10:45   Re: Resetting values
Reply With Quote #6

Alright thanks for all the information
egbertjan 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 09:36.


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