Plugin credite furien

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
CaPy.lNt
Membru, skill +1
Membru, skill +1
Posts: 146
Joined: 23 Mar 2013, 21:11
Detinator Steam: Nu
CS Status: studiez
Detinator server CS: DR.ECILA.RO
Reputatie: Restrictie PM
Has thanked: 34 times
Been thanked: 13 times
Contact:

27 Nov 2013, 11:57

Salut..folosesc acest plugin de credite :
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <dhudmessage>
#include <fakemeta>
#include <nvault>

#define PLUGIN  "Depozit Mooney"
#define AUTHOR  "Aragon*"
#define VERSION "1.0"

enum (+= 100)
{
	TASK_MESAJHUD
}

#define ID_HUD (taskid - TASK_MESAJHUD)

new PlayerCredits[10000], retrase[33];
new Vault, SymbolsName, savepoints;

public plugin_init() {         
	register_plugin(PLUGIN,VERSION,AUTHOR)
	register_forward(FM_ClientUserInfoChanged, "ChangeName");
	SymbolsName = register_cvar("fr_name_symbols", ""); 	//| Symbols Name Restricted |//	biohazardshopmod = register_cvar("bh_shop_mode", "1");		//| Money/Points 0 Money Tax -> 1 Points Tax |//
	savepoints = register_cvar("fr_save_points", "1");	//| Save Points Mode 0 Disable -> 1 Name -> 2 IP -> 3 SteamID |//
	register_clcmd("depozit","Depozit")
	register_logevent("round_start", 2, "1=Round_Start")
	register_clcmd("say /depozit","Depozit")
	register_clcmd("say_team /depozit","Depozit")
	register_clcmd("retrage","Retrage")
	register_clcmd("say /retrage","Retrage")
	register_clcmd("say_team /retrage","Retrage")
	register_clcmd("credite","Show_Credits")
	register_clcmd("credite","Show_Credits")
	register_clcmd("say /credite","Show_Credits")
	register_clcmd("say /credite","Show_Credits")
	register_clcmd("say_team /credite","Show_Credits")
	register_clcmd("say_team /credite","Show_Credits")
	register_concmd("amx_give_credits", "Give_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All -> Amount");
	register_concmd("amx_reset_credits", "Reset_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All");
	}
public plugin_natives() {
	register_native("get_user_credits", "get_user_credits", 1);
	register_native("set_user_credits", "set_user_credits", 1);
}
public set_user_credits(id, credits) {
	PlayerCredits[id] = credits;
	SaveCredits(id)
	}
public get_user_credits(id) {
	return PlayerCredits[id]
	}
public client_putinserver(id) {
	LoadCredits(id)
	retrase[id] = 0
	set_task(180.0, "give_credits", id, _, _, "b")
	set_task(1.0, "MesajHUD", id+TASK_MESAJHUD, _, _, "b")
	}
public client_authorized(id) {
	LoadCredits(id)
	}
public client_connected(id) {
	LoadCredits(id)
	}
public client_disconnect(id) {
	SaveCredits(id)
	remove_task(id)
	retrase[id] = 0
	remove_task(id+TASK_MESAJHUD)
	}
	
public give_credits(id)
{
	ColorChat(id, "^x03[FURIEN]^x04 Ai primit^x03 15 credite^x04 pentru ca ai jucat 5 minute.");
	ColorChat(id, "^x03[FURIEN]^x04 Joaca cat mai mult si acumulezi credite in prostie.");
	PlayerCredits[id] += 15
}

public bomb_planted(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 10
	ColorChat(0, "^x03[FURIEN]^x04 Pentru plantarea bombei,^x03 %s^x04 a primit 10 credite.", nume);
}

public bomb_explode(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 20
	ColorChat(0, "^x03[FURIEN]^x04 Pentru explodarea bombei,^x03 %s^x04 a primit 20 credite.", nume);
}

public bomb_defused(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 30
	ColorChat(0, "^x03[FURIEN]^x04 Pentru dezamorsarea bombei,^x03 %s^x04 a primit 30 credite.", nume);
}

public round_start()
{
	static id;
	for (id = 1; id <= get_maxplayers(); id++)
	{
		if(is_user_alive(id))
		{
			retrase[id] = 0
		}
	}
}

public MesajHUD(taskid)
{
	static id
	id = ID_HUD;
	
	if(!is_user_alive(id))
	{
		id = pev(id, pev_iuser2)
		
		if(!is_user_alive(id))
			return;
	}
	
	if(id != ID_HUD)
	{
		new nume[32];
		get_user_name(id, nume, 31)
		set_dhudmessage(255, 255, 0, 0.0, 0.52, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_HUD, "", nume, pev(id, pev_health), PlayerCredits[id])
	}
	else
	{
		set_dhudmessage(255, 255, 0, 0.0, 0.885, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_HUD, "", pev(ID_HUD, pev_health), PlayerCredits[id])
	}
}
	
//------| Change Name |------//
public ChangeName(id, buffer) {
	if(!is_user_connected(id))
	return FMRES_IGNORED;

	static Name[32], Val[32];
	get_user_name(id, Name, sizeof Name - 1);
	engfunc(EngFunc_InfoKeyValue, buffer, "name", Val, sizeof Val - 1);
	
	if(equal(Val, Name))
	return FMRES_IGNORED;
	
	set_task(0.2, "client_connect", id);
	return FMRES_SUPERCEDE;
	}
	
//------| Client connect |------//	
public client_connect(id) {
	static sName[32];
	get_user_name(id, sName, sizeof sName - 1);
	static sChars[32];
	get_pcvar_string(SymbolsName, sChars, sizeof sChars - 1);	
	for(new i = 0 ; i < strlen(sName) ; i++) {
	for(new j = 0 ; j < strlen(sChars) ; j++) {
	if(sName == sChars[j]) {
	server_cmd("kick #%d ^"Numele tau contine caractere nepermise.^"", get_user_userid(id));
	break;
	}
	else {
	LoadCredits(id);
	}
	}
	}
	}
	
public Depozit(id) {
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR) return PLUGIN_HANDLED;
	
	if(cs_get_user_money(id) == 16000) {
	ColorChat(id, "^x03[FURIEN]^x04 Ai depus^x03 $ 16000^x04 si ai primit^x03 un credit^x04.");
	PlayerCredits[id] += 1;
	cs_set_user_money(id, 0);
	}
	else {
	ColorChat(id, "^x03[FURIEN]^x04 Nu ai^x03 $ 16000^x04.");	
	}
	SaveCredits(id)
	return PLUGIN_HANDLED;
	}
	
public Retrage(id) 
{
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
		return PLUGIN_HANDLED;

	if(cs_get_user_money(id) == 16000) 
	{
		ColorChat(id, "^x03[FURIEN]^x04 Ai deja^x03 $ 16000^x04.");
	}
	else if(PlayerCredits[id]) 
	{
		if(retrase[id] < 3)
		{
			ColorChat(id, "^x03[FURIEN]^x04 Ai retras^x03 un credit^x04 si ai primit^x03 $ 16000^x04.");
			PlayerCredits[id] -= 1;
			cs_set_user_money(id, 16000);
			retrase[id]++
		}
		else
		{
			ColorChat(id, "^x03[FURIEN]^x04 Ai retras runda asta deja^x03 3 credite^x04. Incearca runda viitoare.");
		}
	}
	else 
	{
		ColorChat(id, "^x03[FURIEN]^x04 Ai nevoie de^x03 un credit^x04 pentru a retrage.");	
	}
	SaveCredits(id)
	return PLUGIN_HANDLED;
}
	
public Show_Credits(id) {
	set_hudmessage(0, 128, 0, 0.03, 0.86, 2, 6.0, 5.0);
	show_hudmessage(id, "Ai %d credite.", PlayerCredits[id]);
	ColorChat(id, "^x03[FURIEN]^x04 Ai^x03 %d^x04 credite.", PlayerCredits[id]);
	return PLUGIN_HANDLED;
	}
	
public Give_Credits(id, level, cid) {
	if(!cmd_access(id, level, cid, 2)) {
	return PLUGIN_HANDLED;
	}
	new arg[23], gplayers[32], num, i, players, name[32];
	get_user_name(id, name, 31);
	read_argv(1, arg, 23);
	new give_credits[5];
	read_argv(2, give_credits, charsmax(give_credits));
	new Credits = str_to_num(give_credits);
	if(equali(arg, "@T")) {
	get_players(gplayers, num, "e", "TERRORIST");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Furienilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Furienilor.", name, Credits);
	}
	}
	else if(equali(arg, "@CT")) {
	get_players(gplayers, num, "e", "CT");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Anti-Furienilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Anti-Furienilor.", name, Credits);
	}
	}
	if(equali(arg, "@All")) {
	get_players(gplayers, num, "a");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 jucatorilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 a dat^x03 %i credite ^x03 jucatorilor.", name, Credits);
	}
	}
	new player = cmd_target(id, arg, 11);
	if(!player) {
	return PLUGIN_HANDLED;
	}
	PlayerCredits[player] += Credits;
	SaveCredits(id)
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(player, "^x03Adminul^x04 ti-a dat^x03 %i credite.", Credits);
	case 2: ColorChat(player, "^x03%s^x04 ti-a dat^x03 %i credite.", name, Credits);
	}
	return PLUGIN_HANDLED;
	}
	
public Reset_Credits(id, level, cid) {
	if(!cmd_access(id, level, cid, 2)) {
	return PLUGIN_HANDLED;
	}
	new arg[23], gplayers[32], num, i, players, name[32];
	get_user_name(id, name, 31);
	read_argv(1, arg, 23);
	if(equali(arg, "@T")) {
	get_players(gplayers, num, "e", "TERRORIST");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 Furienilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luat^x03 creditele^x04 tuturor^x03 Furienilor.", name);
	}
	}
	
	else if(equali(arg, "@CT")) {
	get_players(gplayers, num, "e", "CT");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 Anti-Furienilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luat^x03 creditele^x04 tuturor^x03 Anti-Furienilor.", name);
	}
	}
	if(equali(arg, "@All")) {
	get_players(gplayers, num, "a");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 jucatorilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luatx03 creditele^x04 tuturor^x03 jucatorilor.", name);
	}
	}
	new player = cmd_target(id, arg, 11);
	if(!player) {
	return PLUGIN_HANDLED;
	}
	PlayerCredits[player] = 0;
	SaveCredits(id)
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(player, "^x03Adminul^x04 ti-a luat^x03 creditele.");
	case 2: ColorChat(player, "^x03%s^x04 ti-a luat^x03 creditele.", name);
	}
	return PLUGIN_HANDLED;
	}
	
//------| Save Credits |------//
public SaveCredits(id) {
	Vault = nvault_open("DepozitCredits");
	new data_credits[256], key_credits[64];
	switch( get_pcvar_num(savepoints) ) { 
	case 1:  { 
	new name[33];
	get_user_name(id,name,32);
	format(key_credits, 63, "%s-/", name);
		}
	case 2: {
	new player_ip[33];
	get_user_ip(id,player_ip,32);
	format(key_credits, 63, "%s-/", player_ip);
	}
	case 3: {
	new steam_ID[33];
	get_user_authid(id,steam_ID,32);
	format(key_credits, 63, "%s-/", steam_ID);
	}
	}
	format(data_credits, 255, "%i#", PlayerCredits[id]);
	nvault_set(Vault, key_credits, data_credits);
	return PLUGIN_CONTINUE;
	}
//------| Loading Credits |------//
public LoadCredits(id) {
	Vault = nvault_open("DepozitCredits");
	new data_credits[256], key_credits[64];
	switch( get_pcvar_num(savepoints) )  { 
	case 1:  { 
	new name[33];
	get_user_name(id,name,32);
	format(key_credits, 63, "%s-/", name);
	}
	case 2: {
	new player_ip[33];
	get_user_ip(id,player_ip,32);
	format(key_credits, 63, "%s-/", player_ip);
	}
	case 3: {
	new steam_ID[33];
	get_user_authid(id,steam_ID,32);
	format(key_credits, 63, "%s-/", steam_ID);
	}
	}
	format(data_credits, 255, "%i#", PlayerCredits[id]);
	nvault_get(Vault, key_credits, data_credits, 255);
	replace_all(data_credits, 255, "#", " ");

	new Credits[32];
	parse(data_credits, Credits, 31);
	PlayerCredits[id] = str_to_num(Credits);
	return PLUGIN_CONTINUE;
	} 
	
stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
 
	replace_all(msg, 190, "!x04", "^4");
	replace_all(msg, 190, "!x01", "^1");
	replace_all(msg, 190, "!x03", "^3");
 
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
	for(new i = 0; i < count; i++) {
	if(is_user_connected(players)) {
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
	write_byte(players);
	write_string(msg);
	message_end();
	}
	}
	} 
	}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/


Intrebarea mea este cum setez sa de-a automat credite unui jucator care se conecteaza pe server..?
Il poate modifica cineva ? sau e vreun cvar cv?
Image

Image
Rapidserver
User avatar
Adventx
Membru, skill +4
Membru, skill +4
Posts: 1785
Joined: 17 Sep 2013, 20:44
Detinator Steam: Da
Reputatie: Fost moderator ajutator
Has thanked: 125 times
Been thanked: 142 times
Contact:

27 Nov 2013, 13:18

| Afiseaza codul
public client_putinserver(id) {
	LoadCredits(id)
	retrase[id] = 0
	set_task(180.0, "give_credits", id, _, _, "b")
	set_task(1.0, "MesajHUD", id+TASK_MESAJHUD, _, _, "b")
}
Inlocuesti cu :
| Afiseaza codul
public client_putinserver(id) {
	LoadCredits(id)
	retrase[id] = 0
        PlayerCredits[id] += 100
	set_task(180.0, "give_credits", id, _, _, "b")
	set_task(1.0, "MesajHUD", id+TASK_MESAJHUD, _, _, "b")
}
PlayerCredits[id] += 100 - Aici setez cite credite sa primeasca la conectare!
CaPy.lNt
Membru, skill +1
Membru, skill +1
Posts: 146
Joined: 23 Mar 2013, 21:11
Detinator Steam: Nu
CS Status: studiez
Detinator server CS: DR.ECILA.RO
Reputatie: Restrictie PM
Has thanked: 34 times
Been thanked: 13 times
Contact:

27 Nov 2013, 21:12

Eu nu gasesc aceasta linie in pluginu meu :| modificami tu te rog..
Image

Image
User avatar
Adventx
Membru, skill +4
Membru, skill +4
Posts: 1785
Joined: 17 Sep 2013, 20:44
Detinator Steam: Da
Reputatie: Fost moderator ajutator
Has thanked: 125 times
Been thanked: 142 times
Contact:

27 Nov 2013, 22:13

| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <dhudmessage>
#include <fakemeta>
#include <nvault>

#define PLUGIN  "Depozit Mooney"
#define AUTHOR  "Aragon*"
#define VERSION "1.0"

enum (+= 100)
{
	TASK_MESAJHUD
}

#define ID_HUD (taskid - TASK_MESAJHUD)

new PlayerCredits[10000], retrase[33];
new Vault, SymbolsName, savepoints;

public plugin_init() {         
	register_plugin(PLUGIN,VERSION,AUTHOR)
	register_forward(FM_ClientUserInfoChanged, "ChangeName");
	SymbolsName = register_cvar("fr_name_symbols", ""); 	//| Symbols Name Restricted |//	biohazardshopmod = register_cvar("bh_shop_mode", "1");		//| Money/Points 0 Money Tax -> 1 Points Tax |//
	savepoints = register_cvar("fr_save_points", "1");	//| Save Points Mode 0 Disable -> 1 Name -> 2 IP -> 3 SteamID |//
	register_clcmd("depozit","Depozit")
	register_logevent("round_start", 2, "1=Round_Start")
	register_clcmd("say /depozit","Depozit")
	register_clcmd("say_team /depozit","Depozit")
	register_clcmd("retrage","Retrage")
	register_clcmd("say /retrage","Retrage")
	register_clcmd("say_team /retrage","Retrage")
	register_clcmd("credite","Show_Credits")
	register_clcmd("credite","Show_Credits")
	register_clcmd("say /credite","Show_Credits")
	register_clcmd("say /credite","Show_Credits")
	register_clcmd("say_team /credite","Show_Credits")
	register_clcmd("say_team /credite","Show_Credits")
	register_concmd("amx_give_credits", "Give_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All -> Amount");
	register_concmd("amx_reset_credits", "Reset_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All");
	}
public plugin_natives() {
	register_native("get_user_credits", "get_user_credits", 1);
	register_native("set_user_credits", "set_user_credits", 1);
}
public set_user_credits(id, credits) {
	PlayerCredits[id] = credits;
	SaveCredits(id)
	}
public get_user_credits(id) {
	return PlayerCredits[id]
	}
public client_putinserver(id) {
	LoadCredits(id)
	retrase[id] = 0
	PlayerCredits[id] += 100
	set_task(180.0, "give_credits", id, _, _, "b")
	set_task(1.0, "MesajHUD", id+TASK_MESAJHUD, _, _, "b")
	}
