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

And the winner with most headshots is... [Updated 03/18/2010]


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Fun Stuff        Approver:   Hawk552 (427)
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-24-2010 , 14:20   And the winner with most headshots is... [Updated 03/18/2010]
Reply With Quote #1

And the winner with most headshots is...
By lucas_7_94



..:[ Description ]:..
  • This plugin has all heads made around the map.
  • Then, before the end of the map shows a print with the best player on the map....
..:[ Cvars ]:..

Code:
amx_headshots_logs" "0" // Active or Desactive the Logs. amx_headshots_saymode "0" // 1 Print the message in the event_round_start | 0 print the message when map changing
..:[ Pictures / Screenshots ]:..


..:[ Credits ]:..

Code:
- Starsailor : Code From The Best Player. - Asd' (Fraan') : Help me with the Event_DeathMsg. - Drux (Fezh) | suNx : Tester's - Exolent & xPaw : Fix Code. - kLeVeR & Feeeddeehh : BOTS testers.

..:[ Server Running This Plugin ]:..
..:[ Plugin (PHP) ]:..
  • Best Headshot [Simple Version]:
Code:
#include < amxmodx >
#include < amxmisc >

#define TAG "^x04[AMXX]^x01"
#define FCVARS (FCVAR_SERVER | FCVAR_PROTECTED)

static const dates[ ][ ] =
{
    "And the Winner with Most Headshot Is...",
    "1.8",
    "Luqqas' Aka lucas_7_94"
}

new const name_cvar[ ][ ] = { 
    "amx_headshots_logs", 
    "amx_headshots_saymode"
}

new const value_cvar[ ][ ] = { 
    "1", 
    "0" 
}

/* Enums */
enum 
{
    CVAR_LOGS = 0,
    CVAR_SAYMODE,
}

enum
{
    PLUGIN_NAME,
    PLUGIN_VERSION,
    PLUGIN_AUTHOR
}
/* Enums End*/

new cvars[2]

new g_mostheadshots[33]

public plugin_init() {
    register_plugin( dates[PLUGIN_NAME], dates[PLUGIN_VERSION], dates[PLUGIN_AUTHOR])
    
    register_event( "DeathMsg" , "Event_DeathMsg" , "a" , "3=1" );
    
    register_event( "30" , "event_intermission" , "a" );
    
    register_event("HLTV", "event_round_start", "a", "1=0", "2=0");
    
    cvars[0] = register_cvar( name_cvar[CVAR_LOGS] , value_cvar[CVAR_LOGS] );
    cvars[1] = register_cvar( name_cvar[CVAR_SAYMODE], value_cvar[CVAR_SAYMODE]);

    
    register_cvar( "Best Player Headshot | SQL" , dates[PLUGIN_AUTHOR] , FCVARS );
    
    register_event( "TextMsg", "Event_GameRestart", "a", "2=#Game_will_restart_in");
    
    register_event( "TextMsg", "Event_GameRestart", "a", "2=#Game_Commencing" );
    
}

public Event_GameRestart( ) arrayset( g_mostheadshots, 0, 33 )
public client_disconnect( id ) g_mostheadshots[ id ] = 0
public event_intermission( ) set_task( 0.1, "BestHeadPlayer")

public event_round_start( )
{
    if( get_pcvar_num( cvars[1] ) )
        set_task(0.1, "BestHeadPlayer");
}
public BestHeadPlayer( ) 
{    
    new iPlayers[ 32 ], iNum
    get_players( iPlayers, iNum )
    
    if( !iNum )
    {
        return;
    }
    
    new iBestPlayerHeadshot = iPlayers[ 0 ]
    
    for(new i = 1, id; i < iNum; i++) 
    { 
        id = iPlayers[ i ] 
        
        if(g_mostheadshots[ id ] > g_mostheadshots[ iBestPlayerHeadshot ]) 
        { 
            iBestPlayerHeadshot = id 
        } 
    }
    
    new szName[ 32 ] 
    get_user_name( iBestPlayerHeadshot , szName , charsmax(szName) ) 
    if(g_mostheadshots[ iBestPlayerHeadshot ] > 0)
        Color( 0, "%s And The Winner is %s with %d Headshot%s" , TAG , szName , g_mostheadshots[ iBestPlayerHeadshot ] , g_mostheadshots[ iBestPlayerHeadshot ] > 1 ? "s." : "." )
    else
        Color( 0, "%s Nobody was winning on this map!", TAG )
    
    if( !cvars[1] && cvars[0] && g_mostheadshots[ iBestPlayerHeadshot ] > 0) {
        static mapname[ 32 ]
        get_mapname(mapname, sizeof mapname - 1)
        
        static Steam[ 32 ]
        get_user_authid( iBestPlayerHeadshot, Steam, charsmax(Steam))
        
        log_to_file( "best_headshot.log" , "Map %s | Best Player: %s | Headshots: %d | STEAM ID: %s" , mapname , szName , g_mostheadshots[ iBestPlayerHeadshot ], Steam)
    }
    return
}

