Raised This Month: $ Target: $400
 0% 

How to get playername (optimize this?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
colossus
Member
Join Date: Sep 2013
Old 09-09-2013 , 07:07   How to get playername (optimize this?)
Reply With Quote #1

How to optimize getname last ct?

funcion: GetCTLastName()

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <cstrike> #define PLUGIN "Get Name Last CT" #define VERSION "1.0" #define AUTHOR "colossus" new g_maxplayers new szName[33][32] new szText[32] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Add your code here...     register_srvcmd("function", "GoFunction")         g_maxplayers = get_maxplayers() } public client_putinserver(id) {     get_user_name(id, szName[id], charsmax(szName[])) } public GoFunction() {     if(fnGetCTs() == 1)     {         GetCTLastName()     } } fnGetCTs() {     static iCTs, id     iCTs = 0         for (id = 1; id <= g_maxplayers; id++)     {         if(!is_user_alive(id))             continue                     if (cs_get_user_team(id) != CS_TEAM_CT)             continue                     iCTs++     }         return iCTs; } GetCTLastName() {     for(new id = 1; id <= g_maxplayers; id++)     {         if(!is_user_alive(id))             continue                     if (cs_get_user_team(id) != CS_TEAM_CT)             continue                             formatex(szText, charsmax(szText), "%s", szName[id])     } }
colossus is offline
RapZzw3rR
Member
Join Date: May 2012
Location: Romania
Old 09-09-2013 , 07:52   Re: How to get playername (optimize this?)
Reply With Quote #2

PHP Code:
new szText[32];

public 
GoFunction( )
{
    new 
iPlayers[32], iNumszName[32];
    
    
get_players(iPlayersiNum"aceh""CT");
    
    if( 
iNum == )
    {
        
get_user_name(iPlayers[0], szNamecharsmax(szName));
        
formatex(szTextcharsmax(szText), szName[id]);
    }

Try this.
RapZzw3rR is offline
colossus
Member
Join Date: Sep 2013
Old 09-09-2013 , 09:41   Re: How to get playername (optimize this?)
Reply With Quote #3

Quote:
Originally Posted by RapZzw3rR View Post
PHP Code:
new szText[32];

public 
GoFunction( )
{
    new 
iPlayers[32], iNumszName[32];
    
    
get_players(iPlayersiNum"aceh""CT");
    
    if( 
iNum == )
    {
        
get_user_name(iPlayers[0], szNamecharsmax(szName));
        
formatex(szTextcharsmax(szText), szName[id]);
    }

Try this.
What is "aceh" ???
colossus is offline
SpaWn2KiLl
Member
Join Date: Aug 2012
Old 09-09-2013 , 09:48   Re: How to get playername (optimize this?)
Reply With Quote #4

Quote:
Originally Posted by colossus View Post
What is "aceh" ???
If specified, you can constrain which players are returned by flags:
"a" - Don't return dead players
"b" - Don't return alive players
"c" - Skip bots
"d" - Skip real players
"e" - Match with passed team
"f" - Match with part of name
"g" - Ignore case sensitivity
"h" - Skip HLTV
__________________
SpaWn2KiLl is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-09-2013 , 12:10   Re: How to get playername (optimize this?)
Reply With Quote #5

"ae" is enough, there is no reason to filter bots, and there is no way to collect an alive HLTV.

And last code contains mistakes on name

get_user_name(players[0], name, charsmax(name)) is all you need when num == 1, the next format line is completely wrong/
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 09-09-2013 at 12:11.
ConnorMcLeod is offline
SpaWn2KiLl
Member
Join Date: Aug 2012
Old 09-09-2013 , 12:21   Re: How to get playername (optimize this?)
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
"ae" is enough, there is no reason to filter bots, and there is no way to collect an alive HLTV.

And last code contains mistakes on name

get_user_name(players[0], name, charsmax(name)) is all you need when num == 1, the next format line is completely wrong/
I don't agree with you...

If he uses bots... probably he doesn't want them name

Yes it is possible to collect an alive HLTV... Transfer it to one team and then use a plugin to revive...
__________________
SpaWn2KiLl is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-09-2013 , 18:26   Re: How to get playername (optimize this?)
Reply With Quote #7

Last ct is last ct, bot or not.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
colossus
Member
Join Date: Sep 2013
Old 09-09-2013 , 22:13   Re: How to get playername (optimize this?)
Reply With Quote #8

The final code:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #define PLUGIN "Get Name Last CT" #define VERSION "1.0" #define AUTHOR "colossus" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Add your code here...     register_srvcmd("function", "GoFunction") } public GoFunction() {     new iPlayers[32], iNum, szName[32];         get_players(iPlayers, iNum, "ae", "CT");         if( iNum == 1 )     {         get_user_name(iPlayers[0], szName, charsmax(szName))         client_print(0, print_chat, "%s Ultimate CT", szName)     }     }

No Job plugin if players in game > 1....



And other question... How to check the same code but with boolean variable ej: g_Winner[Index]???

Example:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "Get Name Last CT" #define VERSION "1.0" #define AUTHOR "colossus" new g_Winner[33] public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         // Add your code here...     register_srvcmd("function", "GoFunction") } public client_authorized(id) { if(is_user_admin(id)) g_Winner[id] = true; } public GoFunction() {     new iPlayers[32], iNum, szName[32];         get_players(iPlayers, iNum, "ae", "CT");         if( iNum == 1 )     {         if(g_Winner[iPlayers[0]])         {             get_user_name(iPlayers[0], szName, charsmax(szName))             client_print(0, print_chat, "%s Ultimate CT and variable g_Winner == true", szName)         }     }     }

This is correct code or not??

Last edited by colossus; 09-09-2013 at 23:21.
colossus is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 09-10-2013 , 01:01   Re: How to get playername (optimize this?)
Reply With Quote #9

It is not correct.

Explain what you are trying to do.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
colossus
Member
Join Date: Sep 2013
Old 09-10-2013 , 13:23   Re: How to get playername (optimize this?)
Reply With Quote #10

I want to get last player alive CT and g_Winner variable == true.

Last edited by colossus; 09-10-2013 at 13:23.
colossus 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 18:54.


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