Raised This Month: $ Target: $400
 0% 

[ Solved ] Ham killd & array[][]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-26-2012 , 05:57   [ Solved ] Ham killd & array[][]
Reply With Quote #1

Hello, just one question. Why it do not work ?

Code:
#include < amxmodx > #include < hamsandwich > public plugin_init( ) {     register_plugin( "test" , "1.0" , "Aooka" );         RegisterHam( Ham_Killed , "player" , "Fw_HamKilled" , true ); } public Fw_HamKilled( id , attacker , shouldgib ) {     new szName[ 2 ][ 36 ];         szName[ 0 ][ 36 ] = get_user_name( id , szName[ 0 ] , 35 );     szName[ 1 ][ 36 ] = get_user_name( attacker , szName[ 1 ] , 35 );         client_print( 0 , print_chat , "%s kill %s" , szName[ 1 ] , szName[ 0 ] ); }

Thx
__________________
Pawn ? Useless
Aooka is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 06-26-2012 , 07:21   Re: [REQ] Ham killd & array[][]
Reply With Quote #2

Code:
new szName[ 33 ][ 2 ] public Fw_HamKilled( id , attacker , shouldgib ) {     get_user_name( id , szName[ 0 ] , sizeof(szName[ ]) - 1  );     get_user_name( attacker , szName[ 1 ] , sizeof(szName[ ]) - 1 );         client_print( 0 , print_chat , "%s kill %s" , szName[ 1 ] , szName[ 0 ] ); }
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 06-26-2012 , 08:22   Re: [REQ] Ham killd & array[][]
Reply With Quote #3

new szName[ 33 ][ 2 ]
->
new szName[ 2 ][ 33 ]
jimaway is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-26-2012 , 09:02   Re: [REQ] Ham killd & array[][]
Reply With Quote #4

Leave it the way it is apart from:
Code:
szName[ 0 ][ 36 ] = get_user_name( id , szName[ 0 ] , 35 ); szName[ 1 ][ 36 ] = get_user_name( attacker , szName[ 1 ] , 35 );
->
Code:
get_user_name( id , szName[ 0 ] , 35 ); get_user_name( attacker , szName[ 1 ] , 35 );
String returning functions are passed by ref, not directly. And when dealing with arrays that are used as strings, it's a better habit to use charsmax( szName[] ) for readability.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Aooka
Veteran Member
Join Date: Aug 2011
Location: Villeurbanne
Old 06-26-2012 , 09:56   Re: [REQ] Ham killd & array[][]
Reply With Quote #5

Okay thanks all i test it
__________________
Pawn ? Useless
Aooka is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-26-2012 , 10:48   Re: [REQ] Ham killd & array[][]
Reply With Quote #6

Here's what you should have:

PHP Code:
new szName][ 33 ];
get_user_nameid szName] , charsmaxszName[] ) );
get_user_nameattacker szName] , charsmaxszName[] ) ); 
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-26-2012 , 11:17   Re: [REQ] Ham killd & array[][]
Reply With Quote #7

PHP Code:
new szName][ 32 ];
get_user_nameid szName] , charsmaxszName[] ) );
get_user_nameattacker szName] , charsmaxszName[] ) ); 
Fixed size to 32.

Code:
] name 
"name" is "01234567890123456789012345678901234"
] say hi
0123456789012345678901234567890 : hi
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 06-26-2012 , 11:22   Re: [REQ] Ham killd & array[][]
Reply With Quote #8

While we're on that topic, what is the official max steam-id length?
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-26-2012 , 11:24   Re: [REQ] Ham killd & array[][]
Reply With Quote #9

No idea, was using like 22 in the past, but now i use 32 to be large.
I think i've read somewhere that it was 35.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-26-2012 , 11:30   Re: [REQ] Ham killd & array[][]
Reply With Quote #10

Probably read it here http://www.amxmodx.org/funcwiki.php?...thid&go=search
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.
hornet is offline
Reply


Thread Tools
Display Modes

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 06:05.


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