public Event_DeathMsg( ) 
{
    new iAttack = read_data( 1 )
    
    if ( read_data( 2 ) != iAttack  )
        g_mostheadshots[ iAttack ]++
    
    return PLUGIN_HANDLED
}

stock Color( const id , const input[ ] , any:... )
{
    new count = 1, players[ 32 ]
    static msg[ 191 ]
    vformat( msg , 190 , input , 3 )
    
    replace_all( msg , 190 , "^x04" , "^4") // Green Color
    replace_all( msg, 190 , "^x01" , "^1") // Default Color
    replace_all( msg, 190 , "!team" , "^3") // Team Color
    replace_all( msg, 190 , "!team2" , "^0") // Team2 Color
    
    if ( id ) players[ 0 ] = id; else get_players( players , count , "ch" )
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected( players[ i ] ))
            {
                message_begin( MSG_ONE_UNRELIABLE , get_user_msgid("SayText") , _ , players[ i ] )
                write_byte( players[ i ] );
                write_string( msg );
                message_end( );
            }
        }
    }
}

  • Best Headshot [ SQLx Version ]
Code:
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < sqlx >

#define PLUGIN "And the Winner with Most Headshot Is..."
#define VERSION "1.8 "
#define AUTHOR "Luqqas' alias lucas_7_94"

#define TAG "^x04[AMXX]^x01" 

new g_szSQLTable[64], Handle:g_hSQLTuple, g_szQuery[256]

static const dates[ ][ ] =
{
    "And the Winner with Most Headshot Is...",
    "1.8|SQLx",
    "Luqqas' Aka lucas_7_94"
}

new const cvars[][] = {
    "amx_shot_sql_host", 
    "amx_shot_sql_user",
    "amx_shot_sql_pass",
    "amx_shot_sql_db",
    "amx_sql_type",
    "amx_shot_table"
}

new const value_cvars[][] = { 
    "", 
    "",
    "",
    "",
    "mysql", // don't change it
    ""
}

enum
{
    CVAR_HOST ,
    CVAR_USER,
    CVAR_PASS,
    CVAR_DB,
    CVAR_TYPE,
    CVAR_TABLE
}

enum
{
    PLUGIN_NAME,
    PLUGIN_VERSION,
    PLUGIN_AUTHOR
}

new g_mostheadshots[33]

public plugin_init() {
    register_plugin( dates[PLUGIN_NAME], dates[PLUGIN_VERSION], dates[PLUGIN_AUTHOR])
    
    register_cvar( cvars[CVAR_HOST] , value_cvars[CVAR_HOST] )
    register_cvar( cvars[CVAR_USER] , value_cvars[CVAR_USER] )
    register_cvar( cvars[CVAR_PASS] , value_cvars[CVAR_PASS] )
    register_cvar( cvars[CVAR_DB]   , value_cvars[CVAR_DB] )
    register_cvar( cvars[CVAR_TYPE] , value_cvars[CVAR_TYPE] )
    
    new cvTable = register_cvar( cvars[CVAR_TABLE] , value_cvars[CVAR_TABLE] )
    
    
    get_pcvar_string(cvTable, g_szSQLTable, charsmax(g_szSQLTable))
    new host[32],user[32],password[32],db[32]
    get_cvar_string( cvars[CVAR_HOST], host, 31)
    get_cvar_string( cvars[CVAR_USER], user, 31)
    get_cvar_string( cvars[CVAR_PASS],  password, 31)
    get_cvar_string( cvars[CVAR_DB], db, 31)
    
    g_hSQLTuple = SQL_MakeDbTuple(host,user,password,db)
    
    new iError, szError[256]
    new Handle:hSQLConnection = SQL_Connect(g_hSQLTuple, iError, szError, charsmax(szError))
    if(hSQLConnection != Empty_Handle)
    {    
        SQL_QueryAndIgnore(hSQLConnection,
            "CREATE TABLE IF NOT EXISTS `%s` (\
            `LAST_PLAY_DATE` timestamp(14) NOT NULL, \
            `HEADSHOT` int(10) NOT NULL default '0', \
            `MAP` varchar(32), \
            `STEAMID` varchar(32), \
            `NAME` varchar(32) \ 
            , PRIMARY KEY  (`LAST_PLAY_DATE`) ) \
            TYPE=MyISAM \
            COMMENT='Best Headshot SQLx'",
        g_szSQLTable )
        
        SQL_FreeHandle(hSQLConnection)
    }
    else
        log_amx("plugin_init(): SQL Error #%d - %s", iError, szError)
    
    register_event( "DeathMsg" , "Event_DeathMsg" , "a" , "3=1" );
    
    register_event( "30" , "event_intermission" , "a" );
    
    register_cvar( "Best Player Headshot [Version SQLx]" , AUTHOR , FCVAR_SERVER | FCVAR_PROTECTED );
    
    register_event( "TextMsg", "Event_GameRestart", "a", "2=#Game_will_restart_in ");
    
    register_event( "TextMsg", "Event_GameRestart", "a", "2=#Game_Commencing" );
    
}