public client_authorized(id) {
	LoadCredits(id)
	}
public client_connected(id) {
	LoadCredits(id)
	}
public client_disconnect(id) {
	SaveCredits(id)
	remove_task(id)
	retrase[id] = 0
	remove_task(id+TASK_MESAJHUD)
	}
	
public give_credits(id)
{
	ColorChat(id, "^x03[FURIEN]^x04 Ai primit^x03 15 credite^x04 pentru ca ai jucat 5 minute.");
	ColorChat(id, "^x03[FURIEN]^x04 Joaca cat mai mult si acumulezi credite in prostie.");
	PlayerCredits[id] += 15
}

public bomb_planted(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 10
	ColorChat(0, "^x03[FURIEN]^x04 Pentru plantarea bombei,^x03 %s^x04 a primit 10 credite.", nume);
}

public bomb_explode(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 20
	ColorChat(0, "^x03[FURIEN]^x04 Pentru explodarea bombei,^x03 %s^x04 a primit 20 credite.", nume);
}

public bomb_defused(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 30
	ColorChat(0, "^x03[FURIEN]^x04 Pentru dezamorsarea bombei,^x03 %s^x04 a primit 30 credite.", nume);
}

public round_start()
{
	static id;
	for (id = 1; id <= get_maxplayers(); id++)
	{
		if(is_user_alive(id))
		{
			retrase[id] = 0
		}
	}
}

public MesajHUD(taskid)
{
	static id
	id = ID_HUD;
	
	if(!is_user_alive(id))
	{
		id = pev(id, pev_iuser2)
		
		if(!is_user_alive(id))
			return;
	}
	
	if(id != ID_HUD)
	{
		new nume[32];
		get_user_name(id, nume, 31)
		set_dhudmessage(255, 255, 0, 0.0, 0.52, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_HUD, "", nume, pev(id, pev_health), PlayerCredits[id])
	}
	else
	{
		set_dhudmessage(255, 255, 0, 0.0, 0.885, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_HUD, "", pev(ID_HUD, pev_health), PlayerCredits[id])
	}
}
	
//------| Change Name |------//
public ChangeName(id, buffer) {
	if(!is_user_connected(id))
	return FMRES_IGNORED;

	static Name[32], Val[32];
	get_user_name(id, Name, sizeof Name - 1);
	engfunc(EngFunc_InfoKeyValue, buffer, "name", Val, sizeof Val - 1);
	
	if(equal(Val, Name))
	return FMRES_IGNORED;
	
	set_task(0.2, "client_connect", id);
	return FMRES_SUPERCEDE;
	}
	
//------| Client connect |------//	
public client_connect(id) {
	static sName[32];
	get_user_name(id, sName, sizeof sName - 1);
	static sChars[32];
	get_pcvar_string(SymbolsName, sChars, sizeof sChars - 1);	
	for(new i = 0 ; i < strlen(sName) ; i++) {
	for(new j = 0 ; j < strlen(sChars) ; j++) {
	if(sName == sChars[j]) {
	server_cmd("kick #%d ^"Numele tau contine caractere nepermise.^"", get_user_userid(id));
	break;
	}
	else {
	LoadCredits(id);
	}
	}
	}
	}
	
public Depozit(id) {
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR) return PLUGIN_HANDLED;
	
	if(cs_get_user_money(id) == 16000) {
	ColorChat(id, "^x03[FURIEN]^x04 Ai depus^x03 $ 16000^x04 si ai primit^x03 un credit^x04.");
	PlayerCredits[id] += 1;
	cs_set_user_money(id, 0);
	}
	else {
	ColorChat(id, "^x03[FURIEN]^x04 Nu ai^x03 $ 16000^x04.");	
	}
	SaveCredits(id)
	return PLUGIN_HANDLED;
	}
	
public Retrage(id) 
{
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
		return PLUGIN_HANDLED;

	if(cs_get_user_money(id) == 16000) 
	{
		ColorChat(id, "^x03[FURIEN]^x04 Ai deja^x03 $ 16000^x04.");
	}
	else if(PlayerCredits[id]) 
	{
		if(retrase[id] < 3)
		{
			ColorChat(id, "^x03[FURIEN]^x04 Ai retras^x03 un credit^x04 si ai primit^x03 $ 16000^x04.");
			PlayerCredits[id] -= 1;
			cs_set_user_money(id, 16000);
			retrase[id]++
		}
		else
		{
			ColorChat(id, "^x03[FURIEN]^x04 Ai retras runda asta deja^x03 3 credite^x04. Incearca runda viitoare.");
		}
	}
	else 
	{
		ColorChat(id, "^x03[FURIEN]^x04 Ai nevoie de^x03 un credit^x04 pentru a retrage.");	
	}
	SaveCredits(id)
	return PLUGIN_HANDLED;
}
	
public Show_Credits(id) {
	set_hudmessage(0, 128, 0, 0.03, 0.86, 2, 6.0, 5.0);
	show_hudmessage(id, "Ai %d credite.", PlayerCredits[id]);
	ColorChat(id, "^x03[FURIEN]^x04 Ai^x03 %d^x04 credite.", PlayerCredits[id]);
	return PLUGIN_HANDLED;
	}
	
public Give_Credits(id, level, cid) {
	if(!cmd_access(id, level, cid, 2)) {
	return PLUGIN_HANDLED;
	}
	new arg[23], gplayers[32], num, i, players, name[32];
	get_user_name(id, name, 31);
	read_argv(1, arg, 23);
	new give_credits[5];
	read_argv(2, give_credits, charsmax(give_credits));
	new Credits = str_to_num(give_credits);
	if(equali(arg, "@T")) {
	get_players(gplayers, num, "e", "TERRORIST");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Furienilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Furienilor.", name, Credits);
	}
	}
	else if(equali(arg, "@CT")) {
	get_players(gplayers, num, "e", "CT");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Anti-Furienilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Anti-Furienilor.", name, Credits);
	}
	}
	if(equali(arg, "@All")) {
	get_players(gplayers, num, "a");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 jucatorilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 a dat^x03 %i credite ^x03 jucatorilor.", name, Credits);
	}
	}
	new player = cmd_target(id, arg, 11);
	if(!player) {
	return PLUGIN_HANDLED;
	}
	PlayerCredits[player] += Credits;
	SaveCredits(id)
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(player, "^x03Adminul^x04 ti-a dat^x03 %i credite.", Credits);
	case 2: ColorChat(player, "^x03%s^x04 ti-a dat^x03 %i credite.", name, Credits);
	}
	return PLUGIN_HANDLED;
	}
	
public Reset_Credits(id, level, cid) {
	if(!cmd_access(id, level, cid, 2)) {
	return PLUGIN_HANDLED;
	}
	new arg[23], gplayers[32], num, i, players, name[32];
	get_user_name(id, name, 31);
	read_argv(1, arg, 23);
	if(equali(arg, "@T")) {
	get_players(gplayers, num, "e", "TERRORIST");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 Furienilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luat^x03 creditele^x04 tuturor^x03 Furienilor.", name);
	}
	}
	
	else if(equali(arg, "@CT")) {
	get_players(gplayers, num, "e", "CT");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 Anti-Furienilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luat^x03 creditele^x04 tuturor^x03 Anti-Furienilor.", name);
	}
	}
	if(equali(arg, "@All")) {
	get_players(gplayers, num, "a");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 jucatorilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luatx03 creditele^x04 tuturor^x03 jucatorilor.", name);
	}
	}
	new player = cmd_target(id, arg, 11);
	if(!player) {
	return PLUGIN_HANDLED;
	}
	PlayerCredits[player] = 0;
	SaveCredits(id)
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(player, "^x03Adminul^x04 ti-a luat^x03 creditele.");
	case 2: ColorChat(player, "^x03%s^x04 ti-a luat^x03 creditele.", name);
	}
	return PLUGIN_HANDLED;
	}
	
//------| Save Credits |------//
public SaveCredits(id) {
	Vault = nvault_open("DepozitCredits");
	new data_credits[256], key_credits[64];
	switch( get_pcvar_num(savepoints) ) { 
	case 1:  { 
	new name[33];
	get_user_name(id,name,32);
	format(key_credits, 63, "%s-/", name);
		}
	case 2: {
	new player_ip[33];
	get_user_ip(id,player_ip,32);
	format(key_credits, 63, "%s-/", player_ip);
	}
	case 3: {
	new steam_ID[33];
	get_user_authid(id,steam_ID,32);
	format(key_credits, 63, "%s-/", steam_ID);
	}
	}
	format(data_credits, 255, "%i#", PlayerCredits[id]);
	nvault_set(Vault, key_credits, data_credits);
	return PLUGIN_CONTINUE;
	}
//------| Loading Credits |------//
public LoadCredits(id) {
	Vault = nvault_open("DepozitCredits");
	new data_credits[256], key_credits[64];
	switch( get_pcvar_num(savepoints) )  { 
	case 1:  { 
	new name[33];
	get_user_name(id,name,32);
	format(key_credits, 63, "%s-/", name);
	}
	case 2: {
	new player_ip[33];
	get_user_ip(id,player_ip,32);
	format(key_credits, 63, "%s-/", player_ip);
	}
	case 3: {
	new steam_ID[33];
	get_user_authid(id,steam_ID,32);
	format(key_credits, 63, "%s-/", steam_ID);
	}
	}
	format(data_credits, 255, "%i#", PlayerCredits[id]);
	nvault_get(Vault, key_credits, data_credits, 255);
	replace_all(data_credits, 255, "#", " ");

	new Credits[32];
	parse(data_credits, Credits, 31);
	PlayerCredits[id] = str_to_num(Credits);
	return PLUGIN_CONTINUE;
	} 
	
stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
 
	replace_all(msg, 190, "!x04", "^4");
	replace_all(msg, 190, "!x01", "^1");
	replace_all(msg, 190, "!x03", "^3");
 
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
	for(new i = 0; i < count; i++) {
	if(is_user_connected(players)) {
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
	write_byte(players);
	write_string(msg);
	message_end();
	}
	}
	} 
	}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
CaPy.lNt
Membru, skill +1
Membru, skill +1
Posts: 146
Joined: 23 Mar 2013, 21:11
Detinator Steam: Nu
CS Status: studiez
Detinator server CS: DR.ECILA.RO
Reputatie: Restrictie PM
Has thanked: 34 times
Been thanked: 13 times
Contact:

27 Nov 2013, 22:58

Mersi bosu. :D
Image

Image
User avatar
KrAiD.
Fost moderator
Fost moderator
Posts: 866
Joined: 15 Jun 2013, 11:14
Detinator Steam: Da
CS Status: Cat de cat activ :D
Detinator server CS: Nu
Reputatie: Fost Moderator ajutator
0.7 / 3
Has thanked: 14 times
Been thanked: 131 times
Contact:

27 Nov 2013, 23:12

sau asta lu askhanar
| Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fakemeta >
#include < nvault >
//#include < CC_ColorChat >

#pragma semicolon 1


#define PLUGIN "Furien Credits System"
#define VERSION "0.4.5"

#define	ONE_DAY_IN_SECONDS	86400

// |-- CC_ColorChat --|

enum Color
{
	NORMAL = 1, 		// Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
	GREEN, 			// Culoare Verde.
	TEAM_COLOR, 		// Culoare Rosu, Albastru, Gri.
	GREY, 			// Culoarea Gri.
	RED, 			// Culoarea Rosu.
	BLUE, 			// Culoarea Albastru.
};

new TeamName[  ][  ] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

// |-- CC_ColorChat --|

new const g_szTag[ ] = "[Furien Credits]";

new const g_szGiveCreditsFlag[ ] = "a";

new g_szName[ 33 ][ 32 ];
new g_iUserCredits[ 33 ];

new g_iCvarPruneDays;
new g_iCvarEntry;
new iVault;

public plugin_init( )
{
	register_plugin( PLUGIN, VERSION, "Askhanar" );
	register_cvar( "fcs_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY ); 

	g_iCvarPruneDays = register_cvar( "fcs_prunedays", "15" );
	g_iCvarEntry = register_cvar( "fcs_entry_credits", "300" );
	
	register_clcmd( "say", "ClCmdSay" );
	register_clcmd( "say_team", "ClCmdSay" );
	
	register_clcmd( "say /depozit", "ClCmdSayDepozit" );
	register_clcmd( "say /deposit", "ClCmdSayDepozit" );
	register_clcmd( "say_team /depozit", "ClCmdSayDepozit" );
	register_clcmd( "say_team /deposit", "ClCmdSayDepozit" );
	
	register_clcmd( "say /retrage", "ClCmdSayRetrage" );
	register_clcmd( "say /withdraw", "ClCmdSayRetrage" );
	register_clcmd( "say_team /retrage", "ClCmdSayRetrage" );
	register_clcmd( "say_team /withdraw", "ClCmdSayRetrage" );
	
	register_clcmd( "fcs_credite", "ClCmdCredits" );
	register_clcmd( "fcs_credits", "ClCmdCredits" );
	
	register_clcmd( "amx_give_credits", "ClCmdGiveCredits" );
	register_clcmd( "amx_take_credits", "ClCmdTakeCredits" );
	
	register_forward( FM_ClientUserInfoChanged, "Fwd_ClientUserInfoChanged" );
	
	iVault  =  nvault_open(  "FurienCreditsSystem"  );
	
	if(  iVault  ==  INVALID_HANDLE  )
	{
		set_fail_state(  "nValut returned invalid handle!"  );
	}

}

public plugin_natives()
{
	
	register_library( "fcs" );
	register_native( "fcs_get_user_credits", "_fcs_get_user_credits" );
	register_native( "fcs_set_user_credits", "_fcs_set_user_credits" );
	
}

public _fcs_get_user_credits( iPlugin, iParams )
{
	return g_iUserCredits[  get_param( 1 )  ];
}

public _fcs_set_user_credits(  iPlugin, iParams  )
{
	new id = get_param( 1 );
	g_iUserCredits[ id ] = max( 0, get_param( 2 ) );
	SaveCredits( id );
	return g_iUserCredits[ id ];
}

public client_authorized( id )
{
	if( is_user_bot( id ) )
		return 0;
	
	get_user_name( id, g_szName[ id ], sizeof ( g_szName[] ) -1 );
	LoadCredits( id );
	
	return 0;
	
}

public client_disconnect( id )
{
	if( is_user_bot( id ) )
		return 0;
		
	SaveCredits( id );
	
	return 0;
	
}

public ClCmdSay( id )
{
	static szArgs[192];
	read_args( szArgs, sizeof ( szArgs ) -1 );
	
	if( !szArgs[ 0 ] )
		return 0;
	
	new szCommand[ 15 ];
	remove_quotes( szArgs );
	
	if( equal( szArgs, "/credite", strlen( "/credite" ) )
		|| equal( szArgs, "/credits", strlen( "/credits" ) ) )
	{
		replace( szArgs, sizeof ( szArgs ) -1, "/", "" );
		formatex( szCommand, sizeof ( szCommand ) -1, "fcs_%s", szArgs );
		client_cmd( id, szCommand );
		return 1;
	}
	
	return 0;
}

public ClCmdCredits( id )
{
	if( !is_user_connected( id ) )
		return 1;
		
	new szArg[ 32 ];
    	read_argv( 1, szArg, sizeof ( szArg ) -1 );

	if( equal( szArg, "" ) ) 
	{
		
		ColorChat( id, RED, "^x04%s^x01 Ai^x03 %i^x01 credite.", g_szTag, g_iUserCredits[ id ] );
		return 1;
	}
	
    	new iPlayer = cmd_target( id, szArg, 8 );
    	if( !iPlayer || !is_user_connected( iPlayer ) )
	{
		ColorChat( id, RED,"^x04%s^x01 Jucatorul specificat nu a fost gasit!", g_szTag, szArg );
		return 1;
	}

	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof ( szName ) -1 );
	ColorChat( id, RED,"^x04%s^x01 Jucatorul^x03 %s^x01 are^x03 %i^x01 credit%s", g_szTag, szName, g_iUserCredits[ iPlayer ], g_iUserCredits[ iPlayer ] == 1 ? "." : "e." );
	
	return 1;
	
}

public ClCmdSayDepozit( id)
{
	
	if( !is_user_connected( id ) )
		return 1;
		
	new iTeam = get_user_team( id );
	
	if( 1 <= iTeam <= 2 )
	{
		new iMoney = cs_get_user_money( id );
		if( iMoney >= 16000 )
		{
			
			ColorChat( id, RED, "^x04%s^x01 Ai depozitat^x03 16000$^x01 si ai primit^x03 1^x01 credit.", g_szTag );
			cs_set_user_money( id, 0 );
			g_iUserCredits[ id ] += 1;
			
			SaveCredits( id );
			return 1;
		}
		else
		{
			ColorChat( id, RED, "^x04%s^x01 Iti trebuie^x03 16000$^x01 pentru a putea depozita.", g_szTag );
			return 1;
		}
	}
	
	return 1;

}

public ClCmdSayRetrage( id)
{
	
	new iTeam = get_user_team( id );
	
	if( 1 <= iTeam <= 2 )
	{
		
		if( g_iUserCredits[ id ] > 0 )
		{
			new iMoney = cs_get_user_money( id );
			
			ColorChat( id, RED, "^x04%s^x01 Ai retras^x03 1^x01 credit si, ai primi^x03 16000$^x01.", g_szTag );
			cs_set_user_money( id, iMoney + 16000 );
			
			g_iUserCredits[ id ] -=1;
			SaveCredits( id );
			
			if( ( iMoney + 16000 ) > 16000 )
			{
				ColorChat( id, RED, "^x04%s^x03 ATENTIE^x01, ai^x03 %i$^x01 !", g_szTag, iMoney + 16000 );
				ColorChat( id, RED, "^x04%s^x01 La spawn, vei pierde tot ce depaseste suma de^x03 16000$^x01.", g_szTag );
				return 1;
			}
		}
		else
		{
			ColorChat(id, RED, "^x04%s^x03 NU^x01 ai ce sa retragi, ai^x03 0^x01 credite.", g_szTag );
			return 1;
		}
		
	}
	
	return 1;

}

public ClCmdGiveCredits( id )
{
	
	if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )
	{
		client_cmd( id, "echo NU ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) )
	{
		client_cmd( id, "echo amx_give_credits < nume/ @ALL/ @T/ @CT > < credite >" );
		return 1;
	}
	
	new iPlayers[ 32 ];
	new iPlayersNum;
	
	new iCredits = str_to_num( szSecondArg );
	if( iCredits <= 0 )
	{
		client_cmd( id, "echo Valoare creditelor trebuie sa fie mai mare decat 0!" );
		return 1;
	}
	
	if( szFirstArg[ 0 ] == '@' )
	{
		
		switch ( szFirstArg[ 1 ] )
		{
			case 'A':
			{
				if( equal( szFirstArg, "@ALL" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ch" );
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite tuturor jucatorilor!", g_szTag, szName, iCredits );
					return 1;
				}
			}
			
			case 'T':
			{
				if( equal( szFirstArg, "@T" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ceh", "TERRORIST" );
					if( iPlayersNum == 0 )
					{
						client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );
						return 1;
					}
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 TERO^x01!", g_szTag, szName, iCredits );
					return 1;
				}
			}
			
			case 'C':
			{
				if( equal( szFirstArg, "@CT" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ceh", "CT" );
					if( iPlayersNum == 0 )
					{
						client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );
						return 1;
					}
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 CT^x01!", g_szTag, szName, iCredits );
					return 1;
				}
			}
		}
	}
		
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer )
	{
		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	g_iUserCredits[ iPlayer ] += iCredits;
	
	new szName[ 32 ], _szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	get_user_name( id, _szName, sizeof ( _szName ) -1 );
	
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a dat^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );
	
	return 1;
	
	
}

public ClCmdTakeCredits( id )
{
	
	if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )
	{
		client_cmd( id, "echo NU ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) )
	{
		client_cmd( id, "echo amx_take_credits < nume > < credite >" );
		return 1;
	}
	
	new iCredits = str_to_num( szSecondArg );
	if( iCredits <= 0 )
	{
		client_cmd( id, "echo Valoare creditelor trebuie sa fie mai mare decat 0!" );
		return 1;
	}
			
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer )
	{
		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	if( g_iUserCredits[ iPlayer ] < iCredits )
	{
		client_cmd( id, "echo Jucatorul %s nu are atatea credite!Are doar %i", szFirstArg, g_iUserCredits[ iPlayer ] );
		return 1;
	}
	
	g_iUserCredits[ iPlayer ] -= iCredits;
	
	new szName[ 32 ], _szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	get_user_name( id, _szName, sizeof ( _szName ) -1 );
	
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a sters^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );
	
	return 1;
	
	
}

public Fwd_ClientUserInfoChanged( id, szBuffer )
{
	if ( !is_user_connected( id ) ) 
		return FMRES_IGNORED;
	
	static szNewName[ 32 ];
	
	engfunc( EngFunc_InfoKeyValue, szBuffer, "name", szNewName, sizeof ( szNewName ) -1 );
	
	if ( equal( szNewName, g_szName[ id ] ) )
		return FMRES_IGNORED;
	
	SaveCredits(  id  );
	
	ColorChat( id, RED, "^x04%s^x01 Tocmai ti-ai schimbat numele din^x03 %s^x01 in^x03 %s^x01 !", g_szTag, g_szName[ id ], szNewName );
	ColorChat( id, RED, "^x04%s^x01 Am salvat^x03 %i^x01 credite pe numele^x03 %s^x01 !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );
	
	copy( g_szName[ id ], sizeof ( g_szName[] ) -1, szNewName );
	LoadCredits( id );
	
	ColorChat( id, RED, "^x04%s^x01 Am incarcat^x03 %i^x01 credite de pe noul nume (^x03 %s^x01 ) !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );
	
	return FMRES_IGNORED;
}


public LoadCredits( id )
{
	static szData[ 256 ],  iTimestamp;
	
	if(  nvault_lookup( iVault, g_szName[ id ], szData, sizeof ( szData ) -1, iTimestamp ) )
	{
		static szCredits[ 15 ];
		parse( szData, szCredits, sizeof ( szCredits ) -1 );
		g_iUserCredits[ id ] = str_to_num( szCredits );
		return;
	}
	else
	{
		g_iUserCredits[ id ] = get_pcvar_num( g_iCvarEntry );
	}
	
}


public SaveCredits(  id  )
{
	
	static szData[ 256 ];
	formatex( szData, sizeof ( szData ) -1, "%i", g_iUserCredits[ id ] );
	
	nvault_set( iVault, g_szName[ id ], szData );
}

public plugin_end( )
{
	new iDays = get_pcvar_num( g_iCvarPruneDays );
	if( iDays > 0 )
	{
		nvault_prune( iVault, 0, get_systime( ) - ( iDays * ONE_DAY_IN_SECONDS ) );
	}
	
	nvault_close( iVault );
}

// |-- CC_ColorChat --|

ColorChat(  id, Color:iType, const msg[  ], { Float, Sql, Result, _}:...  )
{
	
	// Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
	if( !get_playersnum( ) ) return;
	
	new szMessage[ 256 ];

	switch( iType )
	{
		 // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
		case NORMAL:	szMessage[ 0 ] = 0x01;
		
		// Culoare Verde.
		case GREEN:	szMessage[ 0 ] = 0x04;
		
		// Alb, Rosu, Albastru.
		default: 	szMessage[ 0 ] = 0x03;
	}

	vformat(  szMessage[ 1 ], 251, msg, 4  );

	// Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
	szMessage[ 192 ] = '^0';
	

	new iTeam, iColorChange, iPlayerIndex, MSG_Type;
	
	if( id )
	{
		MSG_Type  =  MSG_ONE_UNRELIABLE;
		iPlayerIndex  =  id;
	}
	else
	{
		iPlayerIndex  =  CC_FindPlayer(  );
		MSG_Type = MSG_ALL;
	}
	
	iTeam  =  get_user_team( iPlayerIndex );
	iColorChange  =  CC_ColorSelection(  iPlayerIndex,  MSG_Type, iType);

	CC_ShowColorMessage(  iPlayerIndex, MSG_Type, szMessage  );
		
	if(  iColorChange  )	CC_Team_Info(  iPlayerIndex, MSG_Type,  TeamName[ iTeam ]  );

}

CC_ShowColorMessage(  id, const iType, const szMessage[  ]  )
{
	
	static bool:bSayTextUsed;
	static iMsgSayText;
	
	if(  !bSayTextUsed  )
	{
		iMsgSayText  =  get_user_msgid( "SayText" );
		bSayTextUsed  =  true;
	}
	
	message_begin( iType, iMsgSayText, _, id  );
	write_byte(  id  );		
	write_string(  szMessage  );
	message_end(  );
}

CC_Team_Info( id, const iType, const szTeam[  ] )
{
	static bool:bTeamInfoUsed;
	static iMsgTeamInfo;
	if(  !bTeamInfoUsed  )
	{
		iMsgTeamInfo  =  get_user_msgid( "TeamInfo" );
		bTeamInfoUsed  =  true;
	}
	
	message_begin( iType, iMsgTeamInfo, _, id  );
	write_byte(  id  );
	write_string(  szTeam  );
	message_end(  );

	return 1;
}

CC_ColorSelection(  id, const iType, Color:iColorType)
{
	switch(  iColorType  )
	{
		
		case RED:	return CC_Team_Info(  id, iType, TeamName[ 1 ]  );
		case BLUE:	return CC_Team_Info(  id, iType, TeamName[ 2 ]  );
		case GREY:	return CC_Team_Info(  id, iType, TeamName[ 0 ]  );

	}

	return 0;
}

CC_FindPlayer(  )
{
	new iMaxPlayers  =  get_maxplayers(  );
	
	for( new i = 1; i <= iMaxPlayers; i++ )
		if(  is_user_connected( i )  )
			return i;
	
	return -1;
}

// |-- CC_ColorChat --|
cvar - fcs_entry_credits 300 sau cate vrei
CaPy.lNt
Membru, skill +1
Membru, skill +1
Posts: 146
Joined: 23 Mar 2013, 21:11
Detinator Steam: Nu
CS Status: studiez
Detinator server CS: DR.ECILA.RO
Reputatie: Restrictie PM
Has thanked: 34 times
Been thanked: 13 times
Contact:

28 Nov 2013, 00:02

KrAiD. wrote:sau asta lu askhanar
| Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >
#include < fakemeta >
#include < nvault >
//#include < CC_ColorChat >

#pragma semicolon 1


#define PLUGIN "Furien Credits System"
#define VERSION "0.4.5"

#define	ONE_DAY_IN_SECONDS	86400

// |-- CC_ColorChat --|

enum Color
{
	NORMAL = 1, 		// Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
	GREEN, 			// Culoare Verde.
	TEAM_COLOR, 		// Culoare Rosu, Albastru, Gri.
	GREY, 			// Culoarea Gri.
	RED, 			// Culoarea Rosu.
	BLUE, 			// Culoarea Albastru.
};

new TeamName[  ][  ] = 
{
	"",
	"TERRORIST",
	"CT",
	"SPECTATOR"
};

// |-- CC_ColorChat --|

new const g_szTag[ ] = "[Furien Credits]";

new const g_szGiveCreditsFlag[ ] = "a";

new g_szName[ 33 ][ 32 ];
new g_iUserCredits[ 33 ];

new g_iCvarPruneDays;
new g_iCvarEntry;
new iVault;

public plugin_init( )
{
	register_plugin( PLUGIN, VERSION, "Askhanar" );
	register_cvar( "fcs_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY ); 

	g_iCvarPruneDays = register_cvar( "fcs_prunedays", "15" );
	g_iCvarEntry = register_cvar( "fcs_entry_credits", "300" );
	
	register_clcmd( "say", "ClCmdSay" );
	register_clcmd( "say_team", "ClCmdSay" );
	
	register_clcmd( "say /depozit", "ClCmdSayDepozit" );
	register_clcmd( "say /deposit", "ClCmdSayDepozit" );
	register_clcmd( "say_team /depozit", "ClCmdSayDepozit" );
	register_clcmd( "say_team /deposit", "ClCmdSayDepozit" );
	
	register_clcmd( "say /retrage", "ClCmdSayRetrage" );
	register_clcmd( "say /withdraw", "ClCmdSayRetrage" );
	register_clcmd( "say_team /retrage", "ClCmdSayRetrage" );
	register_clcmd( "say_team /withdraw", "ClCmdSayRetrage" );
	
	register_clcmd( "fcs_credite", "ClCmdCredits" );
	register_clcmd( "fcs_credits", "ClCmdCredits" );
	
	register_clcmd( "amx_give_credits", "ClCmdGiveCredits" );
	register_clcmd( "amx_take_credits", "ClCmdTakeCredits" );
	
	register_forward( FM_ClientUserInfoChanged, "Fwd_ClientUserInfoChanged" );
	
	iVault  =  nvault_open(  "FurienCreditsSystem"  );
	
	if(  iVault  ==  INVALID_HANDLE  )
	{
		set_fail_state(  "nValut returned invalid handle!"  );
	}

}

public plugin_natives()
{
	
	register_library( "fcs" );
	register_native( "fcs_get_user_credits", "_fcs_get_user_credits" );
	register_native( "fcs_set_user_credits", "_fcs_set_user_credits" );
	
}

public _fcs_get_user_credits( iPlugin, iParams )
{
	return g_iUserCredits[  get_param( 1 )  ];
}

public _fcs_set_user_credits(  iPlugin, iParams  )
{
	new id = get_param( 1 );
	g_iUserCredits[ id ] = max( 0, get_param( 2 ) );
	SaveCredits( id );
	return g_iUserCredits[ id ];
}

public client_authorized( id )
{
	if( is_user_bot( id ) )
		return 0;
	
	get_user_name( id, g_szName[ id ], sizeof ( g_szName[] ) -1 );
	LoadCredits( id );
	
	return 0;
	
}

public client_disconnect( id )
{
	if( is_user_bot( id ) )
		return 0;
		
	SaveCredits( id );
	
	return 0;
	
}

public ClCmdSay( id )
{
	static szArgs[192];
	read_args( szArgs, sizeof ( szArgs ) -1 );
	
	if( !szArgs[ 0 ] )
		return 0;
	
	new szCommand[ 15 ];
	remove_quotes( szArgs );
	
	if( equal( szArgs, "/credite", strlen( "/credite" ) )
		|| equal( szArgs, "/credits", strlen( "/credits" ) ) )
	{
		replace( szArgs, sizeof ( szArgs ) -1, "/", "" );
		formatex( szCommand, sizeof ( szCommand ) -1, "fcs_%s", szArgs );
		client_cmd( id, szCommand );
		return 1;
	}
	
	return 0;
}

public ClCmdCredits( id )
{
	if( !is_user_connected( id ) )
		return 1;
		
	new szArg[ 32 ];
    	read_argv( 1, szArg, sizeof ( szArg ) -1 );

	if( equal( szArg, "" ) ) 
	{
		
		ColorChat( id, RED, "^x04%s^x01 Ai^x03 %i^x01 credite.", g_szTag, g_iUserCredits[ id ] );
		return 1;
	}
	
    	new iPlayer = cmd_target( id, szArg, 8 );
    	if( !iPlayer || !is_user_connected( iPlayer ) )
	{
		ColorChat( id, RED,"^x04%s^x01 Jucatorul specificat nu a fost gasit!", g_szTag, szArg );
		return 1;
	}

	new szName[ 32 ];
	get_user_name( iPlayer, szName, sizeof ( szName ) -1 );
	ColorChat( id, RED,"^x04%s^x01 Jucatorul^x03 %s^x01 are^x03 %i^x01 credit%s", g_szTag, szName, g_iUserCredits[ iPlayer ], g_iUserCredits[ iPlayer ] == 1 ? "." : "e." );
	
	return 1;
	
}

public ClCmdSayDepozit( id)
{
	
	if( !is_user_connected( id ) )
		return 1;
		
	new iTeam = get_user_team( id );
	
	if( 1 <= iTeam <= 2 )
	{
		new iMoney = cs_get_user_money( id );
		if( iMoney >= 16000 )
		{
			
			ColorChat( id, RED, "^x04%s^x01 Ai depozitat^x03 16000$^x01 si ai primit^x03 1^x01 credit.", g_szTag );
			cs_set_user_money( id, 0 );
			g_iUserCredits[ id ] += 1;
			
			SaveCredits( id );
			return 1;
		}
		else
		{
			ColorChat( id, RED, "^x04%s^x01 Iti trebuie^x03 16000$^x01 pentru a putea depozita.", g_szTag );
			return 1;
		}
	}
	
	return 1;

}

public ClCmdSayRetrage( id)
{
	
	new iTeam = get_user_team( id );
	
	if( 1 <= iTeam <= 2 )
	{
		
		if( g_iUserCredits[ id ] > 0 )
		{
			new iMoney = cs_get_user_money( id );
			
			ColorChat( id, RED, "^x04%s^x01 Ai retras^x03 1^x01 credit si, ai primi^x03 16000$^x01.", g_szTag );
			cs_set_user_money( id, iMoney + 16000 );
			
			g_iUserCredits[ id ] -=1;
			SaveCredits( id );
			
			if( ( iMoney + 16000 ) > 16000 )
			{
				ColorChat( id, RED, "^x04%s^x03 ATENTIE^x01, ai^x03 %i$^x01 !", g_szTag, iMoney + 16000 );
				ColorChat( id, RED, "^x04%s^x01 La spawn, vei pierde tot ce depaseste suma de^x03 16000$^x01.", g_szTag );
				return 1;
			}
		}
		else
		{
			ColorChat(id, RED, "^x04%s^x03 NU^x01 ai ce sa retragi, ai^x03 0^x01 credite.", g_szTag );
			return 1;
		}
		
	}
	
	return 1;

}

public ClCmdGiveCredits( id )
{
	
	if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )
	{
		client_cmd( id, "echo NU ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) )
	{
		client_cmd( id, "echo amx_give_credits < nume/ @ALL/ @T/ @CT > < credite >" );
		return 1;
	}
	
	new iPlayers[ 32 ];
	new iPlayersNum;
	
	new iCredits = str_to_num( szSecondArg );
	if( iCredits <= 0 )
	{
		client_cmd( id, "echo Valoare creditelor trebuie sa fie mai mare decat 0!" );
		return 1;
	}
	
	if( szFirstArg[ 0 ] == '@' )
	{
		
		switch ( szFirstArg[ 1 ] )
		{
			case 'A':
			{
				if( equal( szFirstArg, "@ALL" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ch" );
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite tuturor jucatorilor!", g_szTag, szName, iCredits );
					return 1;
				}
			}
			
			case 'T':
			{
				if( equal( szFirstArg, "@T" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ceh", "TERRORIST" );
					if( iPlayersNum == 0 )
					{
						client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );
						return 1;
					}
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 TERO^x01!", g_szTag, szName, iCredits );
					return 1;
				}
			}
			
			case 'C':
			{
				if( equal( szFirstArg, "@CT" ) )
				{
					
					get_players( iPlayers, iPlayersNum, "ceh", "CT" );
					if( iPlayersNum == 0 )
					{
						client_cmd( id, "echo NU se afla niciun jucator in aceasta echipa!" );
						return 1;
					}
					for( new i = 0; i < iPlayersNum ; i++ )
						g_iUserCredits[ iPlayers[ i ] ] += iCredits;
						
					new szName[ 32 ];
					get_user_name( id, szName, sizeof ( szName ) -1 );
					ColorChat( 0, RED, "^x04^%s^x01 Adminul^x03 %s^x01 le-a dat^x03 %i^x01 credite jucatorilor de la^x03 CT^x01!", g_szTag, szName, iCredits );
					return 1;
				}
			}
		}
	}
		
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer )
	{
		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	g_iUserCredits[ iPlayer ] += iCredits;
	
	new szName[ 32 ], _szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	get_user_name( id, _szName, sizeof ( _szName ) -1 );
	
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a dat^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );
	
	return 1;
	
	
}

public ClCmdTakeCredits( id )
{
	
	if( !( get_user_flags( id ) & read_flags( g_szGiveCreditsFlag ) ) )
	{
		client_cmd( id, "echo NU ai acces la aceasta comanda!" );
		return 1;
	}
	
	new szFirstArg[ 32 ], szSecondArg[ 10 ];
	
	read_argv( 1, szFirstArg, sizeof ( szFirstArg ) -1 );
	read_argv( 2, szSecondArg, sizeof ( szSecondArg ) -1 );
	
	if( equal( szFirstArg, "" ) || equal( szSecondArg, "" ) )
	{
		client_cmd( id, "echo amx_take_credits < nume > < credite >" );
		return 1;
	}
	
	new iCredits = str_to_num( szSecondArg );
	if( iCredits <= 0 )
	{
		client_cmd( id, "echo Valoare creditelor trebuie sa fie mai mare decat 0!" );
		return 1;
	}
			
	new iPlayer = cmd_target( id, szFirstArg, 8 );
	if( !iPlayer )
	{
		client_cmd( id, "echo Jucatorul %s nu a fost gasit!", szFirstArg );
		return 1;
	}
	
	if( g_iUserCredits[ iPlayer ] < iCredits )
	{
		client_cmd( id, "echo Jucatorul %s nu are atatea credite!Are doar %i", szFirstArg, g_iUserCredits[ iPlayer ] );
		return 1;
	}
	
	g_iUserCredits[ iPlayer ] -= iCredits;
	
	new szName[ 32 ], _szName[ 32 ];
	get_user_name( id, szName, sizeof ( szName ) -1 );
	get_user_name( id, _szName, sizeof ( _szName ) -1 );
	
	ColorChat( 0, RED, "^x04%s^x01 Adminul^x03 %s^x01 i-a sters^x03 %i^x01 credite lui^x03 %s^x01.", g_szTag, szName, iCredits, _szName );
	
	return 1;
	
	
}

public Fwd_ClientUserInfoChanged( id, szBuffer )
{
	if ( !is_user_connected( id ) ) 
		return FMRES_IGNORED;
	
	static szNewName[ 32 ];
	
	engfunc( EngFunc_InfoKeyValue, szBuffer, "name", szNewName, sizeof ( szNewName ) -1 );
	
	if ( equal( szNewName, g_szName[ id ] ) )
		return FMRES_IGNORED;
	
	SaveCredits(  id  );
	
	ColorChat( id, RED, "^x04%s^x01 Tocmai ti-ai schimbat numele din^x03 %s^x01 in^x03 %s^x01 !", g_szTag, g_szName[ id ], szNewName );
	ColorChat( id, RED, "^x04%s^x01 Am salvat^x03 %i^x01 credite pe numele^x03 %s^x01 !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );
	
	copy( g_szName[ id ], sizeof ( g_szName[] ) -1, szNewName );
	LoadCredits( id );
	
	ColorChat( id, RED, "^x04%s^x01 Am incarcat^x03 %i^x01 credite de pe noul nume (^x03 %s^x01 ) !", g_szTag, g_iUserCredits[ id ], g_szName[ id ] );
	
	return FMRES_IGNORED;
}


public LoadCredits( id )
{
	static szData[ 256 ],  iTimestamp;
	
	if(  nvault_lookup( iVault, g_szName[ id ], szData, sizeof ( szData ) -1, iTimestamp ) )
	{
		static szCredits[ 15 ];
		parse( szData, szCredits, sizeof ( szCredits ) -1 );
		g_iUserCredits[ id ] = str_to_num( szCredits );
		return;
	}
	else
	{
		g_iUserCredits[ id ] = get_pcvar_num( g_iCvarEntry );
	}
	
}


public SaveCredits(  id  )
{
	
	static szData[ 256 ];
	formatex( szData, sizeof ( szData ) -1, "%i", g_iUserCredits[ id ] );
	
	nvault_set( iVault, g_szName[ id ], szData );
}

public plugin_end( )
{
	new iDays = get_pcvar_num( g_iCvarPruneDays );
	if( iDays > 0 )
	{
		nvault_prune( iVault, 0, get_systime( ) - ( iDays * ONE_DAY_IN_SECONDS ) );
	}
	
	nvault_close( iVault );
}

// |-- CC_ColorChat --|

ColorChat(  id, Color:iType, const msg[  ], { Float, Sql, Result, _}:...  )
{
	
	// Daca nu se afla nici un jucator pe server oprim TOT. Altfel dam de erori..
	if( !get_playersnum( ) ) return;
	
	new szMessage[ 256 ];

	switch( iType )
	{
		 // Culoarea care o are jucatorul setata in cvar-ul scr_concolor.
		case NORMAL:	szMessage[ 0 ] = 0x01;
		
		// Culoare Verde.
		case GREEN:	szMessage[ 0 ] = 0x04;
		
		// Alb, Rosu, Albastru.
		default: 	szMessage[ 0 ] = 0x03;
	}

	vformat(  szMessage[ 1 ], 251, msg, 4  );

	// Ne asiguram ca mesajul nu este mai lung de 192 de caractere.Altfel pica server-ul.
	szMessage[ 192 ] = '^0';
	

	new iTeam, iColorChange, iPlayerIndex, MSG_Type;
	
	if( id )
	{
		MSG_Type  =  MSG_ONE_UNRELIABLE;
		iPlayerIndex  =  id;
	}
	else
	{
		iPlayerIndex  =  CC_FindPlayer(  );
		MSG_Type = MSG_ALL;
	}
	
	iTeam  =  get_user_team( iPlayerIndex );
	iColorChange  =  CC_ColorSelection(  iPlayerIndex,  MSG_Type, iType);

	CC_ShowColorMessage(  iPlayerIndex, MSG_Type, szMessage  );
		
	if(  iColorChange  )	CC_Team_Info(  iPlayerIndex, MSG_Type,  TeamName[ iTeam ]  );

}

CC_ShowColorMessage(  id, const iType, const szMessage[  ]  )
{
	
	static bool:bSayTextUsed;
	static iMsgSayText;
	
	if(  !bSayTextUsed  )
	{
		iMsgSayText  =  get_user_msgid( "SayText" );
		bSayTextUsed  =  true;
	}
	
	message_begin( iType, iMsgSayText, _, id  );
	write_byte(  id  );		
	write_string(  szMessage  );
	message_end(  );
}

CC_Team_Info( id, const iType, const szTeam[  ] )
{
	static bool:bTeamInfoUsed;
	static iMsgTeamInfo;
	if(  !bTeamInfoUsed  )
	{
		iMsgTeamInfo  =  get_user_msgid( "TeamInfo" );
		bTeamInfoUsed  =  true;
	}
	
	message_begin( iType, iMsgTeamInfo, _, id  );
	write_byte(  id  );
	write_string(  szTeam  );
	message_end(  );

	return 1;
}

CC_ColorSelection(  id, const iType, Color:iColorType)
{
	switch(  iColorType  )
	{
		
		case RED:	return CC_Team_Info(  id, iType, TeamName[ 1 ]  );
		case BLUE:	return CC_Team_Info(  id, iType, TeamName[ 2 ]  );
		case GREY:	return CC_Team_Info(  id, iType, TeamName[ 0 ]  );

	}

	return 0;
}

CC_FindPlayer(  )
{
	new iMaxPlayers  =  get_maxplayers(  );
	
	for( new i = 1; i <= iMaxPlayers; i++ )
		if(  is_user_connected( i )  )
			return i;
	
	return -1;
}

// |-- CC_ColorChat --|
cvar - fcs_entry_credits 300 sau cate vrei
Nu frate ca nu se potriveste cu meniul de arme..
ms oricum
Image

Image
CaPy.lNt
Membru, skill +1
Membru, skill +1
Posts: 146
Joined: 23 Mar 2013, 21:11
Detinator Steam: Nu
CS Status: studiez
Detinator server CS: DR.ECILA.RO
Reputatie: Restrictie PM
Has thanked: 34 times
Been thanked: 13 times
Contact:

28 Nov 2013, 11:42

Imi poate face si mie cineva sa arate in hud creditele?
jos in coltul din stanga..
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <csx>
#include <dhudmessage>
#include <fakemeta>
#include <nvault>

#define PLUGIN  "Depozit Mooney"
#define AUTHOR  "Aragon*"
#define VERSION "1.0"

enum (+= 100)
{
	TASK_MESAJHUD
}

#define ID_HUD (taskid - TASK_MESAJHUD)

new PlayerCredits[10000], retrase[33];
new Vault, SymbolsName, savepoints;

public plugin_init() {         
	register_plugin(PLUGIN,VERSION,AUTHOR)
	register_forward(FM_ClientUserInfoChanged, "ChangeName");
	SymbolsName = register_cvar("fr_name_symbols", ""); 	//| Symbols Name Restricted |//	biohazardshopmod = register_cvar("bh_shop_mode", "1");		//| Money/Points 0 Money Tax -> 1 Points Tax |//
	savepoints = register_cvar("fr_save_points", "1");	//| Save Points Mode 0 Disable -> 1 Name -> 2 IP -> 3 SteamID |//
	register_clcmd("depozit","Depozit")
	register_logevent("round_start", 2, "1=Round_Start")
	register_clcmd("say /depozit","Depozit")
	register_clcmd("say_team /depozit","Depozit")
	register_clcmd("retrage","Retrage")
	register_clcmd("say /retrage","Retrage")
	register_clcmd("say_team /retrage","Retrage")
	register_clcmd("credite","Show_Credits")
	register_clcmd("credite","Show_Credits")
	register_clcmd("say /credite","Show_Credits")
	register_clcmd("say /credite","Show_Credits")
	register_clcmd("say_team /credite","Show_Credits")
	register_clcmd("say_team /credite","Show_Credits")
	register_concmd("amx_give_credits", "Give_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All -> Amount");
	register_concmd("amx_reset_credits", "Reset_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All");
	}
public plugin_natives() {
	register_native("get_user_credits", "get_user_credits", 1);
	register_native("set_user_credits", "set_user_credits", 1);
}
public set_user_credits(id, credits) {
	PlayerCredits[id] = credits;
	SaveCredits(id)
	}
public get_user_credits(id) {
	return PlayerCredits[id]
	}
public client_putinserver(id) {
	LoadCredits(id)
	retrase[id] = 0
	PlayerCredits[id] += 100
	set_task(180.0, "give_credits", id, _, _, "b")
	set_task(1.0, "MesajHUD", id+TASK_MESAJHUD, _, _, "b")
	}
public client_authorized(id) {
	LoadCredits(id)
	}
public client_connected(id) {
	LoadCredits(id)
	}
public client_disconnect(id) {
	SaveCredits(id)
	remove_task(id)
	retrase[id] = 0
	remove_task(id+TASK_MESAJHUD)
	}
	
public give_credits(id)
{
	ColorChat(id, "^x03[FURIEN]^x04 Ai primit^x03 15 credite^x04 pentru ca ai jucat 5 minute.");
	ColorChat(id, "^x03[FURIEN]^x04 Joaca cat mai mult si acumulezi credite in prostie.");
	PlayerCredits[id] += 15
}

public bomb_planted(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 10
	ColorChat(0, "^x03[FURIEN]^x04 Pentru plantarea bombei,^x03 %s^x04 a primit 10 credite.", nume);
}

public bomb_explode(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 20
	ColorChat(0, "^x03[FURIEN]^x04 Pentru explodarea bombei,^x03 %s^x04 a primit 20 credite.", nume);
}

public bomb_defused(id)
{
	new nume[32];
	get_user_name(id, nume, 31)
	PlayerCredits[id] += 30
	ColorChat(0, "^x03[FURIEN]^x04 Pentru dezamorsarea bombei,^x03 %s^x04 a primit 30 credite.", nume);
}

public round_start()
{
	static id;
	for (id = 1; id <= get_maxplayers(); id++)
	{
		if(is_user_alive(id))
		{
			retrase[id] = 0
		}
	}
}

public MesajHUD(taskid)
{
	static id
	id = ID_HUD;
	
	if(!is_user_alive(id))
	{
		id = pev(id, pev_iuser2)
		
		if(!is_user_alive(id))
			return;
	}
	
	if(id != ID_HUD)
	{
		new nume[32];
		get_user_name(id, nume, 31)
		set_dhudmessage(255, 255, 0, 0.0, 0.52, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_HUD, "", nume, pev(id, pev_health), PlayerCredits[id])
	}
	else
	{
		set_dhudmessage(255, 255, 0, 0.0, 0.885, 0, 6.0, 1.1, 0.0, 0.0)
		show_dhudmessage(ID_HUD, "", pev(ID_HUD, pev_health), PlayerCredits[id])
	}
}
	
//------| Change Name |------//
public ChangeName(id, buffer) {
	if(!is_user_connected(id))
	return FMRES_IGNORED;

	static Name[32], Val[32];
	get_user_name(id, Name, sizeof Name - 1);
	engfunc(EngFunc_InfoKeyValue, buffer, "name", Val, sizeof Val - 1);
	
	if(equal(Val, Name))
	return FMRES_IGNORED;
	
	set_task(0.2, "client_connect", id);
	return FMRES_SUPERCEDE;
	}
	
//------| Client connect |------//	
public client_connect(id) {
	static sName[32];
	get_user_name(id, sName, sizeof sName - 1);
	static sChars[32];
	get_pcvar_string(SymbolsName, sChars, sizeof sChars - 1);	
	for(new i = 0 ; i < strlen(sName) ; i++) {
	for(new j = 0 ; j < strlen(sChars) ; j++) {
	if(sName == sChars[j]) {
	server_cmd("kick #%d ^"Numele tau contine caractere nepermise.^"", get_user_userid(id));
	break;
	}
	else {
	LoadCredits(id);
	}
	}
	}
	}
	
public Depozit(id) {
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR) return PLUGIN_HANDLED;
	
	if(cs_get_user_money(id) == 16000) {
	ColorChat(id, "^x03[FURIEN]^x04 Ai depus^x03 $ 16000^x04 si ai primit^x03 un credit^x04.");
	PlayerCredits[id] += 1;
	cs_set_user_money(id, 0);
	}
	else {
	ColorChat(id, "^x03[FURIEN]^x04 Nu ai^x03 $ 16000^x04.");	
	}
	SaveCredits(id)
	return PLUGIN_HANDLED;
	}
	
public Retrage(id) 
{
	if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
		return PLUGIN_HANDLED;

	if(cs_get_user_money(id) == 16000) 
	{
		ColorChat(id, "^x03[FURIEN]^x04 Ai deja^x03 $ 16000^x04.");
	}
	else if(PlayerCredits[id]) 
	{
		if(retrase[id] < 3)
		{
			ColorChat(id, "^x03[FURIEN]^x04 Ai retras^x03 un credit^x04 si ai primit^x03 $ 16000^x04.");
			PlayerCredits[id] -= 1;
			cs_set_user_money(id, 16000);
			retrase[id]++
		}
		else
		{
			ColorChat(id, "^x03[FURIEN]^x04 Ai retras runda asta deja^x03 3 credite^x04. Incearca runda viitoare.");
		}
	}
	else 
	{
		ColorChat(id, "^x03[FURIEN]^x04 Ai nevoie de^x03 un credit^x04 pentru a retrage.");	
	}
	SaveCredits(id)
	return PLUGIN_HANDLED;
}
	
public Show_Credits(id) {
	set_hudmessage(0, 128, 0, 0.03, 0.86, 2, 6.0, 5.0);
	show_hudmessage(id, "Ai %d credite.", PlayerCredits[id]);
	ColorChat(id, "^x03[FURIEN]^x04 Ai^x03 %d^x04 credite.", PlayerCredits[id]);
	return PLUGIN_HANDLED;
	}
	
public Give_Credits(id, level, cid) {
	if(!cmd_access(id, level, cid, 2)) {
	return PLUGIN_HANDLED;
	}
	new arg[23], gplayers[32], num, i, players, name[32];
	get_user_name(id, name, 31);
	read_argv(1, arg, 23);
	new give_credits[5];
	read_argv(2, give_credits, charsmax(give_credits));
	new Credits = str_to_num(give_credits);
	if(equali(arg, "@T")) {
	get_players(gplayers, num, "e", "TERRORIST");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Furienilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Furienilor.", name, Credits);
	}
	}
	else if(equali(arg, "@CT")) {
	get_players(gplayers, num, "e", "CT");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Anti-Furienilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 le-a dat^x03 %i credite^x04 tuturor^x03 Anti-Furienilor.", name, Credits);
	}
	}
	if(equali(arg, "@All")) {
	get_players(gplayers, num, "a");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] += Credits;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 le-a dat^x03 %i credite^x04 tuturor^x03 jucatorilor.", Credits);
	case 2: ColorChat(0, "^x03%s^x04 a dat^x03 %i credite ^x03 jucatorilor.", name, Credits);
	}
	}
	new player = cmd_target(id, arg, 11);
	if(!player) {
	return PLUGIN_HANDLED;
	}
	PlayerCredits[player] += Credits;
	SaveCredits(id)
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(player, "^x03Adminul^x04 ti-a dat^x03 %i credite.", Credits);
	case 2: ColorChat(player, "^x03%s^x04 ti-a dat^x03 %i credite.", name, Credits);
	}
	return PLUGIN_HANDLED;
	}
	
