Rank y top10 por banderas capturadas y banderas recuperadas.
Lo ollvidaba Creditos para: Soy nuevo
Código PHP:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <jctf>
#include <adv_vault>
#define PLUGIN "Rank - Top10 CTF"
#define VERSION "1.0"
#define AUTHOR "Soy nuevo"
new g_flagcaptured[ 33 ]
new g_flagreturned[ 33 ]
new g_vault
new g_sort
new g_playername[ 33 ][ 32 ]
new motd[ 1536 ]
new g_maxplayers
new const g_sPrefix[] = "!t[!gamxmodx-es.com!t]"
enum {
FLAGSCAPTURED,
FLAGSRETURNED,
MAX_FIELDS
}
new g_campos[MAX_FIELDS]
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_vault = adv_vault_open("CaptureTheFlags", false)
g_campos[FLAGSCAPTURED] = adv_vault_register_field(g_vault, "FlagsCaptured")
g_campos[FLAGSRETURNED] = adv_vault_register_field(g_vault, "FlagsReturned")
adv_vault_init(g_vault)
g_sort = adv_vault_sort_create( g_vault, ORDER_DESC, 0, 2000, g_campos[ FLAGSCAPTURED ], g_campos[ FLAGSRETURNED ] )
register_event("HLTV", "round_start", "a", "1=0", "2=0")
register_clcmd("say /rank", "ranking")
register_clcmd("say /top", "top10_flags")
g_maxplayers = get_maxplayers()
}
public client_putinserver( id )
{
get_user_name(id, g_playername[id], 31 );
g_flagcaptured[ id ] = 0
g_flagreturned[ id ] = 0
set_task( 15.0, "publicidad", id)
LoadData( id )
}
public client_disconnect( id )
{
SaveData( id )
}
public publicidad( id )
{
chat_color( id, "%s !nTipea !g/rank !npara ver tu rank de !tBanderas Capturadas!n.", g_sPrefix )
chat_color( id, "%s !nTipea !g/top !npara ver el TOP10 de !tBanderas Capturadas!n.", g_sPrefix )
}
public jctf_flag(iEvent, id, iFlagTeam, bool:bAssist)
{
switch(iEvent)
{
case FLAG_RETURNED:
{
if(!bAssist)
{
g_flagreturned[ id ]++
}
}
case FLAG_CAPTURED:
{
if(!bAssist)
{
g_flagcaptured[ id ]++
}
}
}
}
public top10_knife( id )
{
new flagsc, flagsr, keyindex, pj[ 32 ]
static len
len = 0
new toploop = min( adv_vault_sort_numresult( g_vault, g_sort ), 10 )
len += formatex(motd[len], sizeof motd-len,
"<body bgcolor=#A4BED6>\
<table width=100%% cellpadding=2 cellspacing=0 border=0>\
<tr align=center bgcolor=#52697B>\
<th width=20%%>Posicion\
<th width=20%% align=left>Nombre\
<th width=20%%>Banderas Capturadas\
<th width=20%%>Banderas Recuperadas");
for( new position=1; position <= toploop; position++ )
{
keyindex = adv_vault_sort_position( g_vault, g_sort, position )
if( !adv_vault_get_prepare( g_vault, keyindex ) ) continue
flagsc = adv_vault_get_field( g_vault, g_campos[ FLAGSCAPTURED ] )
flagsr = adv_vault_get_field( g_vault, g_campos[ FLAGSRETURNED ] )
adv_vault_get_keyname( g_vault, keyindex, pj, 31 )
len += formatex(motd[len], sizeof motd-len, "<tr align=center>");
len += formatex(motd[len], sizeof motd-len, "<td>%d", position);
len += formatex(motd[len], sizeof motd-len, "<td align=left>%s", pj);
len += formatex(motd[len], sizeof motd-len, "<td>%d", flagsc);
len += formatex(motd[len], sizeof motd-len, "<td>%d", flagsr);
}
len += formatex(motd[len], sizeof motd-len, "</table></body>");
show_motd( id, motd, "TOP10 Capture The Flags");
}
public ranking( id )
{
new rank = adv_vault_sort_key(g_vault, g_sort, 0, g_playername[ id ] )
if( !rank )
{
chat_color(id, "%s !nTodavia no estas rankeando :C", g_sPrefix)
}
else chat_color(id, "%s !nTu rank es !t%d !ncon !g%d !nbanderas capturadas y !g%d !nrecuperadas", g_sPrefix, rank, g_flagcaptured[ id ], g_flagreturned[ id ])
}
public round_start()
{
for(new id=1; id <= g_maxplayers; id++)
{
if( is_user_connected( id ) )
SaveData( id )
}
adv_vault_sort_update(g_vault, g_sort)
}
public client_infochanged( id )
{
if( !is_user_connected( id ) ) return
static newname[ 32 ]
get_user_info( id, "name", newname, charsmax( newname ) )
if( !equal(newname, g_playername[ id ] ) )
{
set_task( 0.1, "LoadData", id )
}
}
public SaveData( id )
{
if(!is_user_connected( id ) ) return;
adv_vault_set_start( g_vault )
adv_vault_set_field( g_vault, g_campos[ FLAGSCAPTURED ], g_flagcaptured[ id ] )
adv_vault_set_field( g_vault, g_campos[ FLAGSRETURNED ], g_flagreturned[ id ] )
adv_vault_set_end( g_vault, 0, g_playername[ id ] )
}
public LoadData( id )
{
if(!adv_vault_get_prepare(g_vault, _, g_playername[ id ] ) )
return;
g_flagcaptured[ id ] = adv_vault_get_field( g_vault, g_campos[ FLAGSCAPTURED ] )
g_flagreturned[ id ] = adv_vault_get_field( g_vault, g_campos[ FLAGSRETURNED ] )
}
stock chat_color( const id, const input[], any:... )
{
new count = 1, players[ 32 ]
static msg[ 191 ]
vformat( msg, 190, input, 3 )
replace_all( msg, 190, "!g", "^4" )
replace_all( msg, 190, "!n", "^1" )
replace_all( msg, 190, "!t", "^3" )
replace_all( msg, 190, "!t2", "^0" )
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()
}
}
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
"El día que seas capaz de llorar de impotencia ante una injusticia, ese día seremos compañeros"