Page 1 of 1

Problema plugin VIP

Posted: 14 Mar 2018, 19:23
by JustiNNN
Buna seara. Am o problema la un plugin de vip. Il urc in ftp , iar cand schimb mapa pica sv + ca da eroare in logs.... Ma puteti ajuta?
Sursa plugin
| Afiseaza codul
#include <amxmodx>

#include <amxmisc>

#include <hamsandwich>

#include <engine>

#include <cstrike>

#include <fun>

#include <fakemeta>

#include <sqlx>



#define PLUGIN_NAME "VIP System"

#define PLUGIN_VERSION "1.0"

#define PLUGIN_AUTHOR "YONTU"





#define Host "db.tni.ro"

#define User "hdhs"

#define Pass "idontknow"

#define Db "djjdnd"





#define VIP_FLAG "a"



new Handle:g_SqlTuple;

new g_Error[512];



new bool: is_user_vip[33];



new const TAG[] = "[GAMESCS - VIP]", CONTACT[] = "ADRESA TA";



#define START_HOUR 23

#define STOP_HOUR 10

#define is_user_vip(%1) (get_user_flags(%1) & VIP_FLAG)

#define is_user_valid(%1) (1 <= %1 <= max_players)



enum cvars

{

ap_spawn = 0,

show_vip_tab,

money_kill,

money_hs,

hp_kill,

hp_hs,

max_hp_kill,

show_bullet_dmg,

multi_jump

}



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 cvar[cvars];

new max_players;

new bool:g_bJump[33] = false, g_JumpNum[33] = 0;

new g_iPlayerPos[33], g_iPlayerCol[33];

new rounds = 0;



// NU SCHIMBA

new const Float:g_flCoords[][] = 

{

{0.50, 0.40},

{0.56, 0.44},

{0.60, 0.50},

{0.56, 0.56},

{0.50, 0.60},

{0.44, 0.56},

{0.40, 0.50},

{0.44, 0.44}

}



// NU SCHIMBA VALORILE DEJA EXISTENTE. Poti adauga mai multe culori, respectand matricea

new const g_iColors[][] =

{

{0, 127, 255}, // blue

{255, 127, 0}, // orange

{127, 0, 255}, // purple

{255, 0, 0}, // red

{255, 100, 150}, // pink

{0, 255, 0} // green

}



public plugin_init()

{

register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);

register_cvar("vip_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);

set_cvar_string("vip_", PLUGIN_VERSION);



register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");

register_event("DeathMsg", "event_DeathMsg", "a");

register_event("Damage", "event_Damage", "b", "2>0", "3=0");

register_event("TextMsg", "event_textmsg", "a", "2=#Game_will_restart_in")



RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawnPost", 1);



register_message(get_user_msgid("ScoreAttrib"), "msg_ScoreAttrib");





register_clcmd("say /skslssevips", "CmdVipsOnline");

register_clcmd("say_team /skslssevips", "CmdVipsOnline");

register_clcmd("say vips", "CmdVipsOnline");

register_clcmd("say_team vips", "CmdVipsOnline");



register_clcmd("say vip", "CmdPrintAttributes");

register_clcmd("say_team vip", "CmdPrintAttributes");

register_clcmd("say /skslssevip", "CmdPrintAttributes");

register_clcmd("say_team /skslssevip", "CmdPrintAttributes");



cvar[ap_spawn] = register_cvar("vip_ap_spawn", "100"); // 0 = dezactivat

cvar[show_vip_tab] = register_cvar("vip_show_tab", "1"); // 0 = dezactivat

cvar[hp_kill] = register_cvar("vip_receive_hp_kill", "10"); // 0 = dezactivat

cvar[hp_hs] = register_cvar("vip_receive_hp_hs", "15"); // 0 = dezactivat

cvar[money_kill] = register_cvar("vip_receive_money_kill", "250"); // 0 = dezactivat

cvar[money_hs] = register_cvar("vip_receive_money_hs", "500"); // 0 = dezactivat

cvar[max_hp_kill] = register_cvar("vip_receive_max_hp_kill", "100"); // valoarea maxima de hp pe care o poti obtine facand killuri

cvar[show_bullet_dmg] = register_cvar("vip_show_bullet_dmg", "1"); // 0 = dezactivat

cvar[multi_jump] = register_cvar("vip_multijump", "1"); // 0 = dezactivat. Daca valoarea cvar-ului este 1, vei sari de 2 ori. Orice valoare pui, va fi +1 jump



check_time()

set_task(30.0,"check_time",0,"",0,"b",0);

max_players = get_maxplayers();



// -- || MySql Config || -- //

g_SqlTuple = SQL_MakeDbTuple(Host,User,Pass,Db);



new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511);

if(SqlConnection == Empty_Handle)

set_fail_state(g_Error);



new Handle:Queries;

Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS test (name VARCHAR(100),data DATE)");





if(!SQL_Execute(Queries))

{

SQL_QueryError(Queries,g_Error,511);

set_fail_state(g_Error);

}

SQL_FreeHandle(Queries);



SQL_FreeHandle(SqlConnection);

// -- || End MySql Config || -- //



}



//public client_connect(id) Load();



public client_disconnect(id)

{

is_user_vip[id] = false;

if(is_user_vip[id])

{

new name1[32];

get_user_name(id, name1, charsmax(name1));

ColorChat(0, "!4%s!1 VIP-ul!3 %s!1 s-a deconectat de pe server.", TAG, name1);

}

}

public check_time()

{

new iPlayers[32], iPlayersNum, o;

time(o, _, _);

get_players(iPlayers, iPlayersNum)

if(o >= START_HOUR || o <= STOP_HOUR)

{

for(new i = 0; i < iPlayersNum; i++)

{

	if(is_user_connected(iPlayers) && !is_user_vip[iPlayers])

		is_user_vip[iPlayers] = true;

	}

}

else

{

	for(new i = 0; i < iPlayersNum; i++)

	{

		if(is_user_connected(iPlayers) && (is_user_vip[iPlayers]))

			is_user_vip[iPlayers] = false;

			Load();

		}

	}

}



public client_putinserver(id)

{

	is_user_vip[id] = false;

	if(is_user_vip[id])

	{

		new name1[32];

		get_user_name(id, name1, charsmax(name1));

		ColorChat(0, "!4%s!1 VIP-ul!3 %s!1 s-a conectat pe server.", TAG, name1);

		client_cmd(0, "spk vox/buzwarn");

	}

}

public CmdVipsOnline(id)

{

	if(!is_user_connected(id))

		return PLUGIN_CONTINUE;

	

	new adminnames[33][32], message[256], i, count, len;

	len = format(message, charsmax(message), "!3%s!1 Vips Online: ", TAG);

	for(i = 1 ; i <= max_players; i++)

	{

		if(is_user_connected(i) && is_user_vip)

			get_user_name(i, adminnames[count++], charsmax(adminnames[]));

	}

	

	if(count > 0)

	{

		for(i = 0; i < count; i++)

		{

			len += format(message[len], 255 -len, "!4%s!1%s ", adminnames, i < (count -1) ? ", " : ".");

			if(len > 96) ColorChat(0, message);

		}

		ColorChat(0, message);

	}

	else

	{

		len += format(message[len], 255 -len, "!4No one !")

		ColorChat(0, message);

	}

	

	return PLUGIN_CONTINUE;

}



public ShowVipMenu(id)

{

	if(!is_user_connected(id))

		return PLUGIN_HANDLED;

	

	if(!is_user_vip[id])

	{

		ColorChat(id, "!4%s!1 Imi pare rau, dar nu ai acces la meniul pentru!3 membrii VIP!1.", TAG);

		ColorChat(id, "!4%s!1 Poti cumpara VIP, contactand adresa Y!M:!3 %s!1.", TAG, CONTACT);

		return PLUGIN_HANDLED;

	}

	

	new menu, text_menu[64];

	formatex(text_menu, charsmax(text_menu), "\r%s\w Meniu VIP", TAG);

	menu = menu_create(text_menu, "VipMenuHandler");

	

	menu_additem(menu, "M4A1 + Echipament", "1");

	menu_additem(menu, "AK-47 + Echipament", "2");

	menu_additem(menu, "AWP + Echipament", "3");

	

	menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);

	menu_display(id, menu, 0);

	

	return PLUGIN_CONTINUE;

}



public VipMenuHandler(id, menu, item)

