AMX MOD X
Вторник, 11.12.2018, 14:41:59



Приветствую Вас Гость | RSS
[ Главная ] [ kills counter - AMX Mod X Форум ] [ Регистрация ] [ Вход ]
[ Новые сообщения · Участники · Правила форума · Поиск · RSS ]

Вниманию участников! Данный форум теперь является архивом и вскором времени здесь нельзя будет создавать новых тем! Просьба всем для общения и создания новых тем перейти на наш новый форум: http://amxmodx.su/

  • Страница 1 из 1
  • 1
Модератор форума: slogic, AlMod  
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » kills counter
kills counter
lopДата: Вторник, 22.02.2011, 14:33:00 | Сообщение # 1
Рядовой
Группа: Пользователи
Сообщений: 1
Репутация: 0
Статус: Не в сети
Ok so this plugin is supposed to count your kills and set a level infront of your nick
like
"Newbie",
"Semi-Pro",
"Pro",
"Veteran"
but the problem is that this code doesnt work
can somebody help me fix it ?
Code
#include <amxmodx>
#include <cstrike>
#include <nvault>

new const Version[] = "0.2";

enum KillLevels {
    Newbie,
    SemiPro,
    Pro,
    Veteran
}

new KillLevelRange[ KillLevels ][ 2 ] =  {
    { 0 , 499 },
    { 500 , 749 },
    { 750 , 999 },
    { 1000 , 999999 }
};

new KillLevelName[ KillLevels ][] =  {
    "Newbie",
    "Semi-Pro",
    "Pro",
    "Veteran"
};

enum DeathMsg_Arg {
    KillerID,
    VictimID,
    IsHeadshot,
    WeaponName
}

enum PlayerInfo {
    Name[ 32 ],
    AuthID[ 34 ],
    NumKills,
    KillLevels:CurrentLevel
}

new g_PlayerData[ 33 ][ PlayerInfo ];
new g_iVault;
new g_MsgSayText;

public plugin_init()  {
    register_plugin( "Kill Levels" , Version , "bugsy" );
    register_event( "DeathMsg" , "fw_EvDeathMsg" , "a" , "1>0" );
    register_clcmd( "say" , "fw_CmdSay" );
    register_clcmd( "say_team" , "fw_CmdSayTeam" );
     
    g_MsgSayText = get_user_msgid( "SayText" );
    if ( ( ( g_iVault = nvault_open( "klevels" ) ) == INVALID_HANDLE ) )
       set_fail_state( "Error opening vault" );
}
public AnnounceJoin( id ) {
    client_print( 0 , print_chat , "* %s is a %s in this server!" , g_PlayerData[ id ][ Name ] , KillLevelName[ g_PlayerData[ id ][ CurrentLevel ] ] );
}  