public Event_GameRestart( ) arrayset( g_mostheadshots, 0, 33 )
public client_disconnect( id ) g_mostheadshots[ id ] = 0
public event_intermission( ) set_task( 0.1, "BestHeadPlayer")

public BestHeadPlayer( ) 
{    
    new iPlayers[ 32 ], iNum
    get_players( iPlayers, iNum )
    
    if( !iNum )
    {
        return;
    }
    
    new iBestPlayerHeadshot = iPlayers[ 0 ]
    
    for(new i = 1, id; i < iNum; i++) 
    { 
        id = iPlayers[ i ] 
        
        if(g_mostheadshots[ id ] > g_mostheadshots[ iBestPlayerHeadshot ]) 
        { 
            iBestPlayerHeadshot = id 
        } 
    }
    
    new szName[ 32 ] 
    get_user_name( iBestPlayerHeadshot , szName , charsmax(szName) ) 
    if(g_mostheadshots[ iBestPlayerHeadshot ] > 0)
        Color( 0, "%s And The Winner is %s with %d Headshot%s" , TAG , szName , g_mostheadshots[ iBestPlayerHeadshot ] , g_mostheadshots[ iBestPlayerHeadshot ] > 1 ? "s." : "." )
    else
        Color( 0, "%s Nobody was winning on this map!", TAG )
    
    if( g_mostheadshots[ iBestPlayerHeadshot ] > 0) {
        
        static mapname[ 32 ], Steam[ 32 ]
        get_mapname(mapname, sizeof mapname - 1)
        get_user_authid( iBestPlayerHeadshot, Steam, charsmax(Steam))
        
        formatex(g_szQuery, charsmax(g_szQuery),
        "INSERT INTO `%s` SET `LAST_PLAY_DATE`=SYSDATE(), `HEADSHOT`='%d', `MAP`='%s', `STEAMID`='%s', `NAME`='%s'",
        g_szSQLTable, g_mostheadshots[ iBestPlayerHeadshot ], mapname, Steam, szName, g_mostheadshots[ iBestPlayerHeadshot ], mapname, Steam, szName)
        SQL_ThreadQuery(g_hSQLTuple, "SaveClient_QueryHandler", g_szQuery)
    }
    return
}

public SaveClient_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, iData[], iSize, Float:fQueueTime)
{
    if(iFailState != TQUERY_SUCCESS)
        log_amx("SavingBestHeadShot(): SQL Error #%d - %s", iErrnum, szError)
}

public plugin_end()
    if (g_hSQLTuple) SQL_FreeHandle(g_hSQLTuple)


public Event_DeathMsg( ) 
{
    new iAttack = read_data( 1 )
    
    if ( read_data( 2 ) != iAttack  )
        g_mostheadshots[ iAttack ]++
    
    return PLUGIN_HANDLED
}

stock Color( const id , const input[ ] , any:... )
{
    new count = 1, players[ 32 ]
    static msg[ 191 ]
    vformat( msg , 190 , input , 3 )
    
    replace_all( msg , 190 , "^x04" , "^4") // Green Color
    replace_all( msg, 190 , "^x01" , "^1") // Default Color
    replace_all( msg, 190 , "!team" , "^3") // Team Color
    replace_all( msg, 190 , "!team2" , "^0") // Team2 Color
    if ( id ) players[ 0 ] = id; else get_players( players , count , "ch" )
    {
        for (new i = 0; i < count; i++)
        {
            if (is_user_connected( players[ i ] ))
            {
                message_begin( MSG_ONE_UNRELIABLE , get_user_msgid("SayText") , _ , players[ i ] )
                write_byte( players[ i ] );
                write_string( msg );
                message_end( );
            }
        }
    }
}

..:[ Plugin / Comment / Download ]:..


.-Enjoy the plugin! , If you have any suggestions or questions about something, please post ^^.
Attached Files
File Type: sma Get Plugin or Get Source (best_headshot_sql.sma - 7041 views - 5.4 KB)
File Type: sma Get Plugin or Get Source (best_headshot.sma - 5991 views - 3.6 KB)
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 11-14-2010 at 11:16.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
fezh
Veteran Member
Join Date: Dec 2008
Location: BANNED
Old 02-24-2010 , 14:45   Re: And the winner with most headshot's is...
Reply With Quote #2

As far as I see now it works
Good job then.
__________________
"There is no knowledge, that is not power"
fezh is offline
SpILL
Veteran Member
Join Date: Oct 2009
Location: Karachi, Pakistan
Old 02-24-2010 , 14:50   Re: And the winner with most headshot's is...
Reply With Quote #3

GJ.
__________________


SpILL is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-24-2010 , 14:57   Re: And the winner with most headshot's is...
Reply With Quote #4

- BestHeadPlayer( id ) -> BestHeadPlayer( )
- Fix indent
- Check if "best player" headshots is atleast more than 0
- Remove client_putinserver part, you already have it in client_disconnect
- Remove iHead check, you already checked it in register_event params
- Check if victim != attacker
- g_maxplayers is never used
- Multilang would be fine
__________________
xPaw is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 02-24-2010 , 15:12   Re: And the winner with most headshot's is...
Reply With Quote #5

Quote:
This plugin has all heads made around the map.
Wtf
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-24-2010 , 15:49   Re: And the winner with most headshot's is...
Reply With Quote #6

Code:
public event_intermission( ) set_task( 0.1, "BestHeadPlayer", 0 ) public BestHeadPlayer( id )

Code:
public event_intermission( ) set_task( 0.1, "BestHeadPlayer" ) // task id isn't needed // there is no id for this function if the task id is 0 public BestHeadPlayer( )
-----------------
Code:
    new iPlayers[32], iNum, i, id     get_players( iPlayers, iNum )         new iBestPlayerHeadshot     for(i = 0; i < iNum; i++)     {             id = iPlayers[ i ]                         if(!iBestPlayerHeadshot)             {                 iBestPlayerHeadshot = iPlayers[ 0 ]             }                         if(g_mostheadshots[ id ] > g_mostheadshots[ iBestPlayerHeadshot ])             {                 iBestPlayerHeadshot = id             }     }

Code:
    new iPlayers[32], iNum     get_players( iPlayers, iNum )         // check for no players     if(!iNum)     {         return;     }         // set to first player instead of checking inside loop     new iBestPlayerHeadshot = iPlayers[ 0 ]         // i and id aren't used except for only inside the loop     // start loop at 1 since we set it to iPlayers[ 0 ] already     for(new i = 1, id; i < iNum; i++)     {         id = iPlayers[ i ]                 if(g_mostheadshots[ id ] > g_mostheadshots[ iBestPlayerHeadshot ])         {             iBestPlayerHeadshot = id         }     }
--------------------
Code:
        formatex(infoHead, sizeof infoHead - 1, "Map %s | Best Player: %s | Headshot's: %d", mapname,  szName, g_mostheadshots[iBestPlayerHeadshot])         log_to_file("best_headshot.log", infoHead)

Code:
        // log_to_file() uses formatting strings, so no need to format a string, then pass it.         log_to_file("best_headshot.log", "Map %s | Best Player: %s | Headshot's: %d", mapname,  szName, g_mostheadshots[iBestPlayerHeadshot])
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-24-2010 , 18:45   Re: And the winner with most headshot's is...
Reply With Quote #7

Exolent & xPaw Thanks!

Now , fixing , Thanks you
__________________
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
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-24-2010 , 19:36   Re: And the winner with most headshot's is...
Reply With Quote #8

Updated! Check The first Post! .

At this moment, I'm adding ML
__________________
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
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 02-25-2010 , 07:03   Re: And the winner with most headshot's is...
Reply With Quote #9

Quote:
Originally Posted by lucas_7_94 View Post
Exolent & xPaw Thanks!

Now , fixing , Thanks you
You didnt done all what i said
Quote:
Originally Posted by xPaw View Post
- Check if "best player" headshots is atleast more than 0 (before printing)
- Remove iHead check, you already checked it in register_event params
- Check if victim != attacker
- static -> new, its called only once, no need to make it static
__________________
xPaw is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 02-25-2010 , 07:14   Re: And the winner with most headshot's is...
Reply With Quote #10

Quote:
Originally Posted by xPaw View Post
You didnt done all what i said
Holy shit! sorry , Now I'm solving, thanks ^^

one cuestion ..

PHP Code:
Check if "best player" headshots is atleast more than 0 (before printing
Sorry, I do not understand


yeah , thanks you , i'm now updating , thanks you really.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.

Last edited by lucas_7_94; 02-25-2010 at 07:32.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
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 08:58.


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