/////////////////////////////////////////////////////////////////////////////
//==============================
//= Szintrendszer =
//==============================
//
//---------------------
//- Description -
//---------------------
//
//This plugin include the features:
//** XP System - nVault
//** Level System - nVault
//** Cvars to control all bonus per lvl
//** Commands to Add & Remove XP
//** Level behind the Nick Name
//** Bonus Per level
//** ADM Chat Colors Support
//** ...
//
//----------------------
//- Requirements -
//----------------------
//
//** AMXX: Version 1.8.1
//** AMXX Modules: Cstrike, Fun, Engine, Fakemeta, ColorChat, nVault and Hamsandwich modules
//
//----------------------
//- Installation -
//----------------------
//
//1- Download and compile the plugin from:
//2- Upload the amxx file to your server (cstrike>addons>amxmodx>plugins).
//3- Edit the config file and add the plugin (cstrike>addons>amxmodx>configs>plugins.ini).
//
//----------------------
//- Contact Info -
//----------------------
//
//For reporting bugs or post your feedback visit:
//https://forums.alliedmods.net/showthread.php?p=1810627
//
//If you want some private job PM ME on alliedmodders Forum's or send me and email to:
//
//-----------------
//- Credits -
//-----------------
//
//** Ex1ne
//- XP System & Level System
//
//** matsi
//- Observations and optimizations
//
//** tre3fla
//- Suggestion and request
//
//** ConnorMcLeod
//- Suggestion, SayTxt and Admin Chat Colors Code
//
//** xBatista
//- ShowHud Help
//
//------------------
//- Updates Logs -
//------------------
//
//** v0.0.1 [Oct 2012]
//- First Release
//
//** v0.0.2 [Oct 2012]
//- Optimize & Improve Code
//
//** v0.0.3 [Oct 2012]
//- Optimize Code
//
//** v0.0.4 [Oct 2012]
//- Improve Level Prefix and Personal Info
//
//** v0.0.5 [Oct 2012]
//- Optimize EventDeathMsg
//- Improve Check Level
//
//** v0.0.6 [Oct 2012]
//- Fix Damage Bug
//- Fix Messages Bugs
//
//** v0.0.7 [Oct 2012]
//- Fix Index of Bounds
//
//** v0.0.8 [Oct 2012]
//- Added feature Admin Chat Colors
//
//** v0.0.9 [Oct 2012]
//- Fix some Bugs & Added XP Reward MSG CVAR
//
//** v1.0 [Jan 2013]
//- Fix Give & Remove XP Command
//
////////////////////////////////////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
#include <nvault>
enum Color
{
NORMAL = 1, // clients scr_concolor cvar color
GREEN, // Green Color
TEAM_COLOR, // Red, grey, blue
GREY, // grey
RED, // Red
BLUE, // Blue
}
new TeamName[][] =
{
"",
"TERRORIST",
"CT",
"SPECTATOR"
}
ColorChat(id, Color:type, const msg[], {Float,Sql,Result,_}:...)
{
static message[256];
switch(type)
{
case NORMAL: // clients scr_concolor cvar color
{
message[0] = 0x01;
}
case GREEN: // Green
{
message[0] = 0x04;
}
default: // White, Red, Blue
{
message[0] = 0x03;
}
}
vformat(message[1], 251, msg, 4);
message[192] = '^0';
static team, ColorChange, index, MSG_Type;
if(id)
{
MSG_Type = MSG_ONE;
index = id;
} else {
index = FindPlayer();
MSG_Type = MSG_ALL;
}
team = get_user_team(index);
ColorChange = ColorSelection(index, MSG_Type, type);
ShowColorMessage(index, MSG_Type, message);
if(ColorChange)
{
Team_Info(index, MSG_Type, TeamName[team]);
}
}
ShowColorMessage(id, type, message[])
{
message_begin(type, get_user_msgid("SayText"), _, id);
write_byte(id)
write_string(message);
message_end();
}
Team_Info(id, type, team[])
{
message_begin(type, get_user_msgid("TeamInfo"), _, id);
write_byte(id);
write_string(team);
message_end();
return 1;
}
ColorSelection(index, type, Color:Type)
{
switch(Type)
{
case RED:
{
return Team_Info(index, type, TeamName[1]);
}
case BLUE:
{
return Team_Info(index, type, TeamName[2]);
}
case GREY:
{
return Team_Info(index, type, TeamName[0]);
}
}
return 0;
}
FindPlayer()
{
static i;
i = -1;
while(i <= get_maxplayers())
{
if(is_user_connected(++i))
{
return i;
}
}
return -1;
}
#include <cstrike>
#include <fun>
#include <hamsandwich>
#include <fakemeta>
new Level[33], eXP[33]
new KillXp, HsXp, HeXp/*, KnifeXp*/
new gVault
new const szPrefix[] = "[^4Szintrendszer^3] -"
#define MaxLevels 12
#define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
#define TASK_SHOW_HUD 10113
new g_msgHudSync
new bool:is_user_ignored[ 33 ]
new const Levels[MaxLevels] =
{
100, // Starter #1
150, // Noob #2
200, // Beginner #3
250, // Knifer #4
300, // Rambo #5
350, // Butcher #6
400, // Matrix #7
450, // Probhop #8
550, // Freak #9
600, // Racer #10
650, // Kill Bill #11
700 // Respected Player #12
}
new const Prefix[MaxLevels +1][] =
{
"Kezdo", // 0
"Ujonc", // 1
"Halado", // 2
"TudValamit", // 3
"Gyilkos", // 4
"LoL", // 5
"Orult", // 6
"Wh-s", // 7
"Legyozhetetlen", // 8
"Aimos", // 9
"Mester", // 10
"Eszmeletlen", // 11
"LegenD" // 12
}
// Bonus Stuff
new healthperlevel,
armorperlevel,
speedperlevel,
damageperlevel,
gravityperlvl
new g_iMaxPlayers
// ADMIN CHAT COLORS by ConnorMcLeod
enum _:ADMIN_DATAS
{
m_szName[32],
m_iFlag
}
new const AdminsDatas[][ADMIN_DATAS] =
{
{"Owner", ADMIN_IMMUNITY},
{"Manager", ADMIN_BAN},
// {"SuperAdmin", ADMIN_CFG},
{"Admin", ADMIN_KICK},
{"VIP", ADMIN_RESERVATION}
};
public plugin_init()
{
register_plugin("Deathrun XP & Level Mod", "0.0.9", "Freestyle")
register_message(get_user_msgid("SayText"),"Message_SayText"); // CREDITS TO ConnorMcLeod
RegisterHam ( Ham_Spawn, "player", "Ham_CheckOthers_Bonus", 1);
RegisterHam ( Ham_TakeDamage, "player", "Ham_CheckDamage_Bonus", .Post = false );
RegisterHam ( Ham_Item_PreFrame, "player", "Ham_CheckSpeed_Bonus", 1);
g_iMaxPlayers = get_maxplayers( );
register_cvar( "AdminChatColors_On", "1" ); // Admin Tag - Example: [Admin] Freestyle
register_cvar( "XP_Reward_MSG", "1" ); // Message of the XP Gain
// CHAT COMMANDS //
register_clcmd ( "say /xp", "ShowPlayerXP")
register_clcmd ( "say_team /xp", "ShowPlayerXP")
register_clcmd ( "say /level", "ShowPlayerLevel")
register_clcmd ( "say_team /level", "ShowPlayerLevel")
// XP SYSTEM //
KillXp = register_cvar("drxp_per_kill", "1")
HsXp = register_cvar("drxp_per_hs", "1")
HeXp = register_cvar("drxp_per_nade_kill", "2")
//KnifeXp = register_cvar("drxp_per_knife_kill", "2")
// Give & Remove XP //
register_concmd ( "give_xp", "CmdAddXP", ADMIN_RCON, "<nick, #userid, authid | @all> <xp>" )
register_concmd ( "remove_xp", "CmdRemoveXP", ADMIN_RCON, "<nick, #userid, authid | @all> <xp>" )
/* Bonus Stuff */
// Health Per Level //
healthperlevel = register_cvar("health_per_lvl", "0")
// Armor Per Level //
armorperlevel = register_cvar("armor_per_lvl", "0")
// Speed Per Level //
speedperlevel = register_cvar("speed_per_lvl", "0")
// Gravity Per Level //
gravityperlvl = register_cvar("gravity_per_lvl", "0") // NERVER MORE THAN 66 PER LVL
// Damage Per Level //
damageperlevel = register_cvar("damage_per_lvl", "0")
g_msgHudSync = CreateHudSyncObj()
}
public plugin_cfg( )
{
gVault = nvault_open( "DEATHRUN_XP" )
if ( gVault == INVALID_HANDLE )
set_fail_state( "Error opening nVault" );
}
/* INFO ABOUT PERSONAL XP/LEVEL */
public ShowPlayerXP(id)
{
ColorChat(id, GREY, "%s Neked ^4%i^3 XP-d van es a szinted: ^4%s^3!", szPrefix, eXP[id], Prefix[Level[id]])
}
public ShowPlayerLevel(id)
{
new name[32]
get_user_name(id, name, sizeof(name) -1)
ColorChat(id, GREY, "%s A te szinted: ^4%s^3 ^4%i^3 XP-vel!", szPrefix, Prefix[Level[id]], eXP[id])
}
public Ham_CheckDamage_Bonus( pevVictim, pevInflictor, pevAttacker, Float:flDamage, iDmgBits )
{
if( !( 1 <= pevAttacker <= g_iMaxPlayers) )
{
return HAM_HANDLED;
}
if( !is_user_alive( pevAttacker ) )
{
return HAM_HANDLED;
}
SetHamParamFloat( 4 , flDamage + ( get_pcvar_num( damageperlevel ) * Level[ pevAttacker ] ) )
return HAM_IGNORED;
}
/* Speed Check */
public Ham_CheckSpeed_Bonus( id )
{
if( !is_user_alive( id ) || cs_get_user_team( id ) != CS_TEAM_T )
{
return HAM_IGNORED;
}
set_user_maxspeed( id, 250.0 + ( get_pcvar_num(speedperlevel) * Level[ id ] ) );
return HAM_IGNORED;
}
/* HP & AP & Gravity Check */
public Ham_CheckOthers_Bonus(id)
{
if( !is_user_alive( id ) || cs_get_user_team( id ) != CS_TEAM_T )
return HAM_IGNORED;
// HP Check
new HPCheck = ( get_user_health(id) + get_pcvar_num(healthperlevel) * Level[ id ] );
set_user_health( id, HPCheck );
// AP Check
new APCheck = ( get_user_armor(id) + get_pcvar_num(armorperlevel) * Level[ id ] );
set_user_armor( id, APCheck );
// Gravity
new GRAVITYCheck = 800 - ( get_pcvar_num( gravityperlvl ) * Level[ id ] );
if(get_pcvar_num(gravityperlvl) > 66)
{
set_user_gravity( id, float( 8 ) / 800.0 );
}
else
{
set_user_gravity( id, float( GRAVITYCheck ) / 800.0 );
}
remove_task( TASK_SHOW_HUD + id );
set_task(0.1, "ShowHud", TASK_SHOW_HUD + id)
return HAM_IGNORED;
}
/* Respected Player Join / Leave Stuff */
public LvL_12_PlayerJoin(id)
{
new name[32]
get_user_name(id, name, sizeof(name) -1)
ColorChat(0, GREY, "%s ^4Egy LegenD : ^1%s^4 belepett,^1%i^4 XP-je van!", szPrefix, name, eXP[id])
}
public LvL_12_PlayerRemove(id)
{
new name[32]
get_user_name(id, name, sizeof(name) -1)
ColorChat(0, GREY, "%s ^4Egy LegenD : %s lelepett %i XP-je van!", szPrefix, name, eXP[id])
}
public plugin_end( )
nvault_close( gVault )
public client_putinserver(id)
{
LoadData(id)
set_task( 3.0, "ShowHud", id, .flags = "b" );
if(Level[id] == 12)
{
set_task(5.0, "LvL_12_PlayerJoin", id)
}
}
public client_disconnect(id)
{
SaveData(id)
if(Level[id] == 12)
{
set_task(1.0, "LvL_12_PlayerRemove", id)
}
}
/* XP REWARDS */
public client_death( iKiller, iVictim, wpnindex, hitplace )
{
new vname[32]
new kname[32]
get_user_name( iKiller, kname, charsmax( kname ) )
get_user_name( iVictim, vname, charsmax( vname ) )
if( is_user_ignored[ iKiller ] )
return PLUGIN_HANDLED_MAIN
get_user_name( iKiller, kname, charsmax( kname ) )
get_user_name( iVictim, vname, charsmax( vname ) )
if( iKiller != iVictim && ( 1 <= iKiller <= g_iMaxPlayers ) && ( 1 <= iVictim <= g_iMaxPlayers ) && !( hitplace == HIT_HEAD ) && !( wpnindex == CSW_HEGRENADE ) )
{
eXP[iKiller] += get_pcvar_num(KillXp)
if( get_cvar_num("XP_Reward_MSG") == 1 )
{
ColorChat ( iKiller, GREY, "%s Kaptal^4 %i^3 XP-t mert megolted ^4 %s^3-t", szPrefix, get_pcvar_num(KillXp), vname )
}
}
if( hitplace == HIT_HEAD )
{
eXP[iKiller] += get_pcvar_num(HsXp)
if( get_cvar_num("XP_Reward_MSG") == 1 )
{
ColorChat ( iKiller, GREY, "%s Kaptal^4 %i^3 XP-t mert megolted ^4 %s^3-t", szPrefix, get_pcvar_num (HsXp), vname )
}
}
if( wpnindex == CSW_HEGRENADE && iKiller != iVictim )
{
eXP[iKiller] += get_pcvar_num(HeXp)
if( get_cvar_num("XP_Reward_MSG") == 1 )
{
ColorChat( iKiller, GREEN, "%s Kaptal^4 %i^3 XP-t mert megolted ^4 %s^3-t", szPrefix, get_pcvar_num (HeXp), vname )
}
}
CheckLevel(iKiller)
SaveData(iKiller)
return PLUGIN_CONTINUE
}
public CheckLevel(id)
{
if(Level[id] < MaxLevels-1)
{
while(eXP[id] >= Levels[Level[id]])
{
Level[id] += 1
ColorChat(id, GREY, "%s Gratulalok szintet leptel, mostani szinted szama : ^4%i^3", szPrefix, Level[id])
}
}
}
/* HUD PERMANENT INFO */
public ShowHud(task)
{
new id = task - TASK_SHOW_HUD
if(!is_user_alive(id))
return;
set_hudmessage(0, 0, 0, 0.02, 0.33, 0, 0.0, 0.3, 0.0, 0.0)
ShowSyncHudMsg(id, g_msgHudSync,"[Szinted : %s]^n[XP-d : %i]", Prefix[Level[id]], eXP[id])
set_task(0.1, "ShowHud", TASK_SHOW_HUD + id)
}
/* nVault Stuff */
public SaveData(id)
{
new AuthID[35]
get_user_authid(id,AuthID,34)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s-Mod",AuthID)
format(vaultdata,255,"%i#%i#",eXP[id],Level[id])
nvault_set(gVault,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-Mod",AuthID)
format(vaultdata,255,"%i#%i#",eXP[id],Level[id])
nvault_get(gVault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new playerxp[32], playerlevel[32]
parse(vaultdata, playerxp, 31, playerlevel, 31)
eXP[id] = str_to_num(playerxp)
Level[id] = str_to_num(playerlevel)
return PLUGIN_CONTINUE
}
/* Remove And Add XP */
public CmdAddXP ( iPlayer, level, cid )
{
if( !cmd_access( iPlayer, level, cid, 3 ) ) return PLUGIN_HANDLED;
new arg [ 32 ]
read_argv ( 1, arg, 31 )
new AddXP [ 32 ]
read_argv ( 2, AddXP, charsmax ( AddXP ) )
new XPtoGive = str_to_num ( AddXP )
new AdminName [ 32 ]
new TargetName [ 32 ]
get_user_name ( iPlayer, AdminName, charsmax ( AdminName ) )
if( arg[0]=='@' )
{
if( equali(arg[1],"All") || equali(arg[1],"ALL") )
{
new players[32], totalplayers, All
get_players( players, totalplayers )
for ( new i = 0; i < totalplayers; i++ )
{
All = players[ i ]
eXP[ All ] += XPtoGive
}
CheckLevel( All )
ColorChat ( 0, GREY, "%s ^1%s^3 adott^1 %i^3 XP-t minden ^1 jatekosnak^3!", szPrefix, AdminName, XPtoGive )
}
else if( equali(arg[1],"T") || equali(arg[1],"t") )
{
new players[32], totalplayers, T
get_players( players, totalplayers )
for ( new i = 0; i < totalplayers; i++ )
{
if ( get_user_team(players[ i ]) == 1 )
{
T = players[ i ]
eXP[ T ] += XPtoGive
}
}
CheckLevel( T )
ColorChat ( 0, GREY, "%s ^1%s^3 adott^1 %i^3 XP-t minden^1 Terrornak^3!", szPrefix, AdminName, XPtoGive )
}
else if( equali(arg[1],"CT") || equali(arg[1],"ct") )
{
new players[32], totalplayers, CT
get_players( players, totalplayers )
for( new i = 0; i < totalplayers; i++ )
{
if( get_user_team(players[ i ] ) == 2 )
{
CT = players[ i ]
eXP[ CT ] += XPtoGive
}
}
CheckLevel( CT )
ColorChat ( 0, GREY, "%s ^1%s^3 adott^1 %i^3 XP-t minden^1 CT-nek^3!", szPrefix, AdminName, XPtoGive )
}
}
else
{
new iTarget = cmd_target( iPlayer, arg, 3 )
get_user_name ( iTarget, TargetName, charsmax ( TargetName ) )
if( iTarget )
{
eXP[ iTarget ] += XPtoGive
CheckLevel( iTarget )
ColorChat ( 0, GREY, "%s ^1%s^3 adott^1 %i^3 XP-t ^1 %s-nek^3", szPrefix, AdminName, XPtoGive, TargetName )
}
}
return PLUGIN_HANDLED
}
public CmdRemoveXP ( iPlayer, level, cid )
{
if( !cmd_access(iPlayer, level, cid, 3) ) return PLUGIN_HANDLED;
new arg [ 32 ]
read_argv ( 1, arg, 31 )
new RemoveXP [ 32 ]
read_argv ( 2, RemoveXP, charsmax ( RemoveXP ) )
new XPtoRemove = str_to_num ( RemoveXP )
new AdminName [ 32 ]
new TargetName [ 32 ]
get_user_name ( iPlayer, AdminName, charsmax ( AdminName ) )
if( arg[0]=='@' )
{
if( equali(arg[1],"All") || equali(arg[1],"ALL") )
{
new players[32], totalplayers, All
get_players( players, totalplayers )
for ( new i = 0; i < totalplayers; i++ )
{
All = players[ i ]
eXP[ All ] -= XPtoRemove
}
CheckLevel( All )
ColorChat ( 0, GREY, "%s ^1%s^3 elvett^1 %i^3 XP-t ^1mindenkitol^3!", szPrefix, AdminName, XPtoRemove )
}
else if( equali(arg[1],"T") || equali(arg[1],"t") )
{
new players[32], totalplayers, T
get_players( players, totalplayers )
for ( new i = 0; i < totalplayers; i++ )
{
if ( get_user_team(players[ i ]) == 1 )
{
T = players[ i ]
eXP[ T ] -= XPtoRemove
}
}
CheckLevel( T )
ColorChat ( 0, GREY, "%s ^1%s^3 elvett^1 %i^3 XP-t minden^1 Terroristatol^3!", szPrefix, AdminName, XPtoRemove )
}
else if( equali(arg[1],"CT") || equali(arg[1],"ct") )
{
new players[32], totalplayers, CT
get_players( players, totalplayers )
for( new i = 0; i < totalplayers; i++ )
{
if( get_user_team(players[ i ] ) == 2 )
{
CT = players[ i ]
eXP[ CT ] -= XPtoRemove
}
}
CheckLevel( CT )
ColorChat ( 0, GREY, "%s ^1%s^3 elvett^1 %i^3 XP-t minden^1 CT-tol^3!", szPrefix, AdminName, XPtoRemove )
}
}
else
{
new iTarget = cmd_target( iPlayer, arg, 3 )
get_user_name ( iTarget, TargetName, charsmax ( TargetName ) )
if( !iTarget )
return PLUGIN_HANDLED
eXP[ iTarget ] -= XPtoRemove
CheckLevel( iTarget )
ColorChat ( 0, GREY, "%s ^1%s^3 adott^1 %i^3 XP-t ^1 %s-nek^3", szPrefix, AdminName, XPtoRemove, TargetName )
}
return PLUGIN_HANDLED
}
/* Level Behind Nick & AdminChatColors
CREDITS TO ConnorMcLeod */
public Message_SayText(msgId,msgDest,msgEnt)
{
new id = get_msg_arg_int(1);
if( is_user_connected(id) )
{
if( get_cvar_num("AdminChatColors_On") == 1 )
{
new flags = get_user_flags(id)
for(new i; i<sizeof(AdminsDatas); i++)
{
if( flags & AdminsDatas[i][m_iFlag] )
{
new szChannel[64]
get_msg_arg_string(2, szChannel, charsmax(szChannel))
if( equal(szChannel, "#Cstrike_Chat_All") )
{
formatex(szChannel, charsmax(szChannel), "^4[%s - %s] ^3%%s1 ^1: %%s2", Prefix[Level[id]], AdminsDatas[i][m_szName])
set_msg_arg_string(2, szChannel)
}
else if( !equal(szChannel, "#Cstrike_Name_Change") )
{
format(szChannel, charsmax(szChannel), "^4[%s - %s] %s", Prefix[Level[id]], AdminsDatas[i][m_szName], szChannel)
set_msg_arg_string(2, szChannel)
}
return
}
else
{
new szChannel[64]
get_msg_arg_string(2, szChannel, charsmax(szChannel))
if( equal(szChannel, "#Cstrike_Chat_All") )
{
formatex(szChannel, charsmax(szChannel), "^4[%s] ^3%%s1 ^1: %%s2", Prefix[Level[id]])
set_msg_arg_string(2, szChannel)
}
else if( !equal(szChannel, "#Cstrike_Name_Change") )
{
format(szChannel, charsmax(szChannel), "^4[%s] %s", Prefix[Level[id]], szChannel)
set_msg_arg_string(2, szChannel)
}
return
}
}
}
else
{
new szChannel[64]
get_msg_arg_string(2, szChannel, charsmax(szChannel));
if( equal(szChannel, "#Cstrike_Chat_All") )
{
formatex(szChannel, charsmax(szChannel), "^4[%s] ^3%%s1 ^1: %%s2", Prefix[Level[id]])
set_msg_arg_string(2, szChannel)
}
else if( !equal(szChannel, "#Cstrike_Name_Change") )
{
format(szChannel, charsmax(szChannel), "^4[%s] %s", Prefix[Level[id]], szChannel)
set_msg_arg_string(2, szChannel)
}
return
}
}
}