Optimize code, menu and nvault
PHP Code:
And the menu sometimes shows the wrong level of the weapon. What can be? Any suggestions to optimize the code? |
Re: Optimize code, menu and nvault
Someone?
|
Re: Optimize code, menu and nvault
There's quite a number of issues here.
First of all, you can't level up, because you start at level 0 and level * 10.0 = 0.0 . ( Just note that I've only added and edited parts to make your plugin work, not to make it more efficient ) So change your Ham_TakeDamage hook to: Code:
public fwd_TakeDamage_Pre(victim, inflictor, attacker, Float:damage, damage_bits) Code:
public menu_handler(id, menu, item) So instead you can save and load according to the structure: Code:
And change client_putinserver() to this: Code:
See how it goes. Also, I'd recommend that you don't use is_user_connected() to ensure that the attacker is indeed a player in your Ham_TakeDamage and Ham_Killed hooks. |
Re: Optimize code, menu and nvault
try this.... in the Load() function
Code:
static space = 0also g_iSave[33][33] :arrow: g_iSave[33][32] SteamIDs are only 32, you don't need to set it to 33, its one extra bit you don't need. Relatively negligible in the long run, but an optimization, if you care about it. EDIT: looking at how hornet fixed your code.....the first half of this is obsolete. The second half is still just a little something. Oh...and instead of using client_putinserver() use client_authorized(id) because this is based completely on the authorization of the client (using their SteamID) you want to make sure they actually have one when you execute the body of it. doing it this way will ensure that. client_putinserver(id) is called when the client gets prompted the MOTD, while client_authorized() is called when the client has a proper SteamID placed to his credentials. |
Re: Optimize code, menu and nvault
He doesn't want to count the spaces. It looks as though he thought that he could retrieve the level by getting the character after the space.
Quote:
http://www.amxmodx.org/funcwiki.php?...rver&go=search |
Re: Optimize code, menu and nvault
Quote:
and i suppose your right, but i still believe that in order to make sure its proper (because it doesn't call any private data other than SteamID) i'd use it from client_authorized(). But from what i hear typically authorization is done before putinserver. But i have seen people have STEAM_ID_PENDING when they are spawned. It all depends on his level of acceptable malfunction. :P |
Re: Optimize code, menu and nvault
Thanks, i'll test it
EDIT Hornet, Yes, this is an older version. I've made sure the player has level in TakeDamage .. Anyway, everything is working perfectly(Save,Load, Menu..), thanks. |
| All times are GMT -4. The time now is 00:21. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.