Raised This Month: $ Target: $400
 0% 

Map Entity Trigger


Post New Thread Reply   
 
Thread Tools Display Modes
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-04-2006 , 03:52   Re: Map Entity Trigger
Reply With Quote #11

Since I don't have the map I can't make it to that button specfic for you. What you do is type amx_findbutton in your client game console when your in the server. It will list you all the func_button on the map. Once you know what the button entid is just type amx_pushbutton entid.

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define ADMIN_LEVEL ADMIN_LEVEL_A

public plugin_init()
{
	register_plugin("Push Buttons", "1.0", "gaben")
	register_clcmd("amx_pushbutton", "cmdPush", ADMIN_LEVEL, "- amx_pushbutton func_button id")
	register_clcmd("amx_findbutton", "cmdFind", ADMIN_LEVEL, "- Display all func_button entity")
}

public cmdFind(id, level, cid)
{
	if(!cmd_access(id, level, cid, 1))
		return PLUGIN_HANDLED

	new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", "func_button");
	new target[32], targetname[32]

	while(ent > 0)
	{
		target[0] = 0
		targetname[0] = 0

		pev(ent, pev_target, targetname, 31)
		pev(ent, pev_target, target, 31)

		console_print(id, "[GABEN] func_button: %i targetname: %s target: %s", ent, targetname, target)
		ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_button");
	}
	return PLUGIN_HANDLED
}

public cmdPush(id, level, cid)
{
	if(!cmd_access(id, level, id, 1))
		return PLUGIN_HANDLED

	new arg[10]
	read_argv(1, arg, 9)

	new entid = str_to_num(arg)

	if(!pev_valid(entid))
	{
		console_print(id, "[GABEN] func_button - Id: %i arg: %s is invalid", entid, arg)
		return PLUGIN_HANDLED
	}

	dllfunc(DLLFunc_Use, entid, id)
	console_print(id, "[GABEN] You have push the button %i", entid)

	return PLUGIN_HANDLED
}
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
ijakings
Junior Member
Join Date: Jun 2006
Old 07-04-2006 , 04:16   Re: Map Entity Trigger
Reply With Quote #12

Thanks so much i shall test this right away
ijakings is offline
ijakings
Junior Member
Join Date: Jun 2006
Old 07-04-2006 , 04:22   Re: Map Entity Trigger
Reply With Quote #13

It works great, now I know how to do that I can add a voting system to it by myself, with your permission ofcourse. The learning curve for us newbie coders is quite steep lol.
ijakings is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-04-2006 , 04:28   Re: Map Entity Trigger
Reply With Quote #14

Do what ever you want with it. Just aleast give credit to gaben.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
ijakings
Junior Member
Join Date: Jun 2006
Old 07-04-2006 , 11:58   Re: Map Entity Trigger
Reply With Quote #15

Ive run into a problem and I dont know what to do from here.

Ive borred some voting code from a knifesonly plugin and The actual voting bit works ok, but it doesnt toggle the light on or off

Ive currently got:
Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

new knifeonly = 0;
new choice[2];
new voteknivesonly[] = "\yToggle Light?\w^n^n1. Yes^n2. No";

public plugin_init () {
	register_plugin ( "Togglevote", "0.1a", "ijakings" );
	register_concmd ( "say /votelighttoggle", "cmdvote", ADMIN_VOTE, "- Begins a vote to enable Knives Only." );
	register_menucmd ( register_menuid("\yToggle Light?"), (1<<0)|(1<<1), "count_votes" );
	register_event ( "CurWeapon", "knife", "b" );
}

public cmdvote ( id ) {
    new Float:voting = get_cvar_float ( "amx_last_voting" );
    if ( voting > get_gametime () ) {
        client_print ( id, print_chat, "*A vote has already been cast.*" );
        return PLUGIN_HANDLED;
    }
    if ( voting && voting + get_cvar_float ( "amx_vote_delay" ) > get_gametime() ) {
        client_print ( id, print_chat, "*Please wait for a short while before you are able to vote again.*" );
        return PLUGIN_HANDLED;
    }
    new menu_msg[256];
    new name[32];
    format ( menu_msg, 255, voteknivesonly );
    new Float:votetime = get_cvar_float("amx_vote_time") + 10.0;
    get_user_info ( id, "name", name, 31 );
    set_cvar_float ( "amx_last_voting", get_gametime() + votetime );
    show_menu ( 0, (1<<0)|(1<<1), menu_msg, floatround ( votetime ) );
    set_hudmessage ( 200, 0, 0, 0.05, 0.65, 2, 0.02, 30.0, 0.03, 0.3, 2 );
		
    show_hudmessage ( 0, "%s has started the Vote for lightoggle", name );
    set_task ( votetime, "check_the_votes" );
    choice[0] = choice[1] = 0;
    return PLUGIN_HANDLED; 
}

public count_votes ( id, key ) {
    if ( get_cvar_float ( "amx_vote_answers" ) ) {
        new name[32];
        get_user_name ( id, name, 31 );
        client_print ( 0, print_chat, "* %s voted %s", name, key ? "against light toggle" : "for light toggle" );
    }
    ++choice[key];
    return PLUGIN_HANDLED;
}

