Raised This Month: $ Target: $400
 0% 

Opening doors AMXX 1.9


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Mikka
Member
Join Date: Dec 2018
Old 06-21-2022 , 02:47   Opening doors AMXX 1.9
Reply With Quote #1

Hello everyone, can anybody tell me why the code doesn't work?

Code:
public plugin_init() {
	RegisterHam(Ham_Use, "func_button", "ButtonUse", 1);
}
content of random map file .ini
HTML Code:
-1718.500000 -1102.500000 152.500000 func_button
Code:
public plugin_precache()
{
	new file[128];
	get_mapname(gMap, charsmax(gMap));

	formatex(file[get_localinfo("amxx_configsdir", file, charsmax(file))], charsmax(file), "/cells/%s.ini", gMap);

	if(file_exists(file)) {
		new value[4][32], data[256], iLen;
		for(new i = 0; i < file_size(file, 1); i++) {
			if(i > 1) break;

			read_file(file, i, data, 255, iLen);
			parse(data, value[0], charsmax(value[]), value[1], charsmax(value[]), value[2], charsmax(value[]), value[3], charsmax(value[]));

			new Float:vecOrigin[3];
			vecOrigin[0] = str_to_float(value[0]);
			vecOrigin[1] = str_to_float(value[1]);
			vecOrigin[2] = str_to_float(value[2]);

			new Float:fDistance = 9999.0, Float:fDistance2, iEnt;
			while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", value[3]))) {
				new Float:fOrigin[3], Float:fMin[3], Float:fMax[3];
				pev(iEnt, pev_origin, fOrigin);
				pev(iEnt, pev_mins, fMin);
				pev(iEnt, pev_maxs, fMax);

				fOrigin[0] += (fMin[0] + fMax[0]) * 0.5;
				fOrigin[1] += (fMin[1] + fMax[1]) * 0.5;
				fOrigin[2] += (fMin[2] + fMax[2]) * 0.5;

				if((fDistance2 = vector_distance(fOrigin, vecOrigin)) < fDistance) {
					fDistance = fDistance2;
					g_iButtons[i] = iEnt;
				}
			}
		}
	}
	else
	{
		set_fail_state("Cells bad load");
	}
}
Code:
public ButtonUse(iEnt, id, iActivator) {
	if(!pev_valid(iEnt) || !is_user_alive(id) || id != iActivator || cells) return;
	static i;
	for(i = 0; i < sizeof(g_iButtons); i++) {
		if(!pev_valid(g_iButtons[i]) || !g_iButtons[i] || iEnt != g_iButtons[i]) continue;
		ExecuteHam(Ham_Use, g_iButtons[i], 0, 0, 2, 1.0);
		client_print(0, print_center, "^n^nCells opened: %s", Time);

		cells = true;
	}
}
If i remove the if condition then thats work, but on all buttons.

Code:
if(!pev_valid(g_iButtons[i]) || !g_iButtons[i] || iEnt != g_iButtons[i]) continue;
Mikka is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:21.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode