AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Resetting values (https://forums.alliedmods.net/showthread.php?t=241154)

egbertjan 05-29-2014 04:44

Resetting values
 
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?

Black Rose 05-29-2014 04:52

Re: Resetting values
 
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)

Flick3rR 05-29-2014 05:15

Re: Resetting values
 
If they are global, just set them to zero when player disconnescts in client_disconnect.

Black Rose 05-29-2014 07:13

Re: Resetting values
 
That will not release the memory.

aron9forever 05-29-2014 10:39

Re: Resetting values
 
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)

egbertjan 05-29-2014 10:45

Re: Resetting values
 
Alright thanks for all the information :)


All times are GMT -4. The time now is 09:36.

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