Raised This Month: $32 Target: $400
 8% 

Solved I need help with my plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lnteresting
Junior Member
Join Date: Jan 2019
Old 01-17-2019 , 12:44   I need help with my plugin
Reply With Quote #1

im new to sourcepawn and i tried making a plugin the plugin makes a vote that enables no spread but there are a lot of errors that i dont know how to fix

Code:
HTML Code:
#pragma semicolon 1

#define DEBUG

#define VOTE_NO "###no###"
#define VOTE_YES "###yes###"

#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "0.00"

#include <sourcemod>
#include <sdktools>
#include <adminmenu>

#pragma newdecls required

ConVar g_Cvar_Limits[3] =  { null, ... };

public Plugin myinfo = 
{
	name = "e",
	author = PLUGIN_AUTHOR,
	description = "e",
	version = PLUGIN_VERSION,
	url = "e"
};

public void OnPluginStart()
{
	RegAdminCmd("sm_votenp", Command_VoteNP, ADMFLAG_VOTE);
	
	g_Cvar_Limits[0] = CreateConVar("sm_votenp", "0.40", "percent required for successful map vote.", 0, true, 0.05, true, 1.0);

}
public void OnAdminMenuReady(Handle aTopMenu)
{
	TopMenu topmenu = TopMenu.FromHandle(aTopMenu);
	
	if (topmenu == hTopMenu)
	{
		return;
    }
    
    hTopMenu = topmenu;
    
    TopMenuObject voting_commands = hTopMenu.FindCategory(ADMINMENU_VOTINGCOMMANDS);
    
    if (voting_commands) != INVALID_TOPMENUOBJECT
    {
    	hTopMenu.AddItem("sm_votenp", AdminMenu_VoteNP, voting_commands, "sm_votenp", ADMFLAG_VOTE);
    }
   
}

public int Handle_VoteMenu(Menu menu, MenuAction action, int param1, int param2)
{
	if (action == MenuAction_End)
	{
		delete menu;
    }
}

public void Handle_VoteResults(Menu menu,
                        int num_votes,
                        int num_clients,
                        const int[][] client_info,
                        int num_items
                        const int[][] item_info)
{
	int winner = 0
	if (num_items > 1
	    && (item_info[0][VOTEINFO_ITEM_VOTES] == item_info[1][VOTEINFO_ITEM_VOTES]))
	    {
	    	winner = GetRandomInt(0, 1);
	   }
	   
	   char NoSpread[1]
	   menu.GetItem(item_info[winner][VOTEINFO_ITEM_INDEX], NoSpread, sizeof(NoSpread));
	   ServerCommand("weapon_accuracy_nospread 1")
	  }

void DoVoteMenu(const char[] NoSpread)
{
	if(IsVoteInProgress()
	{
		return;
    }
}

Menu menu = new Menu(Handle_VoteMenu)
menu.VoteResultCallback = Handle_VoteResults;
menu.SetTitle("Enable NoSpread?", NoSpread)
menu.AddItem("yes", "Yes")
menu.AddItem("no" "No")
menu.ExitButton = false;
menu.DisplayVoteToAll(20);
}



Errors:
HTML Code:
// by the SourceMod Dev Team


//// VoteNP.sp
//
// C:\csgoserver\csgo\addons\sourcemod\scripting\include\menus.inc(785) : warning 219: local variable "menu" shadows a variable at a preceding level
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(30) : error 017: undefined symbol "Command_VoteNP"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(39) : error 017: undefined symbol "hTopMenu"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(44) : warning 217: loose indentation
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(44) : error 017: undefined symbol "hTopMenu"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(44) : warning 215: expression has no effect
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(46) : error 017: undefined symbol "hTopMenu"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(46) : warning 213: tag mismatch
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(48) : error 029: invalid expression, assumed zero
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(49) : error 028: invalid subscript (not an array or too many subscripts): "INVALID_TOPMENUOBJECT"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(50) : warning 217: loose indentation
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(50) : error 017: undefined symbol "hTopMenu"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(53) : error 054: unmatched closing brace ("}")
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(55) : warning 219: local variable "menu" shadows a variable at a preceding level
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(63) : warning 219: local variable "menu" shadows a variable at a preceding level
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(68) : error 001: expected token: ")", but found "const"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(68) : error 001: expected token: "{", but found "const"
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(68) : error 001: expected token: "-identifier-", but found "["
// C:\csgoserver\csgo\addons\sourcemod\scripting\VoteNP.sp(68) : fatal error 190: too many error messages on one line
//
// Compilation aborted.
// 12 Errors.
//
// Compilation Time: 0.3 sec
// ----------------------------------------

Press enter to exit ...

Last edited by lnteresting; 01-18-2019 at 11:01.
lnteresting is offline
Brum Brum
Junior Member
Join Date: Mar 2017
Old 01-17-2019 , 16:09   Re: I need help with my plugin
Reply With Quote #2

You closed the DoVoteMenu function too early.
Brum Brum is offline
lnteresting
Junior Member
Join Date: Jan 2019
Old 01-18-2019 , 05:35   Re: I need help with my plugin
Reply With Quote #3

Quote:
Originally Posted by Brum Brum View Post
You closed the DoVoteMenu function too early.
Ok thanks for letting me know but can you tell me what to do?
lnteresting is offline
Cruze
Veteran Member
Join Date: May 2017
Old 01-18-2019 , 07:52   Re: I need help with my plugin
Reply With Quote #4

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>

public Plugin myinfo 
{
    
name "Vote No Spread",
    
author PLUGIN_AUTHOR,
    
description "Voting for No Spread",
    
version PLUGIN_VERSION,
    
url "http://steamcommunity.com/profiles/76561198132924835"
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_votenp"Command_VoteNPADMFLAG_VOTE);
}

public 
int Handle_VoteMenu(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_VoteEnd)
    {
        
/* 0=yes, 1=no */
        
if (param1 == 0)
        {
            
ServerCommand("weapon_accuracy_nospread 1");
        }
    }
}

public 
Action Command_VoteNP(int clientint args)
{
    if(
IsVoteInProgress())
    {
        return 
Plugin_Handled;
    }
    
DoVoteMenu();
    return 
Plugin_Handled;
}

void DoVoteMenu()
{
    
Menu menu = new Menu(Handle_VoteMenu);
    
menu.SetTitle("Enable NoSpread?");
    
menu.AddItem("""Yes");
    
menu.AddItem("""No");
    
menu.ExitButton false;
    
menu.DisplayVoteToAll(20);

__________________
Taking paid private requests! Contact me
Cruze is offline
lnteresting
Junior Member
Join Date: Jan 2019
Old 01-18-2019 , 14:32   Re: I need help with my plugin
Reply With Quote #5

Quote:
Originally Posted by Cruze View Post
PHP Code:
#pragma semicolon 1
#pragma newdecls required

#define PLUGIN_AUTHOR ""
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <sdktools>

public Plugin myinfo 
{
    
name "Vote No Spread",
    
author PLUGIN_AUTHOR,
    
description "Voting for No Spread",
    
version PLUGIN_VERSION,
    
url "http://steamcommunity.com/profiles/76561198132924835"
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_votenp"Command_VoteNPADMFLAG_VOTE);
}

public 
int Handle_VoteMenu(Menu menuMenuAction actionint param1int param2)
{
    if (
action == MenuAction_End)
    {
        
delete menu;
    }
    else if (
action == MenuAction_VoteEnd)
    {
        
/* 0=yes, 1=no */
        
if (param1 == 0)
        {
            
ServerCommand("weapon_accuracy_nospread 1");
        }
    }
}

public 
Action Command_VoteNP(int clientint args)
{
    if(
IsVoteInProgress())
    {
        return 
Plugin_Handled;
    }
    
DoVoteMenu();
    return 
Plugin_Handled;
}

void DoVoteMenu()
{
    
Menu menu = new Menu(Handle_VoteMenu);
    
menu.SetTitle("Enable NoSpread?");
    
menu.AddItem("""Yes");
    
menu.AddItem("""No");
    
menu.ExitButton false;
    
menu.DisplayVoteToAll(20);

Thank you very much!
lnteresting is offline
Reply


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 15:21.


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