Raised This Month: $ Target: $400
 0% 

get_user_name [shows server name] [help]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mAr7obg
Senior Member
Join Date: May 2007
Location: Bulgaria
Old 10-07-2009 , 06:41   get_user_name [shows server name] [help]
Reply With Quote #1

I use this script, but instead the name of the player earning the name of my server if I might help a little to optimize
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
public plugin_init() {
 
register_plugin"x-","x","x" )
 
register_event"DeathMsg",  "Event_Death",  "a" 
}
public 
Event_Death(id)  {
 
//random hud
 
new random(256)
 new 
random(256)
 new 
random(256)
 
//last player
 
new players_ct[32], players_t[32], ictite;
 
get_players(players_ct,ict,"ae","CT")   
 
get_players(players_t,ict,"ae","TERRORIST")  
 
// get players
 
new name[32]
 
get_user_name(id,name,31)
 if( 
ite == ) { 
  
client_cmd(0,"spk server/stayinalive"); 
  
set_hudmessage(r,g,b, -1.00.3006.06.0)
  
show_hudmessage(0"%s is alone :)"name)
  } else if( 
ict == ) { 
  
client_cmd(id,"spk server/stayinalive");
  
set_hudmessage(r,g,b, -1.00.3006.06.0)
  
show_hudmessage(0"%s is alone :)"name)
 }
}
public 
plugin_precache() {
 
precache_sound("server/stayinalive.wav")

mAr7obg is offline
Send a message via Skype™ to mAr7obg
Old 10-07-2009, 07:04
biscuit628
This message has been deleted by biscuit628. Reason: wrong
Jon
Veteran Member
Join Date: Dec 2007
Old 10-07-2009 , 07:13   Re: get_user_name [shows server name] [help]
Reply With Quote #2

There is no index passed in DeathMsg. You need to retrive the index with read_data(). http://wiki.amxmodx.org/Half-Life_1_...vents#DeathMsg
Jon is offline
mAr7obg
Senior Member
Join Date: May 2007
Location: Bulgaria
Old 10-07-2009 , 07:22   Re: get_user_name [shows server name] [help]
Reply With Quote #3

i resolved the problem with this code
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
public plugin_init() {
 
register_plugin"x-","x","x" )
 
register_event"DeathMsg",  "Event_Death",  "a" 
}
public 
Event_Death(id)  {
 
//random hud
 
new random(256)
 new 
random(256)
 new 
random(256)
 
//last player
 
new players_ct[32], players_t[32], ictite;
 
get_players(players_ct,ict,"ae","CT")   
 
get_players(players_t,ict,"ae","TERRORIST")  
 
// get players
 
new name1[32], name2[32]
 
get_user_name(players_ct[0],name1,32)
 
get_user_name(players_t[0],name2,32)
 if( 
ite == ) { 
  
client_cmd(0,"spk server/stayinalive"); 
  
set_hudmessage(r,g,b, -1.00.3006.06.0)
  
show_hudmessage(0"%s is alone :)"name1)
  } else if( 
ict == ) { 
  
client_cmd(id,"spk server/stayinalive");
  
set_hudmessage(r,g,b, -1.00.3006.06.0)
  
show_hudmessage(0"%s is alone :)"name2)
 }
}
public 
plugin_precache() {
 
precache_sound("server/stayinalive.wav")

mAr7obg is offline
Send a message via Skype™ to mAr7obg
mAr7obg
Senior Member
Join Date: May 2007
Location: Bulgaria
Old 10-07-2009 , 07:36   Re: get_user_name [shows server name] [help]
Reply With Quote #4

delte

Last edited by mAr7obg; 10-07-2009 at 07:42.
mAr7obg is offline
Send a message via Skype™ to mAr7obg
Alucard^
AMXX Moderator: Others
Join Date: Sep 2007
Location: Street
Old 10-07-2009 , 09:53   Re: get_user_name [shows server name] [help]
Reply With Quote #5

Good but the id in the public of the DeathMsg is useless. The DeathMsg is a global event.
__________________
Approved Plugins - Steam Profile

Public non-terminated projects:
All Admins Menu, HLTV parameters, Subnick,
Second Password (cool style), InfoZone,
Binary C4 plant/defuse, and more...

Private projects:
NoSpec (+menu), NV Surf Management,
PM Adanved System, KZ longjump2, and more...
Alucard^ is offline
Send a message via Skype™ to Alucard^
vitorrd
Senior Member
Join Date: Jul 2009
Old 10-07-2009 , 12:23   Re: get_user_name [shows server name] [help]
Reply With Quote #6

As Jon said, you must use read_data. Also, read http://www.amxmodx.org/funcwiki.php?go=func&id=165 for information on get_user_name. A note is written in the comments section stating that if the specified ID is 0, the server's name is returned (your variable is not used by DeathMsg, therefore it is 0).
vitorrd is offline
mAr7obg
Senior Member
Join Date: May 2007
Location: Bulgaria
Old 10-07-2009 , 13:15   Re: get_user_name [shows server name] [help]
Reply With Quote #7

Quote:
Originally Posted by Alucard^ View Post
Good but the id in the public of the DeathMsg is useless. The DeathMsg is a global event.
then how to do it without DeathMsg
Last version
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#define prpsounds 2
new preplist[prpsounds][]=
{
 
"server/stayinalive"
 
"server/force"
}
public 
plugin_init() {
 
register_plugin"x-","x","x" )
 
register_event"DeathMsg",  "Event_Death",  "a" 
}
public 
Event_Death(id)  {
 
//======== •Random colors
 
new random(256)
 new 
random(256)
 new 
random(256)
 
//======== •Last player
 
new players_ct[32], players_t[32], ictite;
 
get_players(players_ct,ict,"ae","CT")   
 
get_players(players_t,ict,"ae","TERRORIST")  
 
//======== •Get players
 
new name1[32], name2[32]
 
get_user_name(players_ct[0],name1,32)
 
get_user_name(players_t[0],name2,32)
 
//======== •Random Sounds
 
new q
 q 
random_num(0,prpsounds-1)
 
//======== •Begin
 
if( ite == ) { 
  
client_cmd(0,"spk %s",preplist[q]);
  
set_hudmessage(r,g,b, -1.00.3006.06.0)
  
show_hudmessage(0"%s is alone :)"name1)
  } else if( 
ict == ) { 
  
client_cmd(0,"spk %s",preplist[q]);
  
set_hudmessage(r,g,b, -1.00.3006.06.0)
  
show_hudmessage(0"%s is alone :)"name2)
 }
 
//======== •End
}
public 
plugin_precache() {
 
precache_sound("server/stayinalive.wav")
 
precache_sound("server/force.wav")
 return 
PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1026\\ f0\\ fs16 \n\\ par }
*/ 
mAr7obg is offline
Send a message via Skype™ to mAr7obg
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-07-2009 , 13:19   Re: get_user_name [shows server name] [help]
Reply With Quote #8