public plugin_end() {
    nvault_close( g_iVault );
}
public client_infochanged(id)  {  
    if (!is_user_connected(id))  
       return  
    get_user_info(id, "name", g_PlayerData[id][Name], charsmax(g_PlayerData[][Name]))  
}
public client_putinserver( id ) {
    get_user_name( id , g_PlayerData[ id ][ Name ] , charsmax( g_PlayerData[][ Name ] ) );
    get_user_ip( id , g_PlayerData[ id ][ AuthID ] , charsmax( g_PlayerData[][ AuthID ] ) );
    if ( ( g_PlayerData[ id ][ NumKills ] = nvault_get( g_iVault , g_PlayerData[ id ][ AuthID ] ) ) ) {
       SetPlayerLevel( id );
       set_task( 7.0 , "AnnounceJoin" , id );
    }
}
public client_disconnect( id ) {
    new szKills[ 6 ];
    num_to_str( g_PlayerData[ id ][ NumKills ] , szKills , charsmax( szKills ) );
    nvault_set( g_iVault , g_PlayerData[ id ][ AuthID ] , szKills );
    g_PlayerData[ id ][ Name ][ 0 ] = EOS;
    g_PlayerData[ id ][ AuthID ][ 0 ] = EOS;
    g_PlayerData[ id ][ NumKills ] = 0;
    g_PlayerData[ id ][ CurrentLevel ] = _:Newbie;
}
public fw_EvDeathMsg() {
    new id = read_data( _:KillerID );
    g_PlayerData[ id ][ NumKills ]++;
    SetPlayerLevel( id );
}
public fw_CmdSay(id) {
    static szMessage[ 192 ] , iPlayers[ 32 ];
    new bool:bIsAlive , iPos , iNum , iPlayer;
    bIsAlive = bool:is_user_alive( id );
    iPos = formatex( szMessage , charsmax( szMessage ) , "%s[%s] ^x03%s ^x01:  ", bIsAlive ? "^x04 " : "^x01*DEAD*^x04 " , KillLevelName[ g_PlayerData[ id ][ CurrentLevel ] ] , g_PlayerData[ id ][ Name ] , szMessage );
    read_args( szMessage[ iPos ] , charsmax( szMessage ) - iPos );
    remove_quotes( szMessage[ iPos ] );
    get_players( iPlayers , iNum );
    for ( new i = 0 ; i < iNum ; i++ ) {
       iPlayer = iPlayers[ i ];
       if( ( bIsAlive && is_user_alive( iPlayer ) ) || ( !bIsAlive && !is_user_alive( iPlayer ) ) ) {
          message_begin( MSG_ONE_UNRELIABLE , g_MsgSayText , {0, 0, 0} , iPlayer );
          write_byte( id );
          write_string( szMessage );
          message_end();
       }
    }
    return PLUGIN_HANDLED;
}
public fw_CmdSayTeam( id ) {
    static szMessage[ 192 ] , iPlayers[ 32 ];
    new bool:bIsAlive , iPos , iNum , iPlayer , CsTeams:iTeam;
    new const szTeams[ CsTeams ][] =  {
       "",
       "Terrorist",
       "Counter-Terrorist",
       "Spectator"
    };
    bIsAlive = bool:is_user_alive( id );
    iTeam = cs_get_user_team( id );
    iPos = formatex( szMessage , charsmax( szMessage ) , "^x01%s^x01(%s) ^x04[%s] ^x03%s ^x01:  " , bIsAlive ? "" : "*DEAD*" , szTeams[ iTeam ] , KillLevelName[ g_PlayerData[ id ][ CurrentLevel ] ] , g_PlayerData[ id ][ Name ] , szMessage );
    read_args( szMessage[ iPos ] , charsmax( szMessage ) - iPos );
    remove_quotes( szMessage[ iPos ] );
    get_players( iPlayers , iNum );
    for ( new i = 0 ; i < iNum ; i++ ) {
       iPlayer = iPlayers[ i ];
       if ( ( iTeam == cs_get_user_team( iPlayer ) ) && ( ( bIsAlive && is_user_alive( iPlayer ) ) || ( !bIsAlive && !is_user_alive( iPlayer ) ) ) ) {
          message_begin( MSG_ONE_UNRELIABLE , g_MsgSayText , {0, 0, 0} , iPlayer );
          write_byte( id );
          write_string( szMessage );
          message_end();
       }
    }
    return PLUGIN_HANDLED;
}

SetPlayerLevel( id ) {
    for ( new KillLevels:iLevel = Newbie ; iLevel < KillLevels ; iLevel++ ) {
       if ( KillLevelRange[ iLevel ][ 0 ] <= g_PlayerData[ id ][ NumKills ] <= KillLevelRange[ iLevel ][ 1 ] )  {
          g_PlayerData[ id ][ CurrentLevel ] = _:iLevel;
          break;
       }
    }
}
 
AMX Mod X Форум » Скриптинг » Помощь по скриптингу » kills counter
  • Страница 1 из 1
  • 1
Поиск:

AMX Mod X Russian Community © 2006-2018