Raised This Month: $ Target: $400
 0% 

Entity Voting


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
ijakings
Junior Member
Join Date: Jun 2006
Old 07-04-2006 , 18:05   Entity Voting
Reply With Quote #1

I have a problem, with combingng both of these plugins.

The first plugin is for using button entities from afar

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
}
The second is a voting plugin pulled from a knivesonly plugin and edited so it looks right for the test use im using it for

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;
}
When i start the vote and voting is successful however the entitiy isnt triggered at all, it correctly reports which option has won and the number of votes but it just doesnt execute the command. Can anyone point out what I have done wrong here?
ijakings is offline
 


Thread Tools
Display Modes

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 08:08.


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