{

	if(!is_user_connected(id) || item == MENU_EXIT)

	{

		menu_destroy(menu);

		return PLUGIN_HANDLED;

	}

	

	new szWeapons[32], iNum, i;

	get_user_weapons(id, szWeapons, iNum);

	

	new data[6], namei[64], access, CallBack;

	menu_item_getinfo(menu, item, access, data, charsmax(data), namei, charsmax(namei), CallBack);

	new key = str_to_num(data);

	

	switch(key)

	{

		case 1:

		{

			for(i = 0; i < iNum; i++)

			{

				if(PRIMARY_WEAPONS_BIT_SUM & (1<<szWeapons))

				{

					new weaponname[32];

					get_weaponname(szWeapons, weaponname, charsmax(weaponname));

					bacon_strip_weapon(id, weaponname);

				}

			}

			

			give_item(id, "weapon_m4a1");

			cs_set_user_bpammo(id, CSW_M4A1, 90);

			

			ColorChat(id, "!4%s!1 Ai ales!3 M4A1!1 +!3 Deagle!1 +!3 Set grenade!1 (!31 HE!1 + !32 FB!1).", TAG);

		}

		

		case 2:

		{

			for(i = 0; i < iNum; i++)

			{

				if(PRIMARY_WEAPONS_BIT_SUM & (1<<szWeapons[i]))

				{

					new weaponname[32];

					get_weaponname(szWeapons[i], weaponname, charsmax(weaponname));

					bacon_strip_weapon(id, weaponname);

				}

			}
			

			give_item(id, "weapon_ak47");

			cs_set_user_bpammo(id, CSW_AK47, 90);

			

			ColorChat(id, "!4%s!1 Ai ales!3 AK47!1 +!3 Deagle!1 +!3 Set grenade!1 (!31 HE!1 + !32 FB!1).", TAG);

		}

		

		case 3:

		{

			for(i = 0; i < iNum; i++)

			{

				if(PRIMARY_WEAPONS_BIT_SUM & (1<<szWeapons[i]))

				{

					new weaponname[32];

					get_weaponname(szWeapons[i], weaponname, charsmax(weaponname));

					bacon_strip_weapon(id, weaponname);

				}

			}

			

			give_item(id, "weapon_awp");

			cs_set_user_bpammo(id, CSW_AWP, 30);

			

			ColorChat(id, "!4%s!1 Ai ales!3 AWP!1 +!3 Deagle!1 +!3 Set grenade!1 (!31 HE!1 + !32 FB!1).", TAG);

		}

	}

	

	menu_destroy(menu);

	return PLUGIN_HANDLED;

}



public client_PreThink(id)

{

	new jump_num = get_pcvar_num(cvar[multi_jump]);

	if(!jump_num)

		return PLUGIN_CONTINUE;

	

	if(is_user_alive(id) && !is_user_vip[id])

		return PLUGIN_CONTINUE;

	

	new nbut = get_user_button(id);

	new obut = get_user_oldbutton(id);

	

	if((nbut & IN_JUMP) && !(get_entity_flags(id) & FL_ONGROUND) && !(obut & IN_JUMP))

	{

		if(g_JumpNum[id] < jump_num)

		{

			g_bJump[id] = true;

			g_JumpNum[id]++;

			return PLUGIN_CONTINUE;

		}

	}

	

	if((nbut & IN_JUMP) && (get_entity_flags(id) & FL_ONGROUND))

	{

		g_JumpNum[id] = 0;

		return PLUGIN_CONTINUE;

	}

	

	return PLUGIN_CONTINUE;

}



public client_PostThink(id)

{

	new jump_num = get_pcvar_num(cvar[multi_jump]);

	if(!jump_num)

		return PLUGIN_CONTINUE;

	

	if(is_user_alive(id) && !is_user_vip[id])

		return PLUGIN_CONTINUE;

	

	if(g_bJump[id])

	{

		new Float:fVelocity[3];

		entity_get_vector(id, EV_VEC_velocity, fVelocity);

		fVelocity[2] = random_float(265.0, 285.0);

		entity_set_vector(id, EV_VEC_velocity, fVelocity);

		

		g_bJump[id] = false;

		return PLUGIN_CONTINUE;

	}

	

	return PLUGIN_CONTINUE;

}



public event_NewRound()

{

	rounds++;

}



public event_DeathMsg()