public check_the_votes ( id ) {
    if ( choice[0] > choice[1] ) {
        server_cmd ( "amx_pushbutton 92" );
        client_print ( 0, print_chat, "* Light Toggle has been voted yes. (On ^"%d^") (Off ^"%d^"). *", choice[0], choice[1] );
    } else {
        client_print ( 0, print_chat, "* Light Toggle has been voted no. (On ^"%d^") (Off ^"%d^"). *", choice[0], choice[1] );
    }
    return PLUGIN_CONTINUE;
}
And i cant see why the amx_pushbutton 92 bit isnt working. Its accurately reporting the voting and which won, but its not doing the command.
ijakings is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-05-2006 , 02:35   Re: Map Entity Trigger
Reply With Quote #16

I'm not sure that button will get the same entid every map load. That why I need map file and required files for that map to make a function for you find the entid to that specific button.

Also you can't use server_cmd(" to use the amx_pushbutton. It need to be an actually player to use that command. If you can give me the map I can make it into this function that you can add only to this plugin.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
ijakings
Junior Member
Join Date: Jun 2006
Old 07-05-2006 , 07:58   Re: Map Entity Trigger
Reply With Quote #17

The button has had the same entid all the times ive loaded the map so far. And I can see what you mean about needing it to be a player to use the button.

The map is located at

http://www.danescu.com/cs_militia301.zip

The room with the button is located behind this wall:

[img]http://img221.**************/img221/2122/wall11vh.th.jpg[/img]

And in the room the button is:

[img]http://img213.**************/img213/3311/wall28ic.th.jpg[/img]
ijakings is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 07-05-2006 , 14:05   Re: Map Entity Trigger
Reply With Quote #18

Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

new choice[2];
new voteknivesonly[] = "\yToggle Light?\w^n^n1. Yes^n2. No";
new militia_button_id

public plugin_init () {
	register_plugin ( "Togglevote", "0.1a", "ijakings" );
	register_concmd ( "say /votelighttoggle", "cmdvote", ADMIN_VOTE, "- Begins a vote to enable Knives Only." );
	register_menucmd ( register_menuid("\yToggle Light?"), (1<<0)|(1<<1), "count_votes" );

	militia_button_id = find_militia_button()
}

public cmdvote ( id ) {
    if(militia_button_id)
    {
	    new Float:voting = get_cvar_float ( "amx_last_voting" );
	    if ( voting > get_gametime () ) {
	        client_print ( id, print_chat, "*A vote has already been cast.*" );
	        return PLUGIN_HANDLED;
	    }
	    if ( voting && voting + get_cvar_float ( "amx_vote_delay" ) > get_gametime() ) {
	        client_print ( id, print_chat, "*Please wait for a short while before you are able to vote again.*" );
	        return PLUGIN_HANDLED;
	    }
	    new menu_msg[256];
	    new name[32];
	    format ( menu_msg, 255, voteknivesonly );
	    new Float:votetime = get_cvar_float("amx_vote_time") + 10.0;
	    get_user_info ( id, "name", name, 31 );
	    set_cvar_float ( "amx_last_voting", get_gametime() + votetime );
	    show_menu ( 0, (1<<0)|(1<<1), menu_msg, floatround ( votetime ) );
	    set_hudmessage ( 200, 0, 0, 0.05, 0.65, 2, 0.02, 30.0, 0.03, 0.3, 2 );

	    show_hudmessage ( 0, "%s has started the Vote for lightoggle", name );
	    set_task ( votetime, "check_the_votes", id); // Pass the vote caller id to use.
	    choice[0] = choice[1] = 0;
    }
    else
    {
	    client_print(id, print_chat, "No valid buttons found.")
    }
    return PLUGIN_HANDLED;
}

public count_votes ( id, key ) {
    if ( get_cvar_float ( "amx_vote_answers" ) ) {
        new name[32];
        get_user_name ( id, name, 31 );
        client_print ( 0, print_chat, "* %s voted %s", name, key ? "against light toggle" : "for light toggle" );
    }
    ++choice[key];
    return PLUGIN_HANDLED;
}

public check_the_votes ( id )
{
	if ( choice[0] > choice[1] )
	{
		if(pev_valid(militia_button_id))
		{
			dllfunc(DLLFunc_Use, militia_button_id, id)
			client_print ( 0, print_chat, "* Light Toggle has been voted yes. (On ^"%d^") (Off ^"%d^"). *", choice[0], choice[1] );
		}
		else
		{
			client_print(id, print_chat, "No valid buttons found.")
		}
	} else {
		client_print ( 0, print_chat, "* Light Toggle has been voted no. (On ^"%d^") (Off ^"%d^"). *", choice[0], choice[1] );
	}
	return PLUGIN_CONTINUE;
}

find_militia_button()
{
	new ent = engfunc(EngFunc_FindEntityByString, -1, "classname", "func_button");
	new target[32]

	while(ent > 0)
	{
		pev(ent, pev_target, target, 31)

		if(equal(target, "24_m"))
			return ent

		ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_button");
	}
	return 0
}
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
ijakings
Junior Member
Join Date: Jun 2006
Old 07-06-2006 , 07:39   Re: Map Entity Trigger
Reply With Quote #19

Thanks it works great.
ijakings is offline
Reply



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 09:22.


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