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

[ Solved ] Optimization or not.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-27-2012 , 09:53   [ Solved ] Optimization or not.
Reply With Quote #1

Hello
I do a code :

Code:
#include < amxmodx > public plugin_init( ) {     register_plugin( "Score information" , "1.0" , "Aooka" ); } public ScoreMsg( victim , attacker ) {     if( is_user_alive( attacker ) || !is_user_alive( attacker ) && !is_user_alive( victim ) )     {         new szPseudoVictim[ 32 ] , szPseudoAttacker[ 32 ];                 get_user_name( victim , szPseudoVictim , charsmax( szPseudoVictim ) );         get_user_name( attacker , szPseudoAttacker , charsmax( szPseudoAttacker ) );                 client_print( victim , print_center , "You were killed by %s" , szPseudoAttacker );         client_print( attacker , print_center , "You killed %s" , szPseudoVictim );     } }

I wanted to know if it was correct and well optimized.

Thanks^^
__________________
Pawn ? Useless
Aooka is offline
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 05-27-2012 , 10:00   Re: [REQ] Optimization or not.
Reply With Quote #2

What is "ScoreMsg"?
__________________
<VeCo> is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-27-2012 , 10:01   Re: [REQ] Optimization or not.
Reply With Quote #3

It's just the name of my function. I did not know what to choose ^^ Why ?
__________________
Pawn ? Useless
Aooka is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 05-27-2012 , 11:23   Re: [REQ] Optimization or not.
Reply With Quote #4

ScoreMsg comes from where ? You don't provide the full code.
__________________
Arkshine is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-27-2012 , 11:33   Re: [REQ] Optimization or not.
Reply With Quote #5

No it's really the complete code. I assure you.
I took a random function name
__________________
Pawn ? Useless
Aooka is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-27-2012 , 19:33   Re: [REQ] Optimization or not.
Reply With Quote #6

So ... I just change the function name but ...
Code:
#include < amxmodx > public plugin_init( ) {     register_plugin( "Score information" , "1.0" , "Aooka" ); } public ScoreInfo( victim , attacker ) {     if( is_user_alive( attacker ) || !is_user_alive( attacker ) && !is_user_alive( victim ) )     {         new szPseudoVictim[ 32 ] , szPseudoAttacker[ 32 ];                 get_user_name( victim , szPseudoVictim , charsmax( szPseudoVictim ) );         get_user_name( attacker , szPseudoAttacker , charsmax( szPseudoAttacker ) );                 client_print( victim , print_center , "You were killed by %s" , szPseudoAttacker );         client_print( attacker , print_center , "You killed %s" , szPseudoVictim );     } }
__________________
Pawn ? Useless
Aooka is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 05-27-2012 , 19:44   Re: [REQ] Optimization or not.
Reply With Quote #7

So what's the question here?

Your function needs to be executed to actually do something.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 05-27-2012 , 20:26   Re: [REQ] Optimization or not.
Reply With Quote #8

Post the full code man.

Edit: Well, try this:

Code:
#include < amxmodx > #include < csx > public client_death( attacker , victim ) {     new szPseudoVictim[ 32 ] , szPseudoAttacker[ 32 ];         get_user_name( victim , szPseudoVictim , charsmax( szPseudoVictim ) );     get_user_name( attacker , szPseudoAttacker , charsmax( szPseudoAttacker ) );         client_print( victim , print_center , "You were killed by %s" , szPseudoAttacker );     client_print( attacker , print_center , "You killed %s" , szPseudoVictim ); }

Last edited by kramesa; 05-27-2012 at 20:38.
kramesa is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 05-27-2012 , 22:40   Re: [REQ] Optimization or not.
Reply With Quote #9

Quote:
Originally Posted by Aooka View Post
No it's really the complete code. I assure you.
I took a random function name
It's the correct code, up until the function is called, because it's never called so it will never execute. Thus, it will never do anything.
__________________
Hi.
Kreation is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 05-28-2012 , 04:37   Re: [REQ] Optimization or not.
Reply With Quote #10

I forgot my register_event ( lol ) :
Code:
#include < amxmodx > public plugin_init( ) {     register_plugin( "Score information" , "1.0" , "Aooka" );         register_event( "DeathMsg" , "HookDeath" , "d" ); } public HookDeath( victim , attacker ) {     if( is_user_alive( attacker ) || !is_user_alive( attacker ) && !is_user_alive( victim ) )     {         new szPseudoVictim[ 32 ] , szPseudoAttacker[ 32 ];                 get_user_name( victim , szPseudoVictim , charsmax( szPseudoVictim ) );         get_user_name( attacker , szPseudoAttacker , charsmax( szPseudoAttacker ) );                 client_print( victim , print_center , "You were killed by %s" , szPseudoAttacker );         client_print( attacker , print_center , "You killed %s" , szPseudoVictim );     } }

So I think the code is now good ( sorry ^^ ).

And I think it's the same with this code :
Code:
#include < amxmodx > #include < csx > public client_death( attacker , victim ) {     new szPseudoVictim[ 32 ] , szPseudoAttacker[ 32 ];         get_user_name( victim , szPseudoVictim , charsmax( szPseudoVictim ) );     get_user_name( attacker , szPseudoAttacker , charsmax( szPseudoAttacker ) );         client_print( victim , print_center , "You were killed by %s" , szPseudoAttacker );     client_print( attacker , print_center , "You killed %s" , szPseudoVictim ); }
__________________
Pawn ? Useless
Aooka 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:53.


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