public Reset_Credits(id, level, cid) {
	if(!cmd_access(id, level, cid, 2)) {
	return PLUGIN_HANDLED;
	}
	new arg[23], gplayers[32], num, i, players, name[32];
	get_user_name(id, name, 31);
	read_argv(1, arg, 23);
	if(equali(arg, "@T")) {
	get_players(gplayers, num, "e", "TERRORIST");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 Furienilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luat^x03 creditele^x04 tuturor^x03 Furienilor.", name);
	}
	}
	
	else if(equali(arg, "@CT")) {
	get_players(gplayers, num, "e", "CT");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 Anti-Furienilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luat^x03 creditele^x04 tuturor^x03 Anti-Furienilor.", name);
	}
	}
	if(equali(arg, "@All")) {
	get_players(gplayers, num, "a");
	for(i = 0; i < num; i++) {
	players = gplayers;
	if(!is_user_connected(players))
	continue;
	PlayerCredits[players] = 0;
	SaveCredits(id)
	}
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(0, "^x03Adminul^x04 a luat^x03 creditele^x04 tuturor^x03 jucatorilor.");
	case 2: ColorChat(0, "^x03%s^x04 a luatx03 creditele^x04 tuturor^x03 jucatorilor.", name);
	}
	}
	new player = cmd_target(id, arg, 11);
	if(!player) {
	return PLUGIN_HANDLED;
	}
	PlayerCredits[player] = 0;
	SaveCredits(id)
	switch(get_cvar_num("amx_show_activity")) {
	case 1: ColorChat(player, "^x03Adminul^x04 ti-a luat^x03 creditele.");
	case 2: ColorChat(player, "^x03%s^x04 ti-a luat^x03 creditele.", name);
	}
	return PLUGIN_HANDLED;
	}
	
