Plugin triggering entity Created 10 years ago2013-06-15 19:55:34 UTC by stop! stop!

Created 10 years ago2013-06-15 19:55:34 UTC by stop! stop!

Posted 10 years ago2013-06-15 19:55:34 UTC Post #313987
I'm a beginner at amx scripting and I'd like if somebody could adapt this plugin ( http://forums.alliedmods.net/showthread.php?t=29536&page=2 ) which is awesome btw but does too many : it checks for all func_buttons on the map and lets you choose which one to press...I'd like a simplified version which would only trigger buttond by their names. Example amx_button button1 or amx_button etc.

Thanks in advance
stop! stop!Can't stop mapping
Posted 10 years ago2013-06-16 00:15:10 UTC Post #313989
100% untested!

This plugin should allow you to "use" any entity (for example a button or a hostage) with the command amx_use TARGETNAME where TARGETNAME is the name of the entity.
Example use: amx_use doorbellbtn
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define ADMIN_LEVEL ADMIN_LEVEL_A

public plugin_init() {
	register_plugin("Use Entity", "1.0", "potatis_invalido");
	register_clcmd("amx_use", "cmdUse", ADMIN_LEVEL, "amx_use TARGETNAME");
}

public cmdUse(id, level, cid) {
	if(cmd_access(id, level, id, 1)) {
		new nameArgumentValue[33];
		if(read_argc() != 2 || read_argv(1, nameArgumentValue, (sizeof nameArgumentValue) - 1) < 1) {
			console_print(id, "[amx_use] - Invalid number of arguments.");
		} else {
			new entityId = engfunc(EngFunc_FindEntityByString, -1, "targetname", nameArgumentValue);
			if(!pev_valid(entityId)) {
				console_print(id, "[amx_use] - Entity not found");
			} else {
				console_print(id, "[amx_use] - Using entity with ID number %i", entityId);
				dllfunc(DLLFunc_Use, entityId, id);
			}
		}
	}
	return PLUGIN_HANDLED;
}
I don't have the time to install AMX Mod X right now. I hope it works!
Oskar Potatis Oskar Potatis🦔
Posted 10 years ago2013-06-16 06:16:14 UTC Post #313990
thanks a lot
stop! stop!Can't stop mapping
Posted 10 years ago2013-06-17 06:32:07 UTC Post #313991
I noticed two mistakes. Use this instead:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define ADMIN_LEVEL ADMIN_LEVEL_A

public plugin_init() {
register_plugin("Use Entity", "1.0", "potatis_invalido");
register_clcmd("amx_use", "cmdUse", ADMIN_LEVEL, "TARGETNAME");
}

public cmdUse(id, level, cid) {
if(cmd_access(id, level, cid, 2)) {
new nameArgumentValue[33];
if(read_argc() != 2 || read_argv(1, nameArgumentValue, (sizeof nameArgumentValue) - 1) < 1) {
console_print(id, "[amx_use] - Invalid number of arguments.");
} else {
new entityId = engfunc(EngFunc_FindEntityByString, -1, "targetname", nameArgumentValue);
if(!pev_valid(entityId)) {
console_print(id, "[amx_use] - Entity not found");
} else {
console_print(id, "[amx_use] - Using entity with ID number %i", entityId);
dllfunc(DLLFunc_Use, entityId, id);
}
}
}
return PLUGIN_HANDLED;
}
Oskar Potatis Oskar Potatis🦔
Posted 10 years ago2013-06-21 18:14:33 UTC Post #314014
thanks again hehe
stop! stop!Can't stop mapping
You must be logged in to post a response.