#include amxmodx
#include amxmisc
#include cstrike
#include fakemeta
#include hamsandwich
#include csx
#include SpecialGeoip
#include nvault
#include fm_credits
#define TASK_PRESENTS 1337
#define TASK_SHOWHUD 2674
#define ID_PRESENTS (TaskIndex - TASK_PRESENTS)
#define ID_SHOWHUD (TaskIndex - TASK_SHOWHUD)
// Variabile
new credite[33], killuri[33], MesajSync, MesajSync2
// Cvaruri
new cvar_bplant, cvar_bexp, cvar_bdef, cvar_crdammount, cvar_bonus, cvar_killneed, cvar_how_much, cvar_donate, cvar_hudenable, cvar_firstkill
// Constante
new const cfgfile[] = "fm_credits.cfg"
new const TAG[] = "[ Draken ]"
new const logcommand[] = "fmcredits_command.log"
new const logfile[] = "fmcredits_donate.log"
new bool:g_bFirstKillWasMade = false, g_iMaxPlayers
new souls[33]
new g_vault
public plugin_init()
{
register_plugin("Depozit Nou Bani", "2.3beta", "Sprit3x")
// Register Commands
register_clcmd("say /retrage", "retrage")
register_clcmd("say /depozit", "depoziteaza")
register_clcmd("say /credite", "credits")
register_clcmd("say /points", "motdcredite");
register_concmd("amx_credits", "cmdGive", ADMIN_IMMUNITY, "<nume sau #userid> [credite]")
// Register Ham
RegisterHam(Ham_Killed, "player", "player_killed")
register_event("HLTV", "ev_NewRound", "a", "1=0", "2=0")
// Register Cvars
cvar_bplant = register_cvar("credits_bplant_reward", "5")
cvar_bexp = register_cvar("credits_bexp_reward", "5")
cvar_bdef = register_cvar("credits_bdef_reward", "5")
cvar_crdammount = register_cvar("credits_event_reward", "3")
cvar_bonus = register_cvar("credits_bonuskills", "25")
cvar_killneed = register_cvar("credits_killsneed", "10")
cvar_how_much = register_cvar("credits_excvalue", "16000")
cvar_donate = register_cvar("credits_donate", "1")
cvar_hudenable = register_cvar("credits_hudstats", "1")
cvar_firstkill = register_cvar("credits_firstkill", "1")
// Register Messages
MesajSync = CreateHudSyncObj()
MesajSync2 = CreateHudSyncObj()
g_iMaxPlayers = get_maxplayers()
register_message(get_user_msgid("SayText"), "message")
}
public plugin_cfg()
{
new cfgdir[32]
get_configsdir(cfgdir, charsmax(cfgdir))
server_cmd("exec %s/%s", cfgdir, cfgfile)
g_vault = nvault_open("dfgdsystem")
if (g_vault == INVALID_HANDLE)
set_fail_state("Error opening nVault")
}
public plugin_end()
{
nvault_close(g_vault)
}
public motdcredite(Client)
show_motd(Client, "
http://csoutstanding...ver/fury/points", "Points Motd");
public ev_NewRound() g_bFirstKillWasMade = false;
public plugin_natives()
{
register_native("fm_get_credits", "get_credits")
register_native("fm_set_credits", "set_credits")
register_native("fm_get_souls", "get_souls")
register_native("fm_set_souls", "set_souls")
}
public client_putinserver(id)
{
if (is_user_bot(id) || is_user_hltv(id))
{
credite[id] = killuri[id] = 0;
return -1;
}
set_task(2.0, "LoadData", id)
set_task(1.0, "MesajHUD", id+TASK_SHOWHUD, .flags = "b")
set_task(60.0, "da_credite", id+TASK_PRESENTS, .flags = "b")
return 1;
}
public client_disconnect(id)
{
remove_task(id+TASK_SHOWHUD);
remove_task(id+TASK_PRESENTS);
SaveData(id)
credite[id] = 0
souls[id] = 0
}
public message()
{
new arg[32]
get_msg_arg_string(2, arg, 31)
if(containi(arg,"name")!=-1)
{
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public client_infochanged(id)
{
new newname[32],oldname[32]
get_user_info(id, "name", newname,31)
get_user_name(id,oldname,31)
if(!is_user_connected(id) || is_user_bot(id)) return PLUGIN_CONTINUE
if(!equali(newname, oldname))
{
set_user_info(id,"name",oldname)
client_print(id , print_console , "[Draken] Prohibition of nick change!")
return PLUGIN_HANDLED
}
return PLUGIN_CONTINUE
}
public bomb_planted(id)
{
new nume[32];
get_user_name(id, nume, 31)
credite[id] += get_pcvar_num(cvar_bplant)
color(0, ".v%s.e %s.g receiving.e %d.g credits for planting bomb.", TAG, nume, get_pcvar_num(cvar_bplant))
SaveData(id)
}
public bomb_explode(id)
{
new nume[32];
get_user_name(id, nume, 31)
credite[id] += get_pcvar_num(cvar_bexp)
color(0, ".v%s.e %s.g a receiving.e %d.g credits for the bomb exploded.", TAG, nume, get_pcvar_num(cvar_bexp))
SaveData(id)
}
public bomb_defused(id)
{
new nume[32];
get_user_name(id, nume, 31)
credite[id] += get_pcvar_num(cvar_bdef)
color(0, ".v%s.e %s.g a receving.e %d.g credits for bomb defused.", TAG, nume, get_pcvar_num(cvar_bdef))
SaveData(id)
}
public da_credite(TaskIndex)
{
color(ID_PRESENTS, ".v%s.g You got.e %d credits.g pentru because you played.e 1 .gminuts.", TAG, get_pcvar_num(cvar_crdammount))
color(ID_PRESENTS, ".v%s.g Continue to play and get .e credits .gcontinuous.", TAG)
credite[ID_PRESENTS] += get_pcvar_num(cvar_crdammount)
SaveData(ID_PRESENTS)
}
public donate(id, arg[])
{
new cui[32], count[10]
strbreak(arg, cui, 31, count, 9)
if (!(get_user_flags(id) & ADMIN_RESERVATION))
{
color(id, ".v%s.g The command can be used by those with degree .v slot+", TAG)
return
}
if (!cui[0] || !count[0])
{
color(id, ".v%s.g The command is used as the next:.e /donate name credits.g.", TAG)
return
}
new credite_trimise = credite[id]
new credite2
if (equal(count, "all"))
credite2 = credite_trimise
else
credite2 = str_to_num(count)
if (credite2 <= 0)
{
color(id, ".v%s.g The value you entered is invalid.", TAG)
return
}
credite_trimise -= credite2
if (credite_trimise < 0)
{
credite2 += credite_trimise
credite_trimise = 0
}
new primitor = cmd_target(id, cui, (CMDTARGET_ALLOW_SELF))
if (!primitor || primitor == id)
{
color(id, ".v%s.g %s.g no exist from server.", TAG, cui)
return
}
credite[primitor] += credite2
credite[id] = credite_trimise
SaveData(primitor)
SaveData(id)
new tNume[32], pNume[32]
get_user_name(id, tNume, 31)
get_user_name(primitor, pNume, 31)
color(0, ".v%s.g %s.g Sends his.e %s %d.g credits", TAG, tNume, pNume, credite2)
log_to_file(logfile, "Player %s sends his %d credits his %s", tNume, credite2, pNume)
}
public retrage(id)
{
if(credite[id] > 0)
{
new bani = get_pcvar_num(cvar_how_much);
if(cs_get_user_money(id) >= 16000)
{
color(id, ".v[%s].g You already.e 16000$.g and you can not withdraw.", TAG)
}
else if(cs_get_user_money(id) + bani < 16000)
{
cs_set_user_money(id, cs_get_user_money(id) + bani)
credite[id]--
SaveData(id)
color(id, ".v[%s].g You withdrew 1 credit.e %d$.g . Now you.e %d$.g", TAG, bani, cs_get_user_money(id))
}
else if(cs_get_user_money(id) + bani >= 16000)
{
cs_set_user_money(id, 16000)
credite[id]--
SaveData(id)
color(id, ".v[%s].g You withdrew 1 credit, ie.e %d$.g. Now you.e %d$.g", TAG, bani, cs_get_user_money(id))
}
}
else
{
color(id, ".v[%s].g You have no credit.", TAG)
}
return PLUGIN_HANDLED;
}
public depoziteaza(id)
{
if(cs_get_user_money(id) >= get_pcvar_num(cvar_how_much))
{
credite[id]++
cs_set_user_money(id, cs_get_user_money(id) - get_pcvar_num(cvar_how_much))
color(id, ".v[%s].g Ai depozitat un credit. Ai.e %d.g credite.", TAG, credite[id])
SaveData(id)
}
else
{
color(id, ".v[%s].g Iti trebuie %d$ pentru a putea depozita un credit.", TAG, get_pcvar_num(cvar_how_much))
}
return PLUGIN_HANDLED;
}
public credits(id)
{
color(id, ".v[%s].g You have.e %d.g credits.", TAG, credite[id])
return PLUGIN_HANDLED;
}
public cmdGive(id, level, cid)
{
if(!cmd_access(id, level, cid, 3))
{
return PLUGIN_HANDLED;
}
new arg[32], name[32];
read_argv(1, arg, 31)
get_user_name(id, name, 31)
new jucator = cmd_target(id, arg, 31)
if(!jucator)
{
return PLUGIN_HANDLED
}
if(!is_user_connected(id) || !is_user_connected(jucator))
{
return PLUGIN_HANDLED
}
new cant[4], name2[32];
get_user_name(jucator, name2, 31)
read_argv(2, cant, 3)
new creditss = str_to_num(cant)
credite[jucator] += creditss
SaveData(jucator)
color(0, ".v%s.g Admins.e %s.g she's dedication.e %s %d.g credits.", TAG, name, name2, creditss)
log_to_file(logcommand, "Admins %s she's dedication %s %d credits.", name, name2, creditss)
return PLUGIN_HANDLED;
}
public get_credits(plugin, params)
{
return credite[get_param(1)];
}
public set_credits(plugin, params)
{
new client = get_param(1);
credite[client] = max(0, get_param(2));
SaveData(client);
return credite[client];
}
public get_souls(plugin, params)
{
return souls[get_param(1)];
}
public set_souls(plugin, params)
{
new client = get_param(1);
souls[client] = max(0, get_param(2));
SaveData(client);
return souls[client];
}
public player_killed(victima, atacator)
{
if(victima == atacator || !is_user_connected(atacator) || !is_user_connected(victima))
return 1;
if(killuri[atacator] > 9)
{
killuri[atacator] = 0
credite[atacator] += get_pcvar_num(cvar_bonus)
color(atacator, ".v%s.g You got.e %d credits.g for accumulation a.e 10 kills.g. Play well.", TAG, get_pcvar_num(cvar_bonus))
souls[atacator]++
client_print(atacator, print_center, "+1 Souls")
}
if (get_pcvar_num(cvar_firstkill))
{
if( ( 1 <= atacator <= g_iMaxPlayers ) && atacator != victima )
{
if( cs_get_user_team( atacator ) == CS_TEAM_T && !g_bFirstKillWasMade )
{
g_bFirstKillWasMade = true;
credite[atacator] += 5;
client_print(atacator, print_center, "+5 Credits")
static szKillerName[ 32 ], szVictimName[ 32 ];
get_user_name( atacator, szKillerName, sizeof ( szKillerName ) -1 );
get_user_name( victima, szVictimName, sizeof ( szVictimName ) -1 );
set_hudmessage( 0, 255, 255, -1.0, 0.30, 0, 0.0, 4.5, 0.0, 0.0, -1 );
ShowSyncHudMsg( 0, MesajSync2, "[T] %s made first frag on %s^n and recived 5 credits !", szKillerName, szVictimName );
}
else if( cs_get_user_team( atacator ) == CS_TEAM_CT && !g_bFirstKillWasMade )
{
g_bFirstKillWasMade = true;
credite[atacator] += 5;
client_print(atacator, print_center, "+5 Credits")
static szKillerName[ 32 ], szVictimName[ 32 ];
get_user_name( atacator, szKillerName, sizeof ( szKillerName ) -1 );
get_user_name( victima, szVictimName, sizeof ( szVictimName ) -1 );
set_hudmessage( 0, 255, 255, -1.0, 0.30, 0, 0.0, 4.5, 0.0, 0.0, -1 );
ShowSyncHudMsg( 0, MesajSync2, "[CT] %s made first frag on %s^n and recived 5 credits !", szKillerName, szVictimName );
}
}
}
killuri[atacator]++
SaveData(atacator)
return 1;
}
public MesajHUD(TaskIndex)
{
static id
id = ID_SHOWHUD;
if (!is_user_alive(id))
{
id = pev(id, pev_iuser2)
if(!is_user_alive(id)) return;
}
if (get_pcvar_num(cvar_hudenable))
{
if(id != ID_SHOWHUD)
{
new nume[32], szcountry[128], szcity[128];
get_user_name(id, nume, 31)
GetClientGeoData(id, CountryName, szcountry, 127)
GetClientGeoData(id, City, szcity, 127)
set_hudmessage(0, 100, 250, -1.0, 0.85, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, MesajSync, "Spectating %s^nHP: %d - Credits: %d - Kill for bonus: [%d/%d] - Souls: %d^nFrom: %s , %s", nume, pev(id, pev_health), credite[id], killuri[id], get_pcvar_num(cvar_killneed), souls[id], szcountry, szcity)
}
else
{
set_hudmessage(0, 100, 250, 0.01, 0.92, 0, 6.0, 1.1, 0.0, 0.0, -1)
ShowSyncHudMsg(ID_SHOWHUD, MesajSync, "HP: %d | Credits: %d | Kill for bonus: [%d/%d] | Souls: %d", pev(ID_SHOWHUD, pev_health), credite[ID_SHOWHUD], killuri[ID_SHOWHUD], get_pcvar_num(cvar_killneed), souls[ID_SHOWHUD])
}
}
}
color(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, ".v", "^4")
replace_all(msg, 190, ".g", "^1")
replace_all(msg, 190, ".e", "^3")
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();
}
}
}
}
public LoadData(id)
{
static name[32]
get_user_name(id, name, sizeof(name) - 1)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s",name)
format(vaultdata,255,"%i#%i#^n",credite[id],souls[id])
nvault_get(g_vault,vaultkey,vaultdata,255)
replace_all(vaultdata, 255, "#", " ")
new playerxp[32], playerlevel[32]
parse(vaultdata, playerxp, 31, playerlevel, 31)
credite[id] = str_to_num(playerxp)
souls[id] = str_to_num(playerlevel)
}
public SaveData(id)
{
static name[32]
get_user_name(id, name, sizeof(name) - 1)
new vaultkey[64],vaultdata[256]
format(vaultkey,63,"%s",name)
format(vaultdata,255,"%i#%i#",credite[id],souls[id])
nvault_set(g_vault,vaultkey,vaultdata)
}