//------| Save Credits |------//
public SaveCredits(id) {
	Vault = nvault_open("DepozitCredits");
	new data_credits[256], key_credits[64];
	switch( get_pcvar_num(savepoints) ) { 
	case 1:  { 
	new name[33];
	get_user_name(id,name,32);
	format(key_credits, 63, "%s-/", name);
		}
	case 2: {
	new player_ip[33];
	get_user_ip(id,player_ip,32);
	format(key_credits, 63, "%s-/", player_ip);
	}
	case 3: {
	new steam_ID[33];
	get_user_authid(id,steam_ID,32);
	format(key_credits, 63, "%s-/", steam_ID);
	}
	}
	format(data_credits, 255, "%i#", PlayerCredits[id]);
	nvault_set(Vault, key_credits, data_credits);
	return PLUGIN_CONTINUE;
	}
//------| Loading Credits |------//
public LoadCredits(id) {
	Vault = nvault_open("DepozitCredits");
	new data_credits[256], key_credits[64];
	switch( get_pcvar_num(savepoints) )  { 
	case 1:  { 
	new name[33];
	get_user_name(id,name,32);
	format(key_credits, 63, "%s-/", name);
	}
	case 2: {
	new player_ip[33];
	get_user_ip(id,player_ip,32);
	format(key_credits, 63, "%s-/", player_ip);
	}
	case 3: {
	new steam_ID[33];
	get_user_authid(id,steam_ID,32);
	format(key_credits, 63, "%s-/", steam_ID);
	}
	}
	format(data_credits, 255, "%i#", PlayerCredits[id]);
	nvault_get(Vault, key_credits, data_credits, 255);
	replace_all(data_credits, 255, "#", " ");

	new Credits[32];
	parse(data_credits, Credits, 31);
	PlayerCredits[id] = str_to_num(Credits);
	return PLUGIN_CONTINUE;
	} 
	
stock ColorChat(const id, const input[], any:...) {
	new count = 1, players[32];
	static msg[191];
	vformat(msg, 190, input, 3);
 
	replace_all(msg, 190, "!x04", "^4");
	replace_all(msg, 190, "!x01", "^1");
	replace_all(msg, 190, "!x03", "^3");
 
	if(id) players[0] = id;
	else get_players(players, count, "ch"); {
	for(new i = 0; i < count; i++) {
	if(is_user_connected(players)) {
	message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players);
	write_byte(players);
	write_string(msg);
	message_end();
	}
	}
	} 
	}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
Image

Image
User avatar
Adventx
Membru, skill +4
Membru, skill +4
Posts: 1785
Joined: 17 Sep 2013, 20:44
Detinator Steam: Da
Reputatie: Fost moderator ajutator
Has thanked: 125 times
Been thanked: 142 times
Contact:

28 Nov 2013, 18:28

Pluginul arata mesajul HUD cu cite credite ai si altele, dar eu am intrat la tine pe sever, si am vazut ca folosesti un plugin care inlocueste Time,HP,AP cu alte mesaje HUD, nu stiu daca e de la pluginul asta dar incearca sa-l dezactivezi sa sa vezi daca tot nu-ti arata mesajul HUD
CaPy.lNt
Membru, skill +1
Membru, skill +1
Posts: 146
Joined: 23 Mar 2013, 21:11
Detinator Steam: Nu
CS Status: studiez
Detinator server CS: DR.ECILA.RO
Reputatie: Restrictie PM
Has thanked: 34 times
Been thanked: 13 times
Contact:

28 Nov 2013, 19:13

Aveam acel hud la pluginul cu arme , insa avea bug , eu aveam 200 de credite si imi arata 100..
Acesta este pluginul de arme, se poate vedea ca e sters mesajul hud.. :
| Afiseaza codul
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <cstrike>
#include <hamsandwich>
#include <ColorChat>
#include <engine>
#include <xs>

#define PLUGIN "Furien Weapons Menu"
#define VERSION "1.0"
#define AUTHOR "Tr3fla & Edit By Blue" // si-a bagat si hades nasul pe aici

#define ADMIN_FLAG ADMIN_KICK
#define VIP_FLAG ADMIN_LEVEL_H

#define is_valid_player(%1) (1 <= %1 <= 32)

native set_user_credits ( id, credits );
native get_user_credits ( id );

const m_flNextSecondaryAttack =	47
/* AK47 Golden pentru VIP */
new const vGoldenAk[ 64 ] = "models/fw/v_goldenak.mdl"
new const pGoldenAk[ 64 ] = "models/fw/p_goldenak.mdl"

/* M4A1 Golden pentru VIP */
new const vGoldenM4[ 64 ] = "models/fw/v_goldenm4.mdl"
new const pGoldenM4[ 64 ] = "models/fw/p_goldenm4.mdl"

/* Deagle Golden pentru VIP */
new const vGDeagle[ 64 ] = "models/fw/v_gdeagle.mdl"
new const pGDeagle[ 64 ] = "models/fw/p_deagle.mdl"

new const vFatal [ 64 ] = "models/fw/v_fatal.mdl";
new const pFatal [ 64 ] = "models/fw/p_fatal.mdl";

new const vBarlog [ 64 ] = "models/fw/v_barlog.mdl";
new const pBarlog [ 64 ] = "models/fw/p_barlog.mdl";

//new m_spriteTexture

new bool: ArmaPrimita[ 33 ]
new bool: AreGoldenAK[ 33 ]
new bool: AreGoldenM4[ 33 ]
new bool: AreGDeagle[ 33 ]
new bool: HaveFatal [ 33 ];
new bool: HaveBarlog [ 33 ];

new normalTrace[33], lastTrace[33], cvEnabled, weapon2, dummy;

#define ENG_NULLENT		-1
#define EV_INT_WEAPONKEY	EV_INT_impulse
#define watergun_WEAPONKEY 893
#define MAX_PLAYERS  			  32
#define IsValidUser(%1) (1 <= %1 <= g_MaxPlayers)

#define TASK_FBURN				100
#define ID_FBURN					( taskid - TASK_FBURN )

#define MAX_CLIENTS				32

new bool:g_fRoundEnd

#define FIRE_DURATION		6
#define FIRE_DAMAGE		25

const USE_STOPPED = 0
const OFFSET_ACTIVE_ITEM = 373
const OFFSET_WEAPONOWNER = 41
const OFFSET_LINUX = 5
const OFFSET_LINUX_WEAPONS = 4

#define WEAP_LINUX_XTRA_OFF		4
#define m_fKnown					44
#define m_flNextPrimaryAttack 		46
#define m_iClip					51
#define PLAYER_LINUX_XTRA_OFF	5
#define m_flNextAttack				83

#define watergun_RELOAD_TIME 	3.5
#define watergun_RELOAD		1
#define watergun_DRAW		2
#define watergun_SHOOT1		3
#define watergun_SHOOT2		4

new g_flameSpr
new g_smokeSpr

new g_burning_duration[ MAX_CLIENTS + 1 ]

#define write_coord_f(%1)	engfunc(EngFunc_WriteCoord,%1)

new const Fire_Sounds[][] = { "weapons/waterp.wav" }

new watergun_V_MODEL[64] = "models/fw/v_waterg.mdl"
new watergun_P_MODEL[64] = "models/fw/p_waterg.mdl"
new watergun_W_MODEL[64] = "models/fw/w_waterg.mdl"

//new const GUNSHOT_DECALS[] = { 41, 42, 43, 44, 45 }

new cvar_dmg_watergun, cvar_recoil_watergun, cvar_clip_watergun, cvar_spd_watergun, cvar_watergun_ammo
new g_MaxPlayers, g_orig_event_watergun, g_IsInPrimaryAttack
new Float:cl_pushangle[MAX_PLAYERS + 1][3], m_iBlood[2]
new g_has_watergun[33], g_clip_ammo[33], g_watergun_TmpClip[33], oldweap[33]
new watergun_sprite

const PRIMARY_WEAPONS_BIT_SUM = 
(1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<
CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)
new const WEAPONENTNAMES[][] = { "", "weapon_p228", "", "weapon_scout", "weapon_hegrenade", "weapon_xm1014", "weapon_c4", "weapon_mac10",
			"weapon_aug", "weapon_smokegrenade", "weapon_elite", "weapon_fiveseven", "weapon_ump45", "weapon_sg550",
			"weapon_galil", "weapon_famas", "weapon_usp", "weapon_glock18", "weapon_awp", "weapon_mp5navy", "weapon_m249",
			"weapon_m3", "weapon_m4a1", "weapon_tmp", "weapon_g3sg1", "weapon_flashbang", "weapon_deagle", "weapon_sg552",
			"weapon_ak47", "weapon_knife", "weapon_p90" }

			
#define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))

#define FIRERATE 0.2
#define HITSD 0.7
#define RELOADSPEED 5.0
#define DAMAGE 250.0
#define DAMAGE_MULTI 3.0

#define CSW_WPN CSW_FAMAS
new const weapon[] = "weapon_famas"

new const spr_beam[] = "sprites/plasma/plasma_beam.spr"
new const spr_exp[] = "sprites/plasma/plasma_exp.spr"
new const spr_blood[] = "sprites/blood.spr"
new const snd_fire[][] = { "zombie_plague/plasma/plasma_fire.wav" }
new const snd_reload[][] = { "zombie_plague/plasma/plasma_reload.wav" }
new const snd_hit[][] = { "zombie_plague/plasma/plasma_hit.wav" }

new bool:g_HasRifle[33]
new g_iCurWpn[33], Float:g_flLastFireTime[33]
new g_sprBeam, g_sprExp, g_sprBlood, g_msgDamage, g_msgScreenFade, g_msgScreenShake

const m_pPlayer = 		41
const m_fInReload =		54
const m_pActiveItem = 		373
const m_flTimeWeaponIdle = 	48

const UNIT_SECOND =		(1<<12)
const WPN_MAXCLIP =		25
const ANIM_FIRE = 		5
const ANIM_DRAW = 		10
const ANIM_RELOAD =		9
const EV_INT_WEAPONKEY = 	EV_INT_impulse
const WPNKEY = 			2816

public plugin_init( ) {
	register_plugin( PLUGIN, VERSION, AUTHOR )
	
	register_event( "CurWeapon", "Event_CurWeapon", "be", "1=1" )
	//register_event("CurWeapon", "GoldenEffect", "be", "1=1", "3>0" )
	
	
	cvEnabled = register_cvar("fwm_enabled","1");
	register_event("ResetHUD","event_resethud","b");		//
	register_clcmd("fullupdate","cmd_fullupdate");
	
	register_forward(FM_TraceLine,"fw_traceline");
	register_forward(FM_PlayerPostThink,"fw_playerpostthink");	//
	
	RegisterHam( Ham_Spawn, "player", "fwPlayerSpawn", true )
	RegisterHam ( Ham_TakeDamage, "player", "Player_TakeDamage" );
	RegisterHam( Ham_TakeDamage, "player", "fwTakeDamage" )
	
	register_clcmd( "say /weapons", "ClcmdWeaponsMenus" )
	register_event ( "CurWeapon", "CurrWeapon2", "be", "1=1" );
	
	register_message(get_user_msgid("DeathMsg"), "message_DeathMsg")
	register_event("CurWeapon","CurrentWeapon","be","1=1")
	RegisterHam(Ham_Item_AddToPlayer, "weapon_mp5navy", "fw_watergun_AddToPlayer")
	RegisterHam(Ham_Use, "func_tank", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankmortar", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tankrocket", "fw_UseStationary_Post", 1)
	RegisterHam(Ham_Use, "func_tanklaser", "fw_UseStationary_Post", 1)
	for (new i = 1; i < sizeof WEAPONENTNAMES; i++)
	if (WEAPONENTNAMES[0]) RegisterHam(Ham_Item_Deploy, WEAPONENTNAMES, "fw_Item_Deploy_Post", 1)
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack")
	RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_mp5navy", "fw_watergun_PrimaryAttack_Post", 1)
	RegisterHam(Ham_Item_PostFrame, "weapon_mp5navy", "watergun_ItemPostFrame")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload")
	RegisterHam(Ham_Weapon_Reload, "weapon_mp5navy", "watergun_Reload_Post", 1)
	RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
	RegisterHam( Ham_Spawn, "player", "PlayerSpawn_Post", 1 );
	register_forward(FM_SetModel, "fw_SetModel")
	register_event( "DeathMsg", "EV_DeathMsg", "a" );
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post_fw", 1)
	register_forward(FM_PlaybackEvent, "fwPlaybackEvent")
	
	//RegisterHam(Ham_TraceAttack, "worldspawn", "fw_TraceAttack", 1)
	//RegisterHam(Ham_TraceAttack, "func_breakable", "fw_TraceAttack", 1)
	//RegisterHam(Ham_TraceAttack, "func_wall", "fw_TraceAttack", 1)
	//RegisterHam(Ham_TraceAttack, "func_door", "fw_TraceAttack", 1)
	//RegisterHam(Ham_TraceAttack, "func_door_rotating", "fw_TraceAttack", 1)
	//RegisterHam(Ham_TraceAttack, "func_plat", "fw_TraceAttack", 1)
	//RegisterHam(Ham_TraceAttack, "func_rotating", "fw_TraceAttack", 1)

	cvar_dmg_watergun = register_cvar("zp_watergun_dmg", "0.86")
	cvar_recoil_watergun = register_cvar("zp_watergun_recoil", "1.01")
	cvar_clip_watergun = register_cvar("zp_watergun_clip", "40")
	cvar_spd_watergun = register_cvar("zp_watergun_spd", "1.02")
	cvar_watergun_ammo = register_cvar("zp_watergun_ammo", "200")
	
	
	g_MaxPlayers = get_maxplayers()
	
	register_event("HLTV", "Event_NewRound", "a", "1=0", "2=0");
	register_event("CurWeapon", "event_CurWeapon", "b", "1=1")	

	register_forward(FM_CmdStart, "fw_CmdStart")
	register_forward(FM_UpdateClientData, "fw_UpdateClientData_Post", 1)
	
	RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
	RegisterHam(Ham_Item_Deploy, weapon, "fw_Deploy_Post", 1)
	RegisterHam(Ham_Item_AddToPlayer, weapon, "fw_AddToPlayer")
	RegisterHam(Ham_Weapon_Reload, weapon, "fw_Reload_Post", 1)
	RegisterHam(Ham_Item_PostFrame, weapon, "fw_PostFrame")
	
	g_msgDamage = get_user_msgid("Damage")
	g_msgScreenFade = get_user_msgid("ScreenFade")
	g_msgScreenShake = get_user_msgid("ScreenShake")
	
}

