//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
//**********************************************SOUND VERSION AND COLOR CHAT***********************************************
#include <amxmodx>
#include <nvault>
#include <fakemeta>
#include <engine>
#include <fakemeta_util>
#include <hamsandwich>
#include <cstrike>
#include <xs>
#include <fun>
#define PLUGIN_NAME "level system BETA"
#define PLUGIN_VERSION "0.2.2"
#define PLUGIN_AUTHOR "Bos93 & FirsT & K.o.T.u.K"
#define MAX_CLIENTS 32
#define ID_SHOWHUD (taskid - TASK_SHOWHUD)
enum (+= 100)
{
TASK_SHOWHUD = 10
}
new const MAX_LEVELS[20] =
{
10, //1
30, //2
50, //3
80, //4
120, //5
140, //6
170, //7
200, //8
250, //9
275, //10
315, //11
355, //12
400, //13
460, //14
510, //15
550, //16
590, //17
650, //18
700, //19
780 //20
}
const Float:HUD_STATS_X = -1.0;
const Float:HUD_STATS_Y = 0.75;
const Float:HUD_SPECT_X = -1.0;
const Float:HUD_SPECT_Y = 0.8;
const PEV_SPEC_TARGET = pev_iuser2
new g_iLevel[ MAX_CLIENTS + 1 ],
g_iExp[ MAX_CLIENTS + 1 ],
g_playername[ MAX_CLIENTS + 1 ][ MAX_CLIENTS ];
new g_vault;
public plugin_init( )
{
register_plugin ( PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR );
register_event( "DeathMsg", "EV_DeathMsg", "a" );
RegisterHam(Ham_Spawn,"player","player_respawn");
g_vault = nvault_open("Levels__System");
register_clcmd("randomweapons","go_random")
}
public plugin_natives()
{
register_native("zp_get_user_level", "native_get_user_level", 1)
register_native("zp_set_user_level", "native_set_user_level", 1)
register_native("zp_get_user_exp", "native_get_user_exp", 1)
register_native("zp_set_user_exp", "native_set_user_exp", 1)
}
public plugin_precache()
{
precache_sound("misc/up.wav")
}
public client_disconnect(id)
{
SaveData(id);
}
public client_putinserver( iPlayer )
{
get_user_name(iPlayer, g_playername[iPlayer], charsmax(g_playername[]))
set_task(1.0, "ShowHUD", iPlayer+TASK_SHOWHUD, _, _, "b")
LoadData( iPlayer );
}
public plugin_end()
{
nvault_close(g_vault)
}
public player_respawn(id)
{
new bool:Have;
if(is_user_alive(id) && g_iLevel[id] > 30)
{
client_cmd(id, "m79")
Have = true
}
if(is_user_alive(id) && g_iLevel[id] > 10 && !Have)
{
client_cmd(id, "anaconda")
}
}
public EV_DeathMsg(id)
{
static iVictim, iKiller;
iVictim = read_data( 2 );
iKiller = read_data( 1 );
if( !is_user_connected( iVictim ) )
return;
if( iKiller == iVictim || !iKiller )
return;
g_iExp[ iKiller ] += 1;
while( g_iExp[ iKiller ] >= MAX_LEVELS[ g_iLevel[ iKiller ] ] )
{
g_iLevel[ iKiller ] += 1;
color_print( iKiller , "!g[Level System]!y Поздравляем Ваш уровень поднят シ !");
emit_sound(0, 0, "misc/up.wav", 1.0, 1.0, 0, 100)
client_cmd( iKiller , "randomweapons");
}
}
public ShowHUD(taskid)
{
static iPlayer
iPlayer = ID_SHOWHUD;
if (!is_user_alive( iPlayer ) )
{
iPlayer = pev(iPlayer, PEV_SPEC_TARGET)
// Target not alive
if (!is_user_alive(iPlayer) ) return;
}
if (iPlayer != ID_SHOWHUD)
{
set_hudmessage( 100, 100, 100, HUD_SPECT_X, HUD_SPECT_Y, 0, 5.0, 3.0, 1.0, 1.0, -1 );
show_hudmessage( ID_SHOWHUD , "Наблюдение за: %s^n[HP: %d] [Уровень: %d] [Опыт: %d / %d]", g_playername[ iPlayer ] , get_user_health(iPlayer), g_iLevel[ iPlayer ] , g_iExp[ iPlayer ] , (MAX_LEVELS[g_iLevel[ iPlayer ]]) );
}
else
{
set_hudmessage( 0, 255, 0, HUD_STATS_X, HUD_STATS_Y, 0, 5.0, 3.0, 1.0, 1.0, -1 );
show_hudmessage( ID_SHOWHUD , "[ Уровень: %d ] [ Опыт: %d / %d ]", g_iLevel[ ID_SHOWHUD ] , g_iExp[ ID_SHOWHUD ] , (MAX_LEVELS[g_iLevel[ ID_SHOWHUD ]]));
}
}
public SaveData(id) {
new AuthID[35]
get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s-cso",AuthID)
format(vaultdata,255,"%i#%i#",g_iLevel[id],g_iExp[id])
nvault_set(g_vault,vaultkey,vaultdata)
return PLUGIN_CONTINUE
}
public LoadData(id)
{
new AuthID[35]
get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s-cso",AuthID)
format(vaultdata,255,"%i#%i#",g_iLevel[id],g_iExp[id])
nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new experience[32], playerlevel[32]
parse(vaultdata, experience, 31, playerlevel, 31)
g_iLevel[id] = str_to_num(experience)
g_iExp[id] = str_to_num(playerlevel)
return PLUGIN_CONTINUE
}
public native_get_user_exp(id)
{
return g_iExp[id];
}
public native_set_user_exp(id, amount)
{
g_iExp[id] = amount;
}
public native_get_user_level(id)
{
return g_iLevel[id];
}
public native_set_user_level(id, amount)
{
g_iLevel[id] = amount;
}
stock color_print( const id , const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, "!g", "^4" ) // Green Color
replace_all(msg, 190, "!y", "^1" ) // Default Color
replace_all(msg, 190, "!team", "^3" ) // Team 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();
}
}
}
}