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

Optimal use?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krystek.
Member
Join Date: May 2022
Old 05-13-2022 , 05:24   Optimal use?
Reply With Quote #1

Is the use of any code somehow more optimal, doesn't it matter?

Code:
RegisterHam(Ham_Killed, "player", "SmiercGraczaPost", 1);

public SmiercGraczaPost(index, attacker, shouldgib) {	
	if(!is_user_connected(attacker))
		return HAM_IGNORED;
		
	if(get_user_team(index) != get_user_team(attacker) && klasa_gracza[attacker])
	{
		new nowe_doswiadczenie = doswiadczenie_za_zabojstwo;
		
		if(poziom_gracza[index] > poziom_gracza[attacker])
			nowe_doswiadczenie += ( poziom_gracza[index] - poziom_gracza[attacker] ) * ( doswiadczenie_za_zabojstwo / 10 );
			
		if(!perk_gracza[attacker])
			UstawPerk(attacker, -1, -1, 1);
		gracz_zdobyl_expa[attacker] += nowe_doswiadczenie;
		client_print(attacker, print_center, "+%i EXP'a", nowe_doswiadczenie);
	}
	
	SprawdzPoziom(attacker);
	
	return HAM_IGNORED;
}
or maybe?

Code:
 
public client_death(killer, victim) {
	if(!is_user_connected(killer))
		return PLUGIN_CONTINUE;
		
	if(get_user_team(victim) != get_user_team(killer) && klasa_gracza[killer])
	{
		new nowe_doswiadczenie = doswiadczenie_za_zabojstwo;
		
		if(poziom_gracza[victim] > poziom_gracza[killer])
			nowe_doswiadczenie += ( poziom_gracza[victim] - poziom_gracza[killer] ) * ( doswiadczenie_za_zabojstwo / 10 );
			
		if(!perk_gracza[killer])
			UstawPerk(killer, -1, -1, 1);
		gracz_zdobyl_expa[killer] += nowe_doswiadczenie;
		client_print(killer, print_center, "+%i EXP'a", nowe_doswiadczenie);
	}

	SprawdzPoziom(killer);
	
	return PLUGIN_CONTINUE;
}
Krystek. is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 05-13-2022 , 07:35   Re: Optimal use?
Reply With Quote #2

What do you think, hooking client death using "hamsandwich" or using the existing forward from "csx"
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-13-2022 , 08:56   Re: Optimal use?
Reply With Quote #3

The question is not about optimality. Depending on what features you need in your plugin, you use one or the other.
__________________
HamletEagle 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 04:00.


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