public plugin_precache( ) {
	precache_model( vGoldenAk )
	precache_model( pGoldenAk )
	precache_model( vGoldenM4 )
	precache_model( pGoldenM4 )
	precache_model( vGDeagle )
	precache_model( pGDeagle )
	
	precache_model ( vBarlog );
	precache_model ( pBarlog );
	
	precache_model ( vFatal );
	precache_model ( pFatal );
	
	//m_spriteTexture = precache_model( "sprites/dot.spr" )
	
	precache_model(watergun_V_MODEL)
	precache_model(watergun_P_MODEL)
	precache_model(watergun_W_MODEL)
	for(new i = 0; i < sizeof Fire_Sounds; i++)
	precache_sound(Fire_Sounds)	
	m_iBlood[0] = precache_model("sprites/blood.spr")
	m_iBlood[1] = precache_model("sprites/bloodspray.spr")
	watergun_sprite = precache_model("sprites/watergun.spr")

	g_flameSpr = precache_model( "sprites/flame.spr" );
	g_smokeSpr = precache_model( "sprites/black_smoke3.spr" );

	register_forward(FM_PrecacheEvent, "fwPrecacheEvent_Post", 1)
	
	precache_model("models/fw/plasma/v_plasma.mdl")
	precache_model("models/fw/plasma/p_plasma.mdl")

	g_sprBlood = precache_model(spr_blood)
	g_sprBeam = precache_model(spr_beam)
	g_sprExp = precache_model(spr_exp)
	
	static i
	for(i = 0; i < sizeof snd_fire; i++)
		precache_sound(snd_fire)
	for(i = 0; i < sizeof snd_hit; i++)
		precache_sound(snd_hit)
	for(i = 0; i < sizeof snd_reload; i++)
		precache_sound(snd_reload)	
		
}

public fwPlayerSpawn( id ) {
	AreGoldenAK[ id ] = false
	AreGoldenM4[ id ] = false
	AreGDeagle[ id ] = false
	ArmaPrimita[ id ] = false
	HaveFatal [ id ] = false;
	HaveBarlog [ id ] = false;
	
	if( is_user_alive( id ) && cs_get_user_team( id ) == CS_TEAM_CT ) {
		strip_user_weapons( id )
		PopUpWeaponsMenu( id )
		give_item( id, "weapon_knife" )
		give_item( id, "weapon_usp" )
		cs_set_user_bpammo( id, CSW_USP, 100 )
	}
	else if( is_user_alive( id ) && cs_get_user_team( id ) == CS_TEAM_T ) {
		strip_user_weapons( id ) 
		give_item( id, "weapon_knife" )
		give_item( id, "weapon_hegrenade" )
		give_item( id, "weapon_flashbang" )
		give_item( id, "weapon_smokegrenade" )
		cs_set_user_bpammo( id, CSW_FLASHBANG, 2 )
	}
}

public PopUpWeaponsMenu( id ) {
	new FurienWeaponsMenu = menu_create( "\yAnti-Furien\r Weapons", "FurienWeaponsHandler" )
	
	menu_additem( FurienWeaponsMenu, "Arme\y Hunter", "1", 0 )
	menu_additem( FurienWeaponsMenu, "Arme\r V.I.P", "2", 0 )
	
	// aici si-a bagat hades ownage nasul
	
	menu_additem ( FurienWeaponsMenu, "\wCiuruitoare \r[Special] \y[25 CREDITE]", "3", 0 );
	menu_additem ( FurienWeaponsMenu, "\wArma Fatala \r[Special] \y[80 CREDITE]", "4", 0 );
	menu_additem ( FurienWeaponsMenu, "\wDragon \r[Special] \y[45 CREDITE]", "5", 0 );
	
	menu_setprop( FurienWeaponsMenu, MPROP_EXIT, MEXIT_ALL )
	menu_display( id, FurienWeaponsMenu, 0 )
}

public FurienWeaponsHandler( id, FurienWeaponsMenu, item ) {
	
	if ( get_user_team ( id ) != 2 ) return 1;
	
	if( item == MENU_EXIT ) {
		menu_destroy( FurienWeaponsMenu )
		return PLUGIN_HANDLED
	}
	
	switch( item ) {
		case 0 : {
			ArmeNormale( id ) 
		}
		case 1 : {
			if( get_user_flags( id ) & VIP_FLAG ) {
				ArmeVIP( id ) 
			}
			else {
				ColorChat( id, GREEN, "^4[Furien Weapons]^1 Aceste arme sunt rezervate numai pentru^3 V.I.P^1." )
				PopUpWeaponsMenu( id )
			}

		}
		
		case 2:
		{
			
			new iCredits = get_user_credits(id) - 25;
			if( iCredits < 0 )
			{
				ColorChat ( id, GREEN, "^4[Furien Weapons]^1 Nu ai destule credite, credite necesare:^3 25^1." );
				return 1;
			}
			else
			{
				set_user_credits ( id, iCredits );
				ArmaPrimita[ id ] = true;
				HaveFatal [ id ] = true;
				give_item ( id, "weapon_m249" );
				cs_set_user_bpammo ( id, CSW_M249, 300 );
				CurrWeapon2 ( id );
			}
			
			
			return 1;
		}
		
		case 3:
		{
			
			
			
			new iCredits = get_user_credits(id) - 80;
			if( iCredits < 0 )
			{
				ColorChat ( id, GREEN, "^4[Furien Weapons]^1 Nu ai destule credite, credite necesare:^3 80^1." );
				return 1;
			}
			else
			{
				set_user_credits ( id, iCredits );
				ArmaPrimita[ id ] = true;
				give_laser ( id );
			}
			
			return 1;
		}
		
		case 4:
		{
			new iCredits = get_user_credits(id) - 45;
			if( iCredits < 0 )
			{
				ColorChat ( id, GREEN, "^4[Furien Weapons]^1 Nu ai destule credite, credite necesare:^3 45^1." );
				return 1;
			}
			else
			{
				set_user_credits ( id, iCredits );
				ArmaPrimita[ id ] = true;
				HaveBarlog [ id ] = true;
				give_item ( id, "weapon_xm1014" );
				cs_set_user_bpammo ( id, CSW_XM1014, 200 );
				CurrWeapon2 ( id );
			}
			
			return 1;
		}
	}
	return PLUGIN_HANDLED
}
public ArmeNormale( id ) {
	
	new MeniuArmeNormale = menu_create( "\wMeniu are pentru\r Playeri", "ArmeNormaleHandler" )
	
	menu_additem( MeniuArmeNormale, "\r AK47", "1", 0 )
	menu_additem( MeniuArmeNormale, "M4A1", "2", 0 )
	menu_additem( MeniuArmeNormale, "Mp5 Navy", "3", 0 )
	menu_additem( MeniuArmeNormale, "XM1014", "4", 0 )
	menu_additem( MeniuArmeNormale, "\r M3", "5", 0 )
	menu_additem( MeniuArmeNormale, "\r GALIL", "6", 0 )
	menu_additem( MeniuArmeNormale, "\r P\y90", "7", 0 )
	
	
	menu_setprop( MeniuArmeNormale, MPROP_EXIT, MEXIT_ALL )
	menu_display( id, MeniuArmeNormale, 0 )
}

public ArmeNormaleHandler( id, MeniuArmeNormale, item ) {
	if( !is_user_alive( id ) ) {
		ColorChat( id, GREEN, "^4[Furien Weapons]^1 Nu iti poti alege arma atunci cand esti mort!" )
		return PLUGIN_HANDLED
	}
	
	if ( get_user_team ( id ) != 2 ) return 1;
	
	if( item == MENU_EXIT ) {
		menu_destroy( MeniuArmeNormale )
		return PLUGIN_HANDLED 
	}
	
	switch( item ) {
		case 0 : {
			give_item( id, "weapon_ak47" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_AK47, 200 )
			ArmaPrimita[ id ] = true
		}
		case 1 : {
			give_item( id, "weapon_m4a1" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_M4A1, 200 )
			ArmaPrimita[ id ] = true
		}
		case 2 : {
			give_item( id, "weapon_mp5navy" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_MP5NAVY, 200 )
			ArmaPrimita[ id ] = true
		}
		case 3 : {
			give_item( id, "weapon_xm1014" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_XM1014, 200 )
			ArmaPrimita[ id ] = true
		}
		
		case 4 : {
			give_item( id, "weapon_m3" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_M3, 30 )
			ArmaPrimita[ id ] = true
		}
		
		case 5 : {
			give_item( id, "weapon_galil" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_GALIL, 200 )
			ArmaPrimita[ id ] = true
		}
		case 6 : {
			give_item( id, "weapon_p90" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_P90, 200 )
			ArmaPrimita[ id ] = true
		}
		
		
	}
	menu_destroy( MeniuArmeNormale )
	return PLUGIN_HANDLED
}

public ArmeVIP( id ) {
	new MeniuArmeVIP = menu_create( "\yArme \r*\w V\r.\wI\r.\wP\r *", "ArmeVIPHandler" )
	
	menu_additem( MeniuArmeVIP, "Golden AK47\r  (\y2x DMG\r)", "1", 0 )
	menu_additem( MeniuArmeVIP, "Golden M4A1\r (\y2x DMG\r)", "2", 0 )					
	menu_additem( MeniuArmeVIP, "Golden DEAGLE\r   (\y2x DMG\r)", "3", 0 )			
	menu_additem( MeniuArmeVIP, "Ciuruitoarea\r   (\y100 GL\r)", "4", 0 )
	
	menu_setprop( MeniuArmeVIP, MPROP_EXIT, MEXIT_ALL )
	menu_display( id, MeniuArmeVIP, 0 )
}

public ArmeVIPHandler( id, MeniuArmeVIP, item ) {
	if( !is_user_alive( id ) ) {
		ColorChat( id, GREEN, "^4[Furien Weapons]^1 Nu iti poti alege arma atunci cand esti mort!" )
		return PLUGIN_HANDLED
	}
	
	if ( get_user_team ( id ) != 2 ) return 1;
	
	if( item == MENU_EXIT ) {
		menu_destroy( MeniuArmeVIP )
		return PLUGIN_HANDLED
	}
	
	switch( item ) {
		case 0 : {
			give_item( id, "weapon_ak47" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_AK47, 250 )
			set_pev( id, pev_viewmodel2, vGoldenAk )
			set_pev( id, pev_weaponmodel2, pGoldenAk )
			ArmaPrimita[ id ] = true
			AreGoldenAK[ id ] = true
		}
		case 1 : {
			give_item( id, "weapon_m4a1" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_M4A1, 250 )
			set_pev( id, pev_viewmodel2, vGoldenM4 )
			set_pev( id, pev_weaponmodel2, pGoldenM4 )
			ArmaPrimita[ id ] = true
			AreGoldenM4[ id ] = true
		}
		case 2 : {
			give_item( id, "weapon_deagle" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_DEAGLE, 250 )
			set_pev( id, pev_viewmodel2, vGDeagle )
			set_pev( id, pev_weaponmodel2, pGDeagle )
			ArmaPrimita[ id ] = true
			AreGDeagle[ id ] = true
		}
		case 3 : {
			give_item( id, "weapon_m249" )
			give_item( id, "weapon_smokegrenade" )
			cs_set_user_bpammo( id, CSW_M249, 200 )
			ArmaPrimita[ id ] = true
		}
	}
	menu_destroy( MeniuArmeVIP )
	return PLUGIN_HANDLED
}

public ClcmdWeaponsMenus( id ) {
	if( !is_user_alive( id ) ) {
		ColorChat( id,GREEN, "^4[Furien Weapons]^1 Nu poti sa-ti alegeti arma atunci cand esti mort!" )
		return 
	}
	
	if( ArmaPrimita[ id ] ) {
		ColorChat( id, GREEN,"^4[Furien Weapons]^1 Ti-ai ales deja arma in aceasta runda!" )
		return 
	}
	
	if( cs_get_user_team( id ) == CS_TEAM_CT ) {
		PopUpWeaponsMenu( id )
	}
}

public Event_CurWeapon( id ) {
	new Arma = read_data( 2 )
	
	if( Arma == CSW_AK47 && AreGoldenAK[ id ] ) {
		set_pev( id, pev_viewmodel2, vGoldenAk )
		set_pev( id, pev_weaponmodel2, pGoldenAk )
	}
	
	if( Arma == CSW_M4A1 && AreGoldenM4[ id ] ) {
		set_pev( id, pev_viewmodel2, vGoldenM4 )
		set_pev( id, pev_weaponmodel2, pGoldenM4 )
	}
	
	if( Arma == CSW_DEAGLE && AreGDeagle[ id ] ) {
		set_pev( id, pev_viewmodel2, vGDeagle )
		set_pev( id, pev_weaponmodel2, pGDeagle )
	}
	
	

}

public CurrWeapon2 ( id ) {
	
	if ( get_user_weapon ( id ) == CSW_M249 && HaveFatal [ id ] ) {
		
		set_pev ( id, pev_viewmodel2, vFatal );
		set_pev ( id, pev_weaponmodel2, pFatal );
		
	}
	
	if ( get_user_weapon ( id ) == CSW_XM1014 && HaveBarlog [ id ] ) {
		
		set_pev ( id, pev_viewmodel2, vBarlog );
		set_pev ( id, pev_weaponmodel2, pBarlog );
		
	}
	
}

public fwTakeDamage( Victim, Inflictor, Attacker, Float:Damage ) {
	if( is_valid_player( Attacker ) && get_user_weapon( Attacker ) == CSW_AK47 && AreGoldenAK[ Attacker ] ) {
		SetHamParamFloat( 4, Damage * 2 )
	}
	
	if( is_valid_player( Attacker) && get_user_weapon( Attacker ) == CSW_M4A1 && AreGoldenM4[ Attacker ] ) {
		SetHamParamFloat( 4, Damage * 2 )
	}
	
	if( is_valid_player( Attacker ) && get_user_weapon( Attacker ) == CSW_DEAGLE && AreGDeagle[ Attacker ] ) {
		SetHamParamFloat( 4, Damage * 2 )
	}
	

}

//public GoldenEffect( id ) {
//	new clip,ammo
//	new Arma = get_user_weapon(id,clip,ammo)