{

	new killer = read_data(1);

	new victim = read_data(2);

	new headshot = read_data(3);

	new hp = headshot ? get_pcvar_num(cvar[hp_hs]) : get_pcvar_num(cvar[hp_kill]);

	new money = headshot ? get_pcvar_num(cvar[money_hs]) : get_pcvar_num(cvar[money_kill]);

	

	if(is_user_alive(killer) && is_user_vip[killer])

	{

		if(killer == victim) return PLUGIN_HANDLED;

		if(hp != 0) set_user_health(killer, clamp(get_user_health(killer) + hp, 1, get_pcvar_num(cvar[max_hp_kill])));

		if(money != 0) cs_set_user_money(killer, clamp(cs_get_user_money(killer) + money - 300, 1, 16000));

		

		set_hudmessage(0, 255, 0, -1.0, 0.15, 0, 1.0, 1.0, 0.1, 0.1, -1)

		show_hudmessage(killer, "Healed +%d HP", hp);

		

		message_begin(MSG_ONE, get_user_msgid("ScreenFade"), _, killer);

		write_short(1<<10);

		write_short(1<<10);

		write_short(0x0000);

		write_byte(0);

		write_byte(0);

		write_byte(200);

		write_byte(75);

		message_end();

	}

	

	return PLUGIN_CONTINUE;

}



public event_Damage(victim)

{

	if(!get_pcvar_num(cvar[show_bullet_dmg]))

		return PLUGIN_CONTINUE;

	

	new id = get_user_attacker(victim);

	if(is_user_valid(id))

	{

		if(is_user_alive(id) && !is_user_vip[id])

			return PLUGIN_HANDLED;

		

		if(read_data(4) || read_data(5) || read_data(6))

		{ 

			new iPos = ++g_iPlayerPos[id];

			if(iPos == sizeof(g_flCoords))

				iPos = g_iPlayerPos[id] = 0;

			

			new iCol = ++g_iPlayerCol[id];

			if(iCol == sizeof(g_iColors))

				iCol = g_iPlayerCol[id] = 0;

			

			set_hudmessage(g_iColors[iCol][0], g_iColors[iCol][1], g_iColors[iCol][2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1);

			show_hudmessage(id, "%d", read_data(2));

		}

	}

	

	return PLUGIN_CONTINUE;

}



public event_textmsg()

{

	rounds = 0;

}



public fw_PlayerSpawnPost(id)

{

	Load();

	if(is_user_vip[id] && is_user_alive(id))

	{

		set_task(1.5, "give_items", id + 212);

		return HAM_IGNORED;

	}

	return HAM_IGNORED;

}





public give_items(taskid)

{

	new id = taskid - 212;

	if(!is_user_alive(id))

		return;

	

	if(get_pcvar_num(cvar[ap_spawn]) != 0) cs_set_user_armor(id, get_pcvar_num(cvar[ap_spawn]), CS_ARMOR_VESTHELM);

	if(cs_get_user_team(id) == CS_TEAM_CT) cs_set_user_defuse(id);

	

	give_item(id, "weapon_deagle");

	cs_set_user_bpammo(id, CSW_DEAGLE, 35);

	

	give_item(id, "weapon_hegrenade");

	give_item(id, "weapon_flashbang");

	cs_set_user_bpammo(id, CSW_FLASHBANG, 2);

	

	if(rounds >= 3) ShowVipMenu(id);

}



public Load()

{ 

	new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)

	if(SqlConnection == Empty_Handle)

		set_fail_state(g_Error);

	

	new Handle:Query = SQL_PrepareQuery(SqlConnection,"SELECT * FROM `test` WHERE `data` >= CURRENT_DATE");

	

	if( !SQL_Execute(Query) )

	{

		SQL_QueryError(Query,g_Error,511);

		log_amx("[ZM VIP] SQL error: can't load VIPs: '%s'", g_Error);

		set_fail_state(g_Error);

	}

	else if (!SQL_NumResults(Query))

	{

		log_amx("[ZM VIP] Empty table!" )

	}

	else

	{

		new qcolName = SQL_FieldNameToNum(Query, "name");

		

		

		new Name[44];

		

		

		

		while (SQL_MoreResults(Query))

		{

			Name[0] = EOS;

			

			SQL_ReadResult(Query, qcolName, Name, sizeof(Name)-1);

			

			new iMaxPlayers = get_maxplayers( );

			

			for( new id = 1; id <= iMaxPlayers; id++ ) {

				new szName[33];

				get_user_name(id, szName, 32);

				if(!is_user_vip[id]) {

					if(equali(Name, szName)) {

						is_user_vip[id] = true;

					}

					else

					{

						is_user_vip[id] = false;

					}

				}

			}

			SQL_NextRow(Query)

		}

	}

	

	SQL_FreeHandle(Query);

	SQL_FreeHandle(SqlConnection);

}

public msg_ScoreAttrib(msgid, dest, id)

{

	if(!get_pcvar_num(cvar[show_vip_tab]))

		return PLUGIN_CONTINUE;

	

	new id = get_msg_arg_int(1);

	if(is_user_connected(id) && is_user_vip[id])

		set_msg_arg_int(2, ARG_BYTE, is_user_alive(id) ? (1<<2) : (1<<0));

	

	return PLUGIN_CONTINUE;

}



public CmdPrintAttributes(id)

{

	if(!is_user_connected(id)) return;

	show_motd(id, "vip.txt", "Beneficii VIP");

}



stock bacon_strip_weapon(index, weapon[])

{

	if(!equal(weapon, "weapon_", 7))

		return PLUGIN_CONTINUE;

	

	static weaponid;

	weaponid = get_weaponid(weapon)

	

	if(!weaponid)

		return PLUGIN_CONTINUE;

	

	static weaponent;

	weaponent = fm_find_ent_by_owner(-1, weapon, index);

	

	if(!weaponent)

		return PLUGIN_CONTINUE;

	

	if(get_user_weapon(index) == weaponid)

		ExecuteHamB(Ham_Weapon_RetireWeapon, weaponent);

	

	if(!ExecuteHamB(Ham_RemovePlayerItem, index, weaponent))

		return PLUGIN_CONTINUE;

	

	ExecuteHamB(Ham_Item_Kill, weaponent);

	set_pev(index, pev_weapons, pev(index, pev_weapons) & ~(1<<weaponid));

	

	return PLUGIN_HANDLED;

}



stock fm_find_ent_by_owner(id, const szClassName[], iOwner, jghgtype = 0)

{

	new str_type[11] = "classname", iEnt = id;

	

	switch(jghgtype) {

		

		case 1: str_type = "target";

			case 2: str_type = "targetname";

		}

	

	while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, str_type, szClassName)) && pev(iEnt, pev_owner) != iOwner) { }

	return iEnt;

}

public plugin_end(){

	SQL_FreeHandle(g_SqlTuple);

}

stock ColorChat(id, String[], any:...)

{

	static szMesage[192];

	vformat(szMesage, charsmax(szMesage), String, 3);

	

	replace_all(szMesage, charsmax(szMesage), "!1", "^1");

	replace_all(szMesage, charsmax(szMesage), "!3", "^3");

	replace_all(szMesage, charsmax(szMesage), "!4", "^4");

	

	static g_msg_SayText = 0;

	if(!g_msg_SayText)

		g_msg_SayText = get_user_msgid("SayText");

	

	new Players[32], iNum = 1, i;

	

	if(id) Players[0] = id;

	else get_players(Players, iNum, "ch");

	

	for(--iNum; iNum >= 0; iNum--)

	{

		i = Players[iNum];

		

		message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);

		write_byte(i);

		write_string(szMesage);

		message_end();

	}

}

Re: Problema plugin VIP

Posted: 15 Mar 2018, 18:45
by A k c 3 n 7
posteaza erorile dupa ce pica

Re: Problema plugin VIP

Posted: 15 Mar 2018, 18:47
by JustiNNN
asta imi da in logs :
[sursa] 02/22/2018 - 19:47:52: [AMXX] Run time error 1 (plugin "nordvip.amxx") - forced exit
L 02/22/2018 - 20:36:24: Start of error session.
L 02/22/2018 - 20:36:24: Info (map "de_dust2") (file "addons/amxmodx/logs/error_20180222.log")
[/sursa]

Re: Problema plugin VIP

Posted: 15 Mar 2018, 22:35
by *Or!g!naL*
Asta e pluginul facut de mine pentru forward, punel primul in lista

Re: Problema plugin VIP

Posted: 15 Mar 2018, 22:36
by A k c 3 n 7
cum de tine ma cand e facut de YONTU?

Re: Problema plugin VIP

Posted: 15 Mar 2018, 22:40
by *Or!g!naL*
trecerea pe mysql :))

Re: Problema plugin VIP

Posted: 16 Mar 2018, 09:34
by JustiNNN
Deci trebuie primul in lista . Revin cu un edit daca merge.

Re: Problema plugin VIP

Posted: 17 Mar 2018, 06:51
by Laurentiu P.
Vezi ca ai sqlx activat in plugin ... folosesti vreo baza de date ?

Re: Problema plugin VIP

Posted: 19 Mar 2018, 16:22
by JustiNNN
As dori , daca se poate sa mi scoateti mysql daca se poate....