View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 01-19-2020 , 13:42   Re: COD: HitMarkers [First release: 16/01/2020]
Reply With Quote #23

Xalus did not say "do not use pcvars", he said fXPos, fYPos, fHoldTime variables do not have to be global since they are used in only one function.

You should do:
PHP Code:
//In PostTakeDamage:
new fXPos get_pcvar_float(pXPosition);
new 
fYPos get_pcvar_float(pYPosition);
new 
fHoldTime get_pcvar_float(pHoldTime); 
Quote:
Half-Life, Gearbox, CS 1.6. Your code. Anytime get_user_team is introduced without the cstrike_running() other mods are no longer compatible. Take 'get_user_team' out, they work. Put it back with cstrike_running() it bridges the gap. It then works on more than 1 mod.
This doesn't make any sense.
get_user_team IS NOT CS specific. cs_get_user_team is. By adding cstrike_running the only thing you did is prevent the code from running in any other mod because the point of the native is to check if cstrike is running. If it isn't, then the if check will fail and no code will be executed.

I don't think I have to explain further, but:
PHP Code:
if(is_user_connected(iAttacker) && get_pcvar_num(pPlugin) && cstrike_running() && get_user_team(iVictim) != get_user_team(iAttacker)) 
Reads as: if user is connected, plugin is on, MOD IS CSTRIKE, and victim and attacker are on different teams do something. If mod is not cstrike the entire if fails and nothing is executed and the plugin is as good as disabled.
@OP, remove that check.

Quote:
He can use static variable to hold the value which will more optimized but the cvar change won't be set immediately. Need to change the map.
No, it won't be any more optimized.

Quote:
cvars are there to be changed immediatly, i won't be changing my code which will lead the plugin to require a map change in order for the cvars to change, even though that would optimize my code.
You are right about one thing: cvars are there to be changed immediately. Plus you are not losing any performance by not caching the cvars so there's literally 0 point in doing so in this case(and in most if not all cases).

P.S: having 2 versions for a small change seems overkill. Add a cvar and have only one version.
__________________

Last edited by HamletEagle; 01-19-2020 at 13:45.
HamletEagle is offline