//	if (Arma == CSW_AK47 && AreGoldenAK[ id ] || Arma == CSW_M4A1 && AreGoldenM4[ id ] || Arma == CSW_MP5NAVY && AreGoldenMP5[ id ]  ) {
//		new vec1[ 3 ], vec2[ 3 ]
//		get_user_origin( id, vec1, 1 ) 
//		get_user_origin( id, vec2, 4 ) 
//
//		message_begin( MSG_BROADCAST,SVC_TEMPENTITY )
//		write_byte ( 0 )     
//		write_coord( vec1[ 0 ] )
//		write_coord( vec1[ 1 ] )
//		write_coord( vec1[ 2 ] )
//		write_coord( vec2[ 0 ] )
//		write_coord( vec2[ 1 ] )
//		write_coord( vec2[ 2 ] )
//		write_short( m_spriteTexture )
//		write_byte( 1 )  
//		write_byte( 5 ) 
//		write_byte( 2 ) 
//		write_byte( 10 ) 
//		write_byte( 0  ) 
//		write_byte( 255  )     
//		write_byte( 215  )       
//		write_byte(  0 )       
//		write_byte( 200 ) 
//		write_byte( 150 ) 
//		message_end( )
//	}
//}

/* Edit lucylucy */


// reset normal trace id on join or leave
public client_connect(id)
{
	normalTrace[id] = 0;
	g_has_watergun[id] = false

	g_HasRifle[id] = false
}

public client_disconnect(id)
{
	normalTrace[id] = 0;
	g_has_watergun[id] = false
	g_HasRifle[id] = false
	remove_task(id + TASK_FBURN )
}

// player spawns, and some other such things
public event_resethud(id)
{
	lastTrace[id] = 0;
}

// block forced resethud call
public cmd_fullupdate(id)
{
	return PLUGIN_HANDLED;
}

// traceline hook, meat and bones of the entire plugin
public fw_traceline(Float:vecStart[3],Float:vecEnd[3],ignoreM,id,pentru) // pentToSkip == id, for clarity
{
	if(!is_user_connected(id))
		return FMRES_IGNORED;
	
	// grab normal trace
	if(!normalTrace[id])
	{
		normalTrace[id] = pentru;
		return FMRES_IGNORED;
	}
	
	// ignore normal trace
	else if(pentru == normalTrace[id])
		return FMRES_IGNORED;
	
	// no functionality
	if(!get_pcvar_num(cvEnabled))
		return FMRES_IGNORED;
	
	// not a player entity, or player is dead
	if(!is_user_alive(id))
		return FMRES_IGNORED;
	
	// not shooting anything
	if(!(pev(id,pev_button) & IN_ATTACK))
		return FMRES_IGNORED;
	
	weapon2 = get_user_weapon(id,dummy,dummy);
	
	// using a shotgun, expect multiple tracelines
	if(weapon2 == CSW_M3 || weapon2 == CSW_XM1014)
		return FMRES_IGNORED;
	
	// this is a second traceline, for shooting through walls
	if(pentru == lastTrace[id])
	{
		// values sure to throw off any traceline
		set_tr(TR_vecEndPos,Float:{4096.0,4096.0,4096.0});
		set_tr(TR_AllSolid,1);
		set_tr(TR_pHit,0);
		set_tr(TR_iHitgroup,0);
		set_tr(TR_flFraction,1.0);
		
		return FMRES_SUPERCEDE;
	}
	
	// remeber traceline index for next time
	lastTrace[id] = pentru;
	
	return FMRES_IGNORED;
}

// finished client calculations, reset our traceline index
public fw_playerpostthink(id)
{
	lastTrace[id] = 0;
}




public plugin_natives ()
{
	register_native("give_weapon_watergun", "native_give_weapon_add", 1)
}
public native_give_weapon_add(id)
{
	give_watergun(id)
}

public fwPrecacheEvent_Post(type, const name[])
{
	if (equal("events/mp5n.sc", name))
	{
		g_orig_event_watergun = get_orig_retval()
		return FMRES_HANDLED
	}
	return FMRES_IGNORED
}

public fw_SetModel(entity, model[])
{
	if(!is_valid_ent(entity))
		return FMRES_IGNORED
	
	static szClassName[33]
	entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
		
	if(!equal(szClassName, "weaponbox"))
		return FMRES_IGNORED
	
	static iOwner
	
	iOwner = entity_get_edict(entity, EV_ENT_owner)
	
	if(equal(model, "models/w_mp5.mdl"))
	{
		static iStoredAugID
		
		iStoredAugID = find_ent_by_owner(ENG_NULLENT, "weapon_mp5navy", entity)
	
		if(!is_valid_ent(iStoredAugID))
			return FMRES_IGNORED
	
		if(g_has_watergun[iOwner])
		{
			entity_set_int(iStoredAugID, EV_INT_WEAPONKEY, watergun_WEAPONKEY)
			
			g_has_watergun[iOwner] = false
			
			entity_set_model(entity, watergun_W_MODEL)
			
			return FMRES_SUPERCEDE
		}
	}
	return FMRES_IGNORED
}

public EV_DeathMsg( )
{
	static pevVictim;
	pevVictim = read_data( 2 )
	
	if( !is_user_connected( pevVictim ) )
		return
		
	remove_task( pevVictim + TASK_FBURN )
}

public PlayerSpawn_Post( Player )
{
	if( !is_user_alive( Player ) )
		return;
		
	g_burning_duration[ Player ] = 0
}

public give_watergun(id)
{
	drop_weapons(id, 1)
	new iWep2 = give_item(id,"weapon_mp5navy")
	if( iWep2 > 0 )
	{
		cs_set_weapon_ammo(iWep2, get_pcvar_num(cvar_clip_watergun))
		cs_set_user_bpammo (id, CSW_MP5NAVY, get_pcvar_num(cvar_watergun_ammo))	
		UTIL_PlayWeaponAnimation(id, watergun_DRAW)
		set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
	}
	g_has_watergun[id] = true
}

public fw_watergun_AddToPlayer(watergun, id)
{
	if(!is_valid_ent(watergun) || !is_user_connected(id))
		return HAM_IGNORED
	
	if(entity_get_int(watergun, EV_INT_WEAPONKEY) == watergun_WEAPONKEY)
	{
		g_has_watergun[id] = true
		
		entity_set_int(watergun, EV_INT_WEAPONKEY, 0)
		
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public fw_UseStationary_Post(entity, caller, activator, use_type)
{
	if (use_type == USE_STOPPED && is_user_connected(caller))
		replace_weapon_models(caller, get_user_weapon(caller))
}

public fw_Item_Deploy_Post(weapon_ent)
{
	static owner
	owner = fm_cs_get_weapon_ent_owner(weapon_ent)
	
	static weaponid
	weaponid = cs_get_weapon_id(weapon_ent)
	
	replace_weapon_models(owner, weaponid)
}

public CurrentWeapon(id)
{
	
     replace_weapon_models(id, read_data(2))

     if(read_data(2) != CSW_MP5NAVY || !g_has_watergun[id])
          return
     
     static Float:iSpeed
     if(g_has_watergun[id])
          iSpeed = get_pcvar_float(cvar_spd_watergun)
     
     static weapon[32],Ent
     get_weaponname(read_data(2),weapon,31)
     Ent = find_ent_by_owner(-1,weapon,id)
     if(Ent)
     {
          static Float:Delay
          Delay = get_pdata_float( Ent, 46, 4) * iSpeed
          if (Delay > 0.0)
          {
               set_pdata_float(Ent, 46, Delay, 4)
          }
     }
}

replace_weapon_models(id, weaponid)
{
	
	
	
	switch (weaponid)
	{
		case CSW_MP5NAVY:
		{
			
			if(g_has_watergun[id])
			{
				set_pev(id, pev_viewmodel2, watergun_V_MODEL)
				set_pev(id, pev_weaponmodel2, watergun_P_MODEL)
				if(oldweap[id] != CSW_MP5NAVY) 
				{
					UTIL_PlayWeaponAnimation(id, watergun_DRAW)
					set_pdata_float(id, m_flNextAttack, 1.0, PLAYER_LINUX_XTRA_OFF)
				}
			}
		}
	}
	oldweap[id] = weaponid
}

public fw_UpdateClientData_Post_fw(Player, SendWeapons, CD_Handle)
{
	if(!is_user_alive(Player) || (get_user_weapon(Player) != CSW_MP5NAVY || !g_has_watergun[Player]))
		return FMRES_IGNORED
	
	set_cd(CD_Handle, CD_flNextAttack, halflife_time () + 0.001)
	return FMRES_HANDLED
}

public fw_watergun_PrimaryAttack(Weapon)
{
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	if (!g_has_watergun[Player])
		return
	
	g_IsInPrimaryAttack = 1
	pev(Player,pev_punchangle,cl_pushangle[Player])
	
	g_clip_ammo[Player] = cs_get_weapon_ammo(Weapon)
}

public fwPlaybackEvent(flags, invoker, eventid, Float:delay, Float:origin[3], Float:angles[3], Float:fparam1, Float:fparam2, iParam1, iParam2, bParam1, bParam2)
{
	if ((eventid != g_orig_event_watergun) || !g_IsInPrimaryAttack)
		return FMRES_IGNORED
	if (!(1 <= invoker <= g_MaxPlayers))
    return FMRES_IGNORED

	playback_event(flags | FEV_HOSTONLY, invoker, eventid, delay, origin, angles, fparam1, fparam2, iParam1, iParam2, bParam1, bParam2)
	return FMRES_SUPERCEDE
}

public fw_watergun_PrimaryAttack_Post(Weapon)
{
	g_IsInPrimaryAttack = 0
	new Player = get_pdata_cbase(Weapon, 41, 4)
	
	new szClip, szAmmo
	get_user_weapon(Player, szClip, szAmmo)
	
	if(!is_user_alive(Player))
		return

	if(g_has_watergun[Player])
	{
		if (!g_clip_ammo[Player])
			return

		new Float:push[3]
		pev(Player,pev_punchangle,push)
		xs_vec_sub(push,cl_pushangle[Player],push)
		
		xs_vec_mul_scalar(push,get_pcvar_float(cvar_recoil_watergun),push)
		xs_vec_add(push,cl_pushangle[Player],push)
		set_pev(Player,pev_punchangle,push)
		
		emit_sound(Player, CHAN_WEAPON, Fire_Sounds[0], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
		UTIL_PlayWeaponAnimation(Player, random_num(watergun_SHOOT1, watergun_SHOOT2))

		static Float:plrViewAngles[3], Float:VecEnd[3], Float:VecDir[3], Float:PlrOrigin[3]
		pev(Player, pev_v_angle, plrViewAngles)

		static Float:VecSrc[3], Float:VecDst[3]
	
		//VecSrc = pev->origin + pev->view_ofs
		pev(Player, pev_origin, PlrOrigin)
		pev(Player, pev_view_ofs, VecSrc)
		xs_vec_add(VecSrc, PlrOrigin, VecSrc)

		//VecDst = VecDir * 8192.0
		angle_vector(plrViewAngles, ANGLEVECTOR_FORWARD, VecDir);
		xs_vec_mul_scalar(VecDir, 8192.0, VecDst);
		xs_vec_add(VecDst, VecSrc, VecDst);
	
		new hTrace = create_tr2()
		engfunc(EngFunc_TraceLine, VecSrc, VecDst, 0, Player, hTrace)
		get_tr2(hTrace, TR_vecEndPos, VecEnd);

		create_tracer_water(Player, VecSrc, VecEnd)	
	}
}

public fw_TakeDamage(victim, inflictor, attacker, Float:damage)
{
	if(!is_user_alive(attacker))
		return;

	if (victim != attacker && is_user_connected(attacker))
	{
		if(get_user_weapon(attacker) == CSW_MP5NAVY)
		{
			if(g_has_watergun[attacker])
			{
				SetHamParamFloat(4, damage * get_pcvar_float(cvar_dmg_watergun))

				if( !task_exists( victim + TASK_FBURN ) )
				{
					g_burning_duration[ victim ] += FIRE_DURATION * 5
				
					set_task( 0.2, "CTask__BurningFlame", victim + TASK_FBURN, _, _, "b" )
				}
			}
		}
	}
}

public message_DeathMsg(msg_id, msg_dest, id)
{
	static szTruncatedWeapon[33], iAttacker, iVictim
	
	get_msg_arg_string(4, szTruncatedWeapon, charsmax(szTruncatedWeapon))
	
	iAttacker = get_msg_arg_int(1)
	iVictim = get_msg_arg_int(2)
	
	if(!is_user_connected(iAttacker) || iAttacker == iVictim)
		return PLUGIN_CONTINUE
	
	if(equal(szTruncatedWeapon, "mp5navy") && get_user_weapon(iAttacker) == CSW_MP5NAVY)
	{
		if(g_has_watergun[iAttacker])
			set_msg_arg_string(4, "mp5navy")
	}
	return PLUGIN_CONTINUE
}

stock fm_cs_get_current_weapon_ent(id)
{
	return get_pdata_cbase(id, OFFSET_ACTIVE_ITEM, OFFSET_LINUX)
}

stock fm_cs_get_weapon_ent_owner(ent)
{
	return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
}

stock UTIL_PlayWeaponAnimation(const Player, const Sequence)
{
	set_pev(Player, pev_weaponanim, Sequence)
	
	message_begin(MSG_ONE_UNRELIABLE, SVC_WEAPONANIM, .player = Player)
	write_byte(Sequence)
	write_byte(pev(Player, pev_body))
	message_end()
}

public watergun_ItemPostFrame(weapon_entity) 
{
     new id = pev(weapon_entity, pev_owner)
     if (!is_user_connected(id))
          return HAM_IGNORED

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra
     
     iClipExtra = get_pcvar_num(cvar_clip_watergun)
     new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, PLAYER_LINUX_XTRA_OFF)

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY);
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     new fInReload = get_pdata_int(weapon_entity, m_fInReload, WEAP_LINUX_XTRA_OFF) 

     if( fInReload && flNextAttack <= 0.0 )
     {
	     new j = min(iClipExtra - iClip, iBpAmmo)
	
	     set_pdata_int(weapon_entity, m_iClip, iClip + j, WEAP_LINUX_XTRA_OFF)
	     cs_set_user_bpammo(id, CSW_MP5NAVY, iBpAmmo-j)
		
	     set_pdata_int(weapon_entity, m_fInReload, 0, WEAP_LINUX_XTRA_OFF)
	     fInReload = 0
     }
     return HAM_IGNORED
}

public watergun_Reload(weapon_entity) 
{
     new id = pev(weapon_entity, pev_owner)
     if (!is_user_connected(id))
          return HAM_IGNORED

     if (!g_has_watergun[id])
          return HAM_IGNORED

     static iClipExtra

     if(g_has_watergun[id])
          iClipExtra = get_pcvar_num(cvar_clip_watergun)

     g_watergun_TmpClip[id] = -1

     new iBpAmmo = cs_get_user_bpammo(id, CSW_MP5NAVY)
     new iClip = get_pdata_int(weapon_entity, m_iClip, WEAP_LINUX_XTRA_OFF)

     if (iBpAmmo <= 0)
          return HAM_SUPERCEDE

     if (iClip >= iClipExtra)
          return HAM_SUPERCEDE

     g_watergun_TmpClip[id] = iClip

     return HAM_IGNORED
}

public watergun_Reload_Post(weapon_entity) 
{
	new id = pev(weapon_entity, pev_owner)
	if (!is_user_connected(id))
		return HAM_IGNORED

	if (!g_has_watergun[id])
		return HAM_IGNORED

	if (g_watergun_TmpClip[id] == -1)
		return HAM_IGNORED

	set_pdata_int(weapon_entity, m_iClip, g_watergun_TmpClip[id], WEAP_LINUX_XTRA_OFF)

	set_pdata_float(weapon_entity, m_flTimeWeaponIdle, watergun_RELOAD_TIME, WEAP_LINUX_XTRA_OFF)

	set_pdata_float(id, m_flNextAttack, watergun_RELOAD_TIME, PLAYER_LINUX_XTRA_OFF)

	set_pdata_int(weapon_entity, m_fInReload, 1, WEAP_LINUX_XTRA_OFF)

	UTIL_PlayWeaponAnimation(id, watergun_RELOAD)

	return HAM_IGNORED
}

stock create_tracer_water(id, Float:fVec1[3], Float:fVec2[3])
{
	static iVec1[3]
	FVecIVec(fVec1, iVec1)

	static Float:origin[3], Float:vSrc[3], Float:angles[3], Float:v_forward[3], Float:v_right[3], Float:v_up[3], Float:gun_position[3], Float:player_origin[3], Float:player_view_offset[3]
	pev(id, pev_v_angle, angles)
	engfunc(EngFunc_MakeVectors, angles)
	global_get(glb_v_forward, v_forward)
	global_get(glb_v_right, v_right)
	global_get(glb_v_up, v_up)

	//m_pPlayer->GetGunPosition( ) = pev->origin + pev->view_ofs
	pev(id, pev_origin, player_origin)
	pev(id, pev_view_ofs, player_view_offset)
	xs_vec_add(player_origin, player_view_offset, gun_position)

	xs_vec_mul_scalar(v_forward, 24.0, v_forward)
	xs_vec_mul_scalar(v_right, 3.0, v_right)

	if ((pev(id, pev_flags) & FL_DUCKING) == FL_DUCKING)
		xs_vec_mul_scalar(v_up, 6.0, v_up)
	else
		xs_vec_mul_scalar(v_up, -2.0, v_up)

	xs_vec_add(gun_position, v_forward, origin)
	xs_vec_add(origin, v_right, origin)
	xs_vec_add(origin, v_up, origin)

	vSrc[0] = origin[0]
	vSrc[1] = origin[1]
	vSrc[2] = origin[2]

	new Float:dist = get_distance_f(vSrc, fVec2)
	new CountDrops = floatround(dist / 50.0)
	
	if (CountDrops > 20)
		CountDrops = 20
	
	if (CountDrops < 2)
		CountDrops = 2

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_SPRITETRAIL)
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	write_short(watergun_sprite)
	write_byte(CountDrops)
	write_byte(0)
	write_byte(1)
	write_byte(60)
	write_byte(10)
	message_end()

	message_begin(MSG_PAS, SVC_TEMPENTITY, iVec1)
	write_byte(TE_BEAMPOINTS)
	engfunc(EngFunc_WriteCoord, fVec2[0])
	engfunc(EngFunc_WriteCoord, fVec2[1])
	engfunc(EngFunc_WriteCoord, fVec2[2])
	engfunc(EngFunc_WriteCoord, vSrc[0])
	engfunc(EngFunc_WriteCoord, vSrc[1])
	engfunc(EngFunc_WriteCoord, vSrc[2])
	write_short(watergun_sprite)
	write_byte(6)
	write_byte(200) 
	write_byte(1)
	write_byte(100)
	write_byte(0)
	write_byte(64); write_byte(64); write_byte(192);
	write_byte(192)
	write_byte(250) 
	message_end()
}

stock drop_weapons(id, dropwhat)
{
     static weapons[32], num, i, weaponid
     num = 0
     get_user_weapons(id, weapons, num)
     
     for (i = 0; i < num; i++)
     {
          weaponid = weapons
          
          if (dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM))
          {
               static wname[32]
               get_weaponname(weaponid, wname, sizeof wname - 1)
               engclient_cmd(id, "drop", wname)
          }
     }
}

public CTask__BurningFlame( taskid )
{
	// Get player origin and flags
	static origin[3], flags
	get_user_origin(ID_FBURN, origin)
	flags = pev(ID_FBURN, pev_flags)
	
	// Madness mode - in water - burning stopped
	if ((flags & FL_INWATER) || g_burning_duration[ID_FBURN] < 1 || g_fRoundEnd || !is_user_alive(ID_FBURN))
	{
		// Smoke sprite
		message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
		write_byte(TE_SMOKE) // TE id
		write_coord(origin[0]) // x
		write_coord(origin[1]) // y
		write_coord(origin[2]-50) // z
		write_short(g_smokeSpr) // sprite
		write_byte(random_num(15, 20)) // scale
		write_byte(random_num(10, 20)) // framerate
		message_end()
		
		// Task not needed anymore
		remove_task(taskid)
		return
	}
	
	// Get player's health
	static health
	health = pev(ID_FBURN, pev_health)
	
	// Take damage from the fire
	if (health - FIRE_DAMAGE > 0)
		fm_set_user_health(ID_FBURN, health - FIRE_DAMAGE)
	
	// Flame sprite
	message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
	write_byte(TE_SPRITE) // TE id
	write_coord(origin[0]+random_num(-5, 5)) // x
	write_coord(origin[1]+random_num(-5, 5)) // y
	write_coord(origin[2]+random_num(-10, 10)) // z
	write_short(g_flameSpr) // sprite
	write_byte(random_num(5, 10)) // scale
	write_byte(200) // brightness
	message_end()

	
	g_burning_duration[ID_FBURN]--
}

stock fm_set_user_health( index, health ) 
	health > 0 ? set_pev(index, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, index);

	
public event_CurWeapon(id)
{
	if(!is_user_alive(id))
	return PLUGIN_CONTINUE
		
	g_iCurWpn[id] = read_data(2)
	
		
	if(!g_HasRifle[id] || g_iCurWpn[id] != CSW_WPN) 
		return PLUGIN_CONTINUE
		
	entity_set_string(id, EV_SZ_viewmodel, "models/fw/plasma/v_plasma.mdl")
	entity_set_string(id, EV_SZ_weaponmodel, "models/fw/plasma/p_plasma.mdl")
	return PLUGIN_CONTINUE
}

public fw_PlayerKilled(victim, attacker, shouldgib)
{
	if(is_user_alive(victim))
	{
		g_HasRifle[victim] = false
		return HAM_HANDLED
	}
	return HAM_IGNORED
}

public Event_NewRound()
{
	for (new i = 1; i <= get_maxplayers(); i++)
	{
		g_HasRifle = false
	}
}

public give_laser(id)
{
		
	new bool:HasWpn = bool:user_has_weapon(id, CSW_WPN)
		
	if(!g_HasRifle[id] && !HasWpn)
	{
		g_HasRifle[id] = true	
		fm_give_item(id, weapon)	
		cs_set_user_bpammo(id, CSW_WPN, 100)	
		engclient_cmd(id, weapon)
	}

	
	return PLUGIN_CONTINUE
}
public fw_CmdStart(id, handle, seed)
{
	if(!is_user_alive(id))
		return FMRES_IGNORED
	
	if(!g_HasRifle[id])
		return FMRES_IGNORED
		

	
	if(g_iCurWpn[id] != CSW_WPN)
		return FMRES_IGNORED
		
	static iButton
	iButton = get_uc(handle, UC_Buttons)
	
	if(iButton & IN_ATTACK)
	{
		set_uc(handle, UC_Buttons, iButton & ~IN_ATTACK)
		
		static Float:flCurTime
		flCurTime = halflife_time()
		
		if(flCurTime - g_flLastFireTime[id] < FIRERATE)
			return FMRES_IGNORED
			
		static iWpnID, iClip
		iWpnID = get_pdata_cbase(id, m_pActiveItem, 5)
		iClip = cs_get_weapon_ammo(iWpnID)
		
		if(get_pdata_int(iWpnID, m_fInReload, 4))
			return FMRES_IGNORED
		
		set_pdata_float(iWpnID, m_flNextPrimaryAttack, FIRERATE, 4)
		set_pdata_float(iWpnID, m_flNextSecondaryAttack, FIRERATE, 4)
		set_pdata_float(iWpnID, m_flTimeWeaponIdle, FIRERATE, 4)
		g_flLastFireTime[id] = flCurTime
		if(iClip <= 0)
		{
			ExecuteHamB(Ham_Weapon_PlayEmptySound, iWpnID)
			return FMRES_IGNORED
		}
		primary_attack(id)
		make_punch(id, 50)
		cs_set_weapon_ammo(iWpnID, --iClip)
		
		return FMRES_IGNORED
	}
	
	return FMRES_IGNORED
}
public fw_UpdateClientData_Post(id, sendweapons, handle)
{
	if(!is_user_alive(id))
		return FMRES_IGNORED
		
	if(!g_HasRifle[id])
		return FMRES_IGNORED
		
	
	if(g_iCurWpn[id] != CSW_WPN)
		return FMRES_IGNORED
		
	set_cd(handle, CD_flNextAttack, halflife_time() + 0.001)
	return FMRES_HANDLED
}
public fw_Deploy_Post(wpn)
{
	static id
	id = get_pdata_cbase(wpn, m_pPlayer, 4)
	
	if(is_user_connected(id) && g_HasRifle[id])
	{
		set_wpnanim(id, ANIM_DRAW)
	}
	return HAM_IGNORED
}
public fw_AddToPlayer(wpn, id)
{
	if(is_valid_ent(wpn) && is_user_connected(id) && entity_get_int(wpn, EV_INT_WEAPONKEY) == WPNKEY)
	{
		g_HasRifle[id] = true
		entity_set_int(wpn, EV_INT_WEAPONKEY, 0)
		return HAM_HANDLED
	}
	return HAM_IGNORED
}
public fw_PostFrame(wpn)
{
	static id
	id = get_pdata_cbase(wpn, m_pPlayer, 4)

	if(is_user_alive(id) && g_HasRifle[id])
	{
		static Float:flNextAttack, iBpAmmo, iClip, iInReload
		iInReload = get_pdata_int(wpn, m_fInReload, 4)
		flNextAttack = get_pdata_float(id, m_flNextAttack, 5)
		iBpAmmo = cs_get_user_bpammo(id, CSW_WPN)
		iClip = cs_get_weapon_ammo(wpn)
		
		if(iInReload && flNextAttack <= 0.0)
		{
			new iRemClip = min(WPN_MAXCLIP - iClip, iBpAmmo)
			cs_set_weapon_ammo(wpn, iClip + iRemClip)
			cs_set_user_bpammo(id, CSW_WPN, iBpAmmo-iRemClip)
			iInReload = 0
			set_pdata_int(wpn, m_fInReload, 0, 4)
		}
		static iButton
		iButton = get_user_button(id)

		if((iButton & IN_ATTACK2 && get_pdata_float(wpn, m_flNextSecondaryAttack, 4) <= 0.0) || (iButton & IN_ATTACK && get_pdata_float(wpn, m_flNextPrimaryAttack, 4) <= 0.0))
			return
		
		if(iButton & IN_RELOAD && !iInReload)
		{
			if(iClip >= WPN_MAXCLIP)
			{
				entity_set_int(id, EV_INT_button, iButton & ~IN_RELOAD)
				set_wpnanim(id, 0)
			}
			else if(iClip == WPN_MAXCLIP)
			{
				if(iBpAmmo)
				{
					reload(id, wpn, 1)
				}
			}
		}
	}
}
public fw_Reload_Post(wpn)
{
	static id
	id = get_pdata_cbase(wpn, m_pPlayer, 4)
	
	if(is_user_alive(id) && g_HasRifle[id] && get_pdata_int(wpn, m_fInReload, 4))
	{		
		reload(id, wpn)
	}
}
public primary_attack(id)
{
	set_wpnanim(id, ANIM_FIRE)
	entity_set_vector(id, EV_VEC_punchangle, Float:{ -1.5, 0.0, 0.0 })
	emit_sound(id, CHAN_WEAPON, snd_fire[random_num(0, sizeof snd_fire - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)

	static iTarget, iBody, iEndOrigin[3], iStartOrigin[3]
	get_user_origin(id, iStartOrigin, 1) 
	get_user_origin(id, iEndOrigin, 3)
	fire_effects(iStartOrigin, iEndOrigin)
	get_user_aiming(id, iTarget, iBody)
	
	new iEnt = create_entity("info_target")
	
	static Float:flOrigin[3]
	IVecFVec(iEndOrigin, flOrigin)
	entity_set_origin(iEnt, flOrigin)
	remove_entity(iEnt)
	
	if(is_user_alive(iTarget))
	{	
		if(HITSD > 0.0)
		{
			static Float:flVelocity[3]
			get_user_velocity(iTarget, flVelocity)
			xs_vec_mul_scalar(flVelocity, HITSD, flVelocity)
			set_user_velocity(iTarget, flVelocity)	
		}
		if(get_user_team ( id ) != get_user_team ( iTarget ))
		{
			new iHp = pev(iTarget, pev_health)
			new Float:iDamage, iBloodScale
			if(iBody == HIT_HEAD)
			{
				iDamage = DAMAGE
				iBloodScale = 10
			}
			else
			{
				iDamage = DAMAGE*DAMAGE_MULTI
				iBloodScale = 25
			}
			if(iHp > iDamage) 
			{
				make_blood(iTarget, iBloodScale)
				set_pev(iTarget, pev_health, iHp-iDamage)
				damage_effects(iTarget)
			}
			else if(iHp <= iDamage)
			{
				ExecuteHamB(Ham_Killed, iTarget, id, 2)
			}
		}
	}
	else
	{
		emit_sound(id, CHAN_WEAPON, snd_hit[random_num(0, sizeof snd_hit - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	}
}
stock fire_effects(iStartOrigin[3], iEndOrigin[3])
{
	message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
	write_byte(0)    
	write_coord(iStartOrigin[0])
	write_coord(iStartOrigin[1])
	write_coord(iStartOrigin[2])
	write_coord(iEndOrigin[0])
	write_coord(iEndOrigin[1])
	write_coord(iEndOrigin[2])
	write_short(g_sprBeam)
	write_byte(1) 
	write_byte(5) 
	write_byte(10) 
	write_byte(25) 
	write_byte(0) 
	write_byte(0)     
	write_byte(255)      
	write_byte(0)      
	write_byte(100) 
	write_byte(0) 
	message_end()
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
	write_byte(3)
	write_coord(iEndOrigin[0])
	write_coord(iEndOrigin[1])
	write_coord(iEndOrigin[2])
	write_short(g_sprExp)
	write_byte(10)
	write_byte(15)
	write_byte(4)
	message_end()	
}
stock reload(id, wpn, force_reload = 0)
{
	set_pdata_float(id, m_flNextAttack, RELOADSPEED, 5)
	set_wpnanim(id, ANIM_RELOAD)
	emit_sound(id, CHAN_WEAPON, snd_reload[random_num(0, sizeof snd_reload - 1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
	
	if(force_reload)
		set_pdata_int(wpn, m_fInReload, 1, 4)
}
stock damage_effects(id)
{
	message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
	write_byte(0)
	write_byte(0)
	write_long(DMG_NERVEGAS)
	write_coord(0) 
	write_coord(0)
	write_coord(0)
	message_end()
	
	message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, {0,0,0}, id)
	write_short(1<<13)
	write_short(1<<14)
	write_short(0x0000)
	write_byte(0)
	write_byte(255)
	write_byte(0)
	write_byte(100) 
	message_end()
		
	message_begin(MSG_ONE, g_msgScreenShake, {0,0,0}, id)
	write_short(0xFFFF)
	write_short(1<<13)
	write_short(0xFFFF) 
	message_end()
}
stock make_blood(id, scale)
{
	new Float:iVictimOrigin[3]
	pev(id, pev_origin, iVictimOrigin)
	
	message_begin(MSG_BROADCAST, SVC_TEMPENTITY) 
	write_byte(115)
	write_coord(floatround(iVictimOrigin[0]+random_num(-20,20))) 
	write_coord(floatround(iVictimOrigin[1]+random_num(-20,20))) 
	write_coord(floatround(iVictimOrigin[2]+random_num(-20,20))) 
	write_short(g_sprBlood)
	write_short(g_sprBlood) 
	write_byte(248) 
	write_byte(scale) 
	message_end()
}
stock set_wpnanim(id, anim)
{
	entity_set_int(id, EV_INT_weaponanim, anim)
	message_begin(MSG_ONE, SVC_WEAPONANIM, {0, 0, 0}, id)
	write_byte(anim)
	write_byte(entity_get_int(id, EV_INT_body))
	message_end()
}
stock make_punch(id, velamount) 
{
	static Float:flNewVelocity[3], Float:flCurrentVelocity[3]
	velocity_by_aim(id, -velamount, flNewVelocity)
	get_user_velocity(id, flCurrentVelocity)
	xs_vec_add(flNewVelocity, flCurrentVelocity, flNewVelocity)
	set_user_velocity(id, flNewVelocity)	
}
stock fm_give_item(index, const item[])
{
	if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
		return 0;

	new ent = fm_create_entity(item);
	if (!pev_valid(ent))
		return 0;
	
	new Float:origin[3];
	pev(index, pev_origin, origin);
	set_pev(ent, pev_origin, origin);
	set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
	dllfunc(DLLFunc_Spawn, ent);
	
	new save = pev(ent, pev_solid);
	dllfunc(DLLFunc_Touch, ent, index);
	if (pev(ent, pev_solid) != save)
		return ent;
	
	engfunc(EngFunc_RemoveEntity, ent);
	
	return -1;
}

public Player_TakeDamage ( iVictim, iInflictor, iAttacker, Float:fDamage, iDamageBits ) {
	
	if ( HaveBarlog [ iAttacker ] && get_user_weapon ( iAttacker ) == CSW_XM1014 && is_valid_player( iAttacker) ) {
		
		SetHamParamFloat( 4, fDamage * 3.0);
		return HAM_HANDLED;
		
	}
	
	if ( HaveFatal [ iAttacker ] && get_user_weapon ( iAttacker ) == CSW_M249 && is_valid_player( iAttacker) ) {
		
		SetHamParamFloat( 4, fDamage * 2.4);
		return HAM_HANDLED;
		
	}
	
	return HAM_IGNORED;
	
}
Image

Image
User avatar
Gabriel963
Fost moderator
Fost moderator
Posts: 1658
Joined: 03 Feb 2013, 13:03
Detinator Steam: Da
CS Status: Retried
Reputatie: Membru Club eXtreamCS (1 luna)
Fost Moderator
Location: Bucharest, Romania.
Has thanked: 20 times
Been thanked: 85 times
Contact:

28 Nov 2013, 19:15

Mai bine ai trece pe cel a lui askhanar, ii modifici nativele cu cele a lu aragon pentru a merge pe meniul tau de arme. :P
Image
Post Reply

Return to “Cereri”

  • Information