Please read vitorrd.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 10-07-2009 , 13:25   Re: get_user_name [shows server name] [help]
Reply With Quote #9

Not best..

PHP Code:
#include < amxmodx >

new const g_szSounds[ ][ ] = {
    
"server/stayinalive"
    
"server/force"
};

public 
plugin_init( ) {
    
register_plugin"""""" );
    
    
register_event"DeathMsg""EventDeath""a" );
}

public 
plugin_precache( )
    for( new 
isizeof g_szSoundsi++ )
        
precache_soundg_szSounds] );

public 
EventDeath( ) {
    
// This part is stupid but w/e...
    
new iPlayers][ 32 ], iNum];
    
get_playersiPlayers], iNum], "ae""CT" );
    
get_playersiPlayers], iNum], "ae""TERRORIST" );
    
    if( 
iNum] == && iNum] == ) {
        new 
szName][ 32 ];
        
get_user_nameiPlayers][ ], szName], 31 );
        
get_user_nameiPlayers][ ], szName], 31 );
        
        
set_hudmessagerandom256 ), random256 ), random256 ), -1.00.306.06.0 );
        
show_hudmessage0"%s vs %s !"szName], szName] );
    }
    else if( 
iNum] == ) {
        new 
szName32 ];
        
get_user_nameiPlayers][ ], szName31 );
        
        
set_hudmessagerandom256 ), random256 ), random256 ), -1.00.306.06.0 );
        
show_hudmessage0"%s (CT) is alone now :)"szName );
        
        
client_cmd0"spk %s"g_szSoundsrandomsizeof g_szSounds ) ] );
    }
    else if( 
iNum] == ) {
        new 
szName32 ];
        
get_user_nameiPlayers][ ], szName31 );
        
        
set_hudmessagerandom256 ), random256 ), random256 ), -1.00.306.06.0 );
        
show_hudmessage0"%s (T) is alone now :)"szName );
        
        
client_cmd0"spk %s"g_szSoundsrandomsizeof g_szSounds ) ] );
    }

__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-07-2009 , 13:28   Re: get_user_name [shows server name] [help]
Reply With Quote #10

I hope it's a joke xPaw.
__________________
Arkshine 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 22:33.


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