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

Help In My First Plugin (Alot Of Error Messages)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GetRektByNoob
Member
Join Date: Nov 2018
Old 11-12-2018 , 13:42   Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #1

ok so i requested a plugin on the forums but no one answered me so i tried to create it my self and i didnt wrote something but like expexted it not working and i wounderd can someone help me fix it or explane to me why its not working...

this is the post where is requested : https://forums.alliedmods.net/showthread.php?t=311806
this code in here is supposed to be only the /startnp command
can someone help me please and explane to my why its not working...

My Code :
Code:
#include <sourcemod>

public Public:myinfo = 
{
	name = "Vote No Spread",
	autour = "GetRektByNoob",
	description = " No Spread Plugin",
	url = ""
};

public OnPluginStart()
{
	new servername = "Gamers-Il";
	RegAdminCmd("sm_startnp", start_no_spread , ADMFLAG_SLAY, " Start Vote No Spread Plugin")
	new bool:StopAction = false;
	
	int yes = 0;
	int no = 0;
	int total = 0;
	int percintage = 0;
}

public Action:start_no_spread(client)
{	
	if (!StopAction)
	{
		Menu start = new Menu(Handle_VoteMenu);
		start.SetTitle("Enable No Spread");
		start.AddItem("yes", "Yes");
		start.AddItem("no", "No");
		start.ExitButton = false;
		start.DisplayVoteToAll(20);
		
		yes = 0;
		no = 0;
		total = 0;
		percintage =0
		
		return Plugin_Handled;
	}
	
	else
	{
	PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.",servername);
	return Plugin_Handled;
	}
}

public int Handle_VoteMenu(Menu menu, MenuAction action, int param1, int param2)
{
	if (action == MenuAction_Select)
	{
		if (prama2 == 1)
		{
			yes++;
			total++;
		}
		
		else
		{			
			no++;
			total++;
		}
	}
	
	if (action == MenuAction_End)
	{
		percintage = (yes / total) * 100; 
		if (percintage >= 60)
		PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 Enabled\0x07ffffff.",servername);

		else
		PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 D\0x07ffffff.",servername);	
		
		delete start;
	}
}

Error Messages :
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// VoteNoSpread.sp
//
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\include\menus.inc(370) : warning 219: local variable "total" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(4 -- 5) : error 017: undefined symbol "name"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(9) : error 010: invalid function or declaration
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(13) : warning 219: local variable "servername" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(13) : error 033: array must be indexed (variable "-unknown-")
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(14) : error 100: function prototypes do not match
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(15) : warning 219: local variable "StopAction" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(17) : warning 219: local variable "yes" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(18) : warning 219: local variable "no" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(19) : warning 219: local variable "total" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(20) : warning 219: local variable "percintage" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(20) : warning 204: symbol is assigned a value that is never used: "percintage"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(19) : warning 204: symbol is assigned a value that is never used: "total"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(18) : warning 204: symbol is assigned a value that is never used: "no"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(17) : warning 204: symbol is assigned a value that is never used: "yes"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(15) : warning 204: symbol is assigned a value that is never used: "StopAction"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(13) : warning 204: symbol is assigned a value that is never used: "servername"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(25) : error 017: undefined symbol "StopAction"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(27) : warning 219: local variable "start" shadows a variable at a preceding level
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(34) : error 017: undefined symbol "yes"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(34) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(35) : error 017: undefined symbol "no"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(35) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(36) : error 017: undefined symbol "total"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(36) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(37) : error 017: undefined symbol "percintage"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(37 -- 39) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(44) : error 017: undefined symbol "servername"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(53) : error 017: undefined symbol "prama2"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(55) : error 017: undefined symbol "yes"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(55) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(56) : error 017: undefined symbol "total"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(56) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(61) : error 017: undefined symbol "no"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(61) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(62) : error 017: undefined symbol "total"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(62) : warning 215: expression has no effect
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(68) : error 017: undefined symbol "percintage"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(68) : error 017: undefined symbol "yes"
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(68) : error 130: cannot coerce functions to values
// C:\Users\USER\Desktop\New folder (2)\addons\sourcemod\scripting\VoteNoSpread.sp(68) : fatal error 190: too many error messages on one line
//
// Compilation aborted.
// 19 Errors.
//
// Compilation Time: 0.19 sec
// ----------------------------------------

Press enter to exit ...
NOTE : this is my first plugin ever and i know there is alot of fucking error messages
GetRektByNoob is offline
NWayne
Junior Member
Join Date: Aug 2017
Location: Warsaw, Europe
Old 11-12-2018 , 15:56   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #2

Brov, so at the first point you have to decide which syntax you'd like to use.
I just made it for you in the new one.

It is compiling now, but i don't give a f*ck it will work.(only guess).

Code:
#define servername "Gamers-Il"

int yes = 0;
int no = 0;
int total = 0;
int percintage = 0;

bool StopAction;
public void OnPluginStart()
{

	RegAdminCmd("sm_startnp", start_no_spread, ADMFLAG_BAN);
	StopAction = false;
}

public Action start_no_spread(int client, int args)
{	
	if (!StopAction)
	{
		Menu menu = new Menu(Handle_VoteMenu);
		menu.SetTitle("Enable No Spread");
		menu.AddItem("yes", "Yes");
		menu.AddItem("no", "No");
		menu.ExitButton = false;
		menu.DisplayVoteToAll(20);
		
		yes = 0;
		no = 0;
		total = 0;
		percintage = 0;
		
		return Plugin_Handled;
	}
	else
	{
		PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.", servername);
		return Plugin_Handled;
	}
}

public int Handle_VoteMenu(Menu menu, MenuAction action, int client, int item)
{
	switch(action)
	{
		case MenuAction_Select:
		{
			switch(item)
			{
				case 0:
				{
					yes++;
					total++;
				}
				case 1:
				{
					no++;
					total++;
				}
			}
		}		
		case MenuAction_End:
		{
			percintage = yes / total * 100; 
			if (percintage >= 60) {	
				PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 Enabled\0x07ffffff.", servername);
			}
			else {
				PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 D\0x07ffffff.", servername);	
			}
			delete menu;
		}			
	}
}
Just don't give up, we'll help you

Last edited by NWayne; 11-12-2018 at 15:58.
NWayne is offline
Whai
Senior Member
Join Date: Jul 2018
Old 11-12-2018 , 16:28   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #3

I'm going to try to explain you part by part (heh my english is very bad so you can don't understand) (it's not rare for me to getting wrong, so I can be wrong) :

First :

You mixed old synthax and new synthax (int = new synthax) (public Action:start_no_spread(client) = old synthax and public Action start_no_spread(int client) = new synthax)

Second :

Code:
#include <sourcemod>

public Public:myinfo = 
{
	name = "Vote No Spread",
	autour = "GetRektByNoob",
	description = " No Spread Plugin",
	url = ""
};
Some typo, it should be :

Code:
#include <sourcemod>

#define PLUGIN_VERSION "1.0" //for the plugin version

public Plugin:myinfo = //It's not public "Public" but "Plugin" and please choose between old or new synthax ( public Plugin myinfo = { } )
{
	name = "Vote No Spread", //That's good, the error come from the line above
	author = "GetRektByNoob", //Typo, it's not autour but author
	description = " No Spread Plugin", //That's good
	version = PLUGIN_VERSION, //You forgot the plugin version
	url = "" //That's good
};
Third :

Code:
public OnPluginStart()
{
	new servername = "Gamers-Il";
	RegAdminCmd("sm_startnp", start_no_spread , ADMFLAG_SLAY, " Start Vote No Spread Plugin")
	new bool:StopAction = false;
	
	int yes = 0;
	int no = 0;
	int total = 0;
	int percintage = 0;
}
some errors :

Code:
//don't do that on "OnPluginStart", just do like this
new bool:StopAction = false; //it can be "bool StopAction = false;"

int yes = 0;
int no = 0;
int total = 0;
int percintage = 0; //Shouldn't be percentage ?

public OnPluginStart() //You can do "public void OnPluginStart()" for the new synthax
{
	new servername = "Gamers-Il"; //???? new and int ??? also Integer = for number, not for letters just remove this

	RegAdminCmd("sm_startnp", start_no_spread , ADMFLAG_SLAY, " Start Vote No Spread Plugin") // that's good
}
now it should look like this for the moment :

Code:
#pragma semicolon 1 //Userful

#include <sourcemod> 

#pragma newdecls required //this is for new synthax. Note : always after include files

#define PLUGIN_VERSION "1.0" //for the plugin version 
#define servername "Gamers-Il" //for your thing that come from "new servername = "Gamers-Il""

public Plugin myinfo =
{ 
    name = "Vote No Spread",
    author = "GetRektByNoob", 
    description = " No Spread Plugin",
    version = PLUGIN_VERSION,
    url = ""
}; 

bool StopAction = false;

int yes = 0; 
int no = 0; 
int total = 0; 
int percentage = 0; 

public void OnPluginStart()
{ 
    RegAdminCmd("sm_startnp", start_no_spread , ADMFLAG_SLAY, " Start Vote No Spread Plugin") 
}
Fourth :

Code:
public Action:start_no_spread(client)
{	
	if (!StopAction)
	{
		Menu start = new Menu(Handle_VoteMenu);
		start.SetTitle("Enable No Spread");
		start.AddItem("yes", "Yes");
		start.AddItem("no", "No");
		start.ExitButton = false;
		start.DisplayVoteToAll(20);
		
		yes = 0;
		no = 0;
		total = 0;
		percintage = 0;
		
		return Plugin_Handled;
	}
	
	else
	{
	PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.",servername);
	return Plugin_Handled;
	}
}
errors :

Code:
public Action:start_no_spread(client, args) //You forgot args. New synthax = public Action start_no_spread(int client, int args) 
{	
	if (!StopAction) //Heh it's useless because StopAction is always false, you didn't make StopAction set true; when the menu start
	{
		Menu start = new Menu(Handle_VoteMenu); //that's good, note : "new" for this line is not an old synthax, so you can still use it
		start.SetTitle("Enable No Spread"); //good
		start.AddItem("yes", "Yes");//Good
		start.AddItem("no", "No");//Good
		start.ExitButton = false;//Good
		start.DisplayVoteToAll(20);//I have no experiences about vote menu so I can't tell if it's true or false, so ask someone else. But it seems good because I saw it on menu.inc

		yes = 0;
		no = 0;
		total = 0;
		percentage =0

		return Plugin_Handled; //Remove this, useless
	}
	
	else
	{
	PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.",servername);
	return Plugin_Handled;
	}
	return Plugin_Handled; //You forgot this, it's very important because if you don"t do that, when you run the command, it will run but it will also send you "Unknow command : sm_startnp"
}
now the code should look like this :

Code:
#pragma semicolon 1

#include <sourcemod> 

#pragma newdecls required

#define PLUGIN_VERSION "1.0"
#define servername "Gamers-Il"

public Plugin myinfo =
{ 
    name = "Vote No Spread",
    author = "GetRektByNoob", 
    description = " No Spread Plugin",
    version = PLUGIN_VERSION,
    url = ""
}; 

bool StopAction = false;

int yes = 0; 
int no = 0; 
int total = 0; 
int percentage = 0; 

public void OnPluginStart()
{ 
    RegAdminCmd("sm_startnp", start_no_spread , ADMFLAG_SLAY, " Start Vote No Spread Plugin") 
}  

public Action start_no_spread(int client, int args)
{	
	if (!StopAction) 
	{
		Menu start = new Menu(Handle_VoteMenu);
		start.SetTitle("Enable No Spread");
		start.AddItem("yes", "Yes");
		start.AddItem("no", "No");
		start.ExitButton = false;
		start.DisplayVoteToAll(20);

		yes = 0;
		no = 0;
		total = 0;
		percentage = 0;

	}
	else
	{
	PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.",servername);
	return Plugin_Handled;
	}
	return Plugin_Handled;
}
Fifth :

Code:
public int Handle_VoteMenu(Menu menu, MenuAction action, int client, int item)
{
	switch(action)
	{
		case MenuAction_Select:
		{
			switch(item)
			{
				case 0:
				{
					yes++;
					total++;
				}
				case 1:
				{
					no++;
					total++;
				}
			}
		}		
		case MenuAction_End:
		{
			percintage = yes / total * 100; 
			if (percintage >= 60) {	
				PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 Enabled\0x07ffffff.", servername);
			}
			else {
				PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 D\0x07ffffff.", servername);	
			}
			delete menu;
		}			
	}
}
It should be :

Code:
public int Handle_VoteMenu(Menu menu, MenuAction action, int client, int item) //It's not always client or item, it depend of the MenuAction, replace by param1 and param2
{
	switch(action) //Good
	{
		case MenuAction_Select: //Good
		{
			switch(item)//Remove this
			{//Remove this
				case 0://Remove this
				{//Remove this
					yes++;//Remove this
					total++;//Remove this
				}//Remove this
				case 1://Remove this
				{//Remove this
					no++;//Remove this
					total++;//Remove this
				}//Remove this
			}//Remove this

			//Replace by this

			char info[32];
			menu.GetItem(param2, info, sizeof(info));

			if(StrEqual(info, "yes", false))
			{
				yes++ //Don't know if it's good, please ask to someone
				total++ //Don't know if it's good, please ask to someone
			}
			else if(StrEqual(info, "no", false))
			{
				no++ //Don't know if it's good, please ask to someone
				total++ //Don't know if it's good, please ask to someone
			}
			
		}		
		case MenuAction_End:
		{
			percentage = (yes / total * 100);  // replaced to "percentage" it's better to do "result = (operations)". Wait, where is "no" ? is it useless ?
			if (percentage >= 60) {	
				PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 Enabled\0x07ffffff.", servername);//In this case, MenuAction End, there is no client index so remove it by PrintToChatAll
			}
			else {
				PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 D\0x07ffffff.", servername); //In this case, MenuAction End, there is no client index so remove it by PrintToChatAll
			}
			delete menu;
		}			
	}
}
The final code should look like this :

Code:
#pragma semicolon 1

#include <sourcemod> 

#pragma newdecls required

#define PLUGIN_VERSION "1.0"
#define servername "Gamers-Il"

public Plugin myinfo =
{ 
    name = "Vote No Spread",
    author = "GetRektByNoob", 
    description = " No Spread Plugin",
    version = PLUGIN_VERSION,
    url = ""
}; 

bool StopAction; // Sorry forgot to say but StopAction by default is on false value so don't need 

int yes = 0; 
int no = 0; 
int iTotal = 0; // Sorry forgot to say but I changed for not having an error compiling 
int percentage = 0; 

public void OnPluginStart()
{ 
    RegAdminCmd("sm_startnp", start_no_spread, ADMFLAG_SLAY, " Start Vote No Spread Plugin");
}  

public Action start_no_spread(int client, int args)
{	
	if (!StopAction) 
	{
		Menu start = new Menu(Handle_VoteMenu);
		start.SetTitle("Enable No Spread");
		start.AddItem("yes", "Yes");
		start.AddItem("no", "No");
		start.ExitButton = false;
		start.DisplayVoteToAll(20);
		StopAction = true; // Sorry forgot this 
		yes = 0;
		no = 0;
		iTotal = 0;
		percentage = 0;
	}
	else
	{
		PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.",servername);
		return Plugin_Handled;
	}

	return Plugin_Handled;
}

public int Handle_VoteMenu(Menu menu, MenuAction action, int param1, int param2) 
{
	switch(action)
	{
		case MenuAction_Select:
		{
			char info[32];
			menu.GetItem(param2, info, sizeof(info));

			if(StrEqual(info, "yes", false))
			{
				yes++;
				iTotal++;
			}
			else if(StrEqual(info, "no", false))
			{
				no++;
				iTotal++;
			}
			
		}		
		case MenuAction_End:
		{
			percentage = (yes / iTotal * 100); 

			if (percentage >= 60) {	
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 Enabled\0x07ffffff.", servername);
			}

			else {
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 D\0x07ffffff.", servername);	
			}

			yes = 0; // Sorry forgot this 
			no = 0; // Sorry forgot this 
			iTotal = 0; // Sorry forgot this 
			percentage = 0; // Sorry forgot this 
			StopAction = false; // Sorry forgot this 
			delete menu;
		}			
	}
}
[EDIT]
I don't know if it will works

[EDIT #2]
ALSO, after the menu end, it will only print messages, so it useless.

[EDIT #3]
Corrected missing semicolons, only fixed on the final code part. Just copy the final code, because my others codes have so much errors that I'm too lazy to fix
__________________

Last edited by Whai; 11-12-2018 at 18:01.
Whai is offline
SpirT
Senior Member
Join Date: Sep 2018
Location: Portugal
Old 11-12-2018 , 16:29   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #4

PHP Code:
#include <sourcemod>
#include <sdktools>

#define servername "Gamers-Il"

public Plugin myinfo 
{
    
name "Vote No Spread",
    
author "GetRektByNoob",
    
description " No Spread Plugin",
    
version "1.0.0",
    
url ""
};

int servername;
int yes 0;
int no 0;
int total 0;
int percintage 0;
bool StopAction false;

public 
OnPluginStart()
{
    
RegAdminCmd("sm_startnp"start_no_spread ADMFLAG_SLAY" Start Vote No Spread Plugin")
}

public 
Action start_no_spread(int clientint args)
{    
    
servername "Gamers-Il";
    if (!
StopAction)
    {
        
Menu start = new Menu(Handle_VoteMenu);
        
start.SetTitle("Enable No Spread");
        
start.AddItem("yes""Yes");
        
start.AddItem("no""No");
        
start.ExitButton false;
        
start.DisplayVoteToAll(20);
        
        
yes 0;
        
no 0;
        
total 0;
        
percintage 0;
        
        return 
Plugin_Handled;
    }
    
    else
    {
    
PrintToChat(client,"\0x0704f448[%s] \0x07ffffff There is already vote running.",servername);
    return 
Plugin_Handled;
    }
}

public 
int Handle_VoteMenu(Menu startMenuAction actionint param1int param2)
{
    
percintage GetConVarInt(percintage);
    
servername "Gamers-Il";
    if (
action == MenuAction_Select)
    {
        if (
param2 == 1)
        {
            
yes++;
            
total++;
        }
        
        else
        {            
            
no++;
            
total++;
        }
    }
    
    if (
action == MenuAction_End)
    {
        
percintage = (yes total) * 100
        if (
percintage >= 60)
        
PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 Enabled\0x07ffffff.",servername);

        else
        
PrintToChat(client,"\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff Has Been \0x0704f448 D\0x07ffffff.",servername);    
        
        
delete start;
    }

There is it, i compiled but it's not tested. Start using the new syntax that will help you a lot to improve your skills... And don't give up, we are always here to help you! Add me as friend if you want. PM me, maybe we can talk later...
__________________
SpirT is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-13-2018 , 18:41   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #5

GetRektByNoob, you shouldn't count percentage by yourself. SourceMod is already do all the vote stuff for you.

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

#define SERVER_NAME "Gamers-Il"

public Plugin myinfo 
{
    
name "Vote No Spread",
    
author "GetRektByNoob",
    
description " No Spread Plugin",
    
version "1.0.0",
    
url ""
};

public 
void OnPluginStart()
{
    
RegAdminCmd("sm_startnp"start_no_spreadADMFLAG_SLAY"Start Vote No Spread Plugin");
}

public 
Action start_no_spread(int clientint args)
{
    if (
IsVoteInProgress()) {
        
PrintToChat(client,"\x07[%s] \x04There is already vote running."SERVER_NAME);
        return 
Plugin_Handled;
    }
    
    
Menu menu = new Menu(Handle_VoteMenuMenuAction_DisplayItem MenuAction_Display);
    
menu.SetTitle("Enable No Spread ?");
    
menu.AddItem("""Yes");
    
menu.AddItem("""No");
    
menu.ExitButton false;
    
menu.DisplayVoteToAll(20);
    return 
Plugin_Handled;
}

public 
int Handle_VoteMenu(Menu menuMenuAction actionint param1int param2)
{
    switch (
action)
    {
        case 
MenuAction_End:
            
delete menu;
            
        case 
MenuAction_VoteEnd// 0=yes, 1=no
        
{
            if (
param1 == 0)
                
PrintToChatAll("\x07[%s]\x04 No Spread Has Been \x07 enabled."SERVER_NAME);
            else
                
PrintToChatAll("\x07[%s]\x04 No Spread Has Been \x07 disabled."SERVER_NAME);
        }
    }

__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
GetRektByNoob
Member
Join Date: Nov 2018
Old 11-14-2018 , 13:14   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #6

ok i complited what i want in the plugin but as expected its not working ;/ but this time there is less error messages *Proud of my self*

New Code :
Code:
#pragma semicolon 1

#include <sourcemod> 

#pragma newdecls required

#define PLUGIN_VERSION "1.0"
#define servername "Gamers-Il"

public Plugin myinfo =
{ 
    name = "Vote No Spread",
    author = "GetRektByNoob", 
    description = " No Spread Plugin",
    version = PLUGIN_VERSION,
    url = ""
}; 

bool StopAction; // Sorry forgot to say but StopAction by default is on false value so don't need 
bool Enable;

int yes = 0; 
int no = 0; 
int iTotal = 0; 
int percentage = 0;
 
int chance = 60; // Min Percentage For Votes To Work

public void OnPluginStart()
{ 
    RegAdminCmd("sm_startnp", start_no_spread, ADMFLAG_SLAY, " Start Vote No Spread Plugin");
	RegAdminCmd("sm_stopnp", stop_no_spread, ADMFLAG_SLAY, " Stop Vote No Spread Plugin");
	RegAdminCmd("sm_np", toggle_no_spread, ADMFLAG_SLAY, " Toggles No Spread | 1 = Enable | 0 = Disable");
	RegAdminCmd("sm_npcredits", credits_no_spread, ADMFLAG_RESERVATION, " Credits Command");
}  

public Action start_no_spread(int client, int args)
{	
	if (!StopAction && !Enable) 
	{
		Menu start = new Menu(Handle_StartVoteMenu);
		start.SetTitle("Enable No Spread");
		start.AddItem("yes", "Yes");
		start.AddItem("no", "No");
		start.ExitButton = false;
		start.DisplayVoteToAll(20);
		StopAction = true; 
		yes = 0;
		no = 0;
		iTotal = 0;
		percentage = 0;
	}
	else
	{
		PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);
	}

	return Plugin_Handled;
}

public Action stop_no_spread(int client, int args)
{	
	if (!StopAction && Enable) 
	{
		Menu stop = new Menu(Handle_StopVoteMenu);
		stop.SetTitle("Enable No Spread");
		stop.AddItem("yes", "Yes");
		stop.AddItem("no", "No");
		stop.ExitButton = false;
		stop.DisplayVoteToAll(20);
		StopAction = true; 
		yes = 0;
		no = 0;
		iTotal = 0;
		percentage = 0;
	}
	else
	{
		PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);
	}

	return Plugin_Handled;
}

public int Handle_StartVoteMenu(Menu menu, MenuAction action, int param1, int param2) 
{
	switch(action)
	{
		case MenuAction_Select:
		{
			char info[32];
			menu.GetItem(param2, info, sizeof(info));

			if(StrEqual(info, "yes", false))
			{
				yes++;
				iTotal++;
			}
			else if(StrEqual(info, "no", false))
			{
				no++;
				iTotal++;
			}
			
		}		
		case MenuAction_End:
		{
			percentage = (yes / iTotal * 100); 

			if (percentage >= chance) 
			{	
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff has been \0x0704f448 Enable\0x07ffffff. \0x07a5a7aa(%i% voted yes)", servername, percentage);
				Enable = true;
				
				// weapon_recoil_scale 0
				// weapon_accuracy_nospread 1
			}

			else {
				PrintToChatAll("\0x0704f448[%s] \0x07ffffff The vote to enable \0x07e8aaef No Spread \0x07ffffff has \0x0704f448 Failed\0x07ffffff. \0x07a5a7aa(%i% voted yes)", servername, percentage);	
			}

			yes = 0; // 
			no = 0; 
			iTotal = 0; 
			percentage = 0; 
			StopAction = false;
			delete menu;
		}			
	}
}


public int Handle_StopVoteMenu(Menu menu, MenuAction action, int param1, int param2) 
{
	switch(action)
	{
		case MenuAction_Select:
		{
			char info[32];
			menu.GetItem(param2, info, sizeof(info));

			if(StrEqual(info, "yes", false))
			{
				yes++;
				iTotal++;
			}
			else if(StrEqual(info, "no", false))
			{
				no++;
				iTotal++;
			}
			
		}		
		case MenuAction_End:
		{
			percentage = (yes / iTotal * 100); 

			if (percentage >= chance) 
			{	
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff has been \0x0704f448 Disable\0x07ffffff. \0x07a5a7aa(%i% Voted Yes)", servername, percentage);
				Enable = false;
				
				// weapon_recoil_scale 2
				// weapon_accuracy_nospread 0
			}

			else {
				PrintToChatAll("\0x0704f448[%s] \0x07ffffff The vote to enable \0x07e8aaef No Spread \0x07ffffff has\0x0704f448 Failed\0x07ffffff. \0x07a5a7aa(%i% Voted Yes)", servername, percentage);	
			}

			yes = 0; 
			no = 0; 
			iTotal = 0;
			percentage = 0;  
			StopAction = false; 
			delete menu;
		}			
	}
}

public Action start_no_spread(int client, int args)
{
	int Arg1 = GetCmdArg(1);
	
	String name = GetClientName(client, name, sizeof(name));
	
	if (args == 0 || args >= 3)
	{
		PrintToChat(client,"\0x0704f448[%s]\0x07ffffff Usage : sm_np 0/1 (0 = Disable | 1 = Enable)", servername);
	}
	
	else
	{
		switch(Arg1)
		{
			case default:
			{
				PrintToChat(client,"\0x0704f448[%s]\0x07ffffff Usage : sm_np 0/1 (0 = Disable | 1 = Enable)", servername);
			}
			
			case 0:
			{
				if (Enable)
				{
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff has been \0x0704f448 Disable \0x07ffffff by \0x075fb3dd %s \0x07ffffff.", servername, name);
				
				// weapon_recoil_scale 0
				// weapon_accuracy_nospread 1
				
				}
				
				else
				{
					PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);
				}
			}
			
			case 1:
			{
				if (!Enable)
				{
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff has been \0x0704f448 Enable \0x07ffffff by \0x075fb3dd %s \0x07ffffff.", servername, name);
				}
				
				else
				{
					PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);
				}
			}
		}
	}
	
	return Plugin_Handled;
}

public Action Credits_no_spread(int client, int args)
{
	PrintToChat(client,"\0x0704f448[%s] \0x07ffffff This plugin was made by \0x075fb3ddGetRektByNoob \0x07ffffff.",servername);
	return Plugin_Handled;
}

Error Messages :
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// [Vote] NoSpread.sp
//
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(32) : warning 217: loose indentation
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(33) : error 017: undefined symbol "toggle_no_spread"
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(34) : error 017: undefined symbol "credits_no_spread"
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(182) : error 021: symbol already defined: "start_no_spread"
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(184) : error 092: number of arguments does not match definition
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(186) : error 098: type "String" should be "char" in new-style declarations
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(186) : error 035: argument type mismatch (argument 2)
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(186) : warning 213: tag mismatch
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(197) : error 029: invalid expression, assumed zero
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(202) : error 040: duplicate "case" label (value 0)
//
// 8 Errors.
//
// Compilation Time: 0.2 sec
// ----------------------------------------

Press enter to exit ...
can someone also explane to me couple of stuff..

1) What dose this lines do?
Code:
char info[32];
menu.GetItem(param2, info, sizeof(info));
if(StrEqual(info, "yes", false))
2) how do i define new String

3) And what dose this like do
Code:
 #define servername "Gamers-Il"

Last edited by GetRektByNoob; 11-14-2018 at 13:19.
GetRektByNoob is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-14-2018 , 14:57   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #7

GetRektByNoob, why do you need so large plugin? Look at my little snippet.

Quote:
1) What dose this lines do?
extracts menuitem alias ("info" parameter) and compare it with "yes" string.

Quote:
2) how do i define new String
Code:
char sStr[32] = "Your string";
Quote:
And what dose this like do
Replace "servername" macro with "Gamers-Il"

Quote:
RegAdminCmd("sm_startnp", start_no_spread, ADMFLAG_SLAY, " Start Vote No Spread Plugin");
RegAdminCmd("sm_stopnp", stop_no_spread, ADMFLAG_SLAY, " Stop Vote No Spread Plugin");
You don't need two menu and two handler to do the same task vice versa. Just create global bool and check it. Depending on bool show appropriate text (menu title e.t.c.).
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Whai
Senior Member
Join Date: Jul 2018
Old 11-14-2018 , 14:58   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #8

Here is all you need :
Menu Vote Api
Global New Api Reference

Your Questions :

1)

Sorry, I made a mistake (I mean it's useless when it's for vote menu), I have no experiences about vote menu.
For awnser to your question :

This is create a char/String to store a value.
Code:
char info[32];
This is for getting the client's choice then store it
Code:
menu.GetItem(param2, info, sizeof(info));
This is for look if his choice(stored value) is "yes"
Code:
if(StrEqual(info, "yes", false))

2)

For Strings, the new synthax is "char", take a look in New Api Synthax information
Here is some help to translate old to new synthax
Here is some Writting "first plugin"
And here is where you can learn a lot of things


3)

Code:
#define servername "Gamers-Il"
Something, or if you saw something in my post like

Code:
//for your thing that come from "new servername = "Gamers-Il""
It's just for your

Code:
PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);

NOTE :

Also Integrer = for non-decimal number value
Char = for Characters (8-bit ASCII characters)
float = for decimal number value (example : 2.5)
bool = store true or false
Source
__________________

Last edited by Whai; 11-14-2018 at 14:59.
Whai is offline
GetRektByNoob
Member
Join Date: Nov 2018
Old 11-16-2018 , 07:49   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #9

can someone help me fix this error messages? i tried but i dont really understand the error messages and whats wrong with what i did...

Code:
public Action toggle_no_spread(int client, int args)
{	
	char Temp[] = GetCmdArg(1);
	int Arg1 = StringToInt(const Temp, 10);
	
	GetClientName(client, name, sizeof(name));
	
	if (args == 0 || args >= 3)
	{
		PrintToChat(client,"\0x0704f448[%s]\0x07ffffff Usage : sm_np 0/1 (0 = Disable | 1 = Enable)", servername);
	}
	
	else
	{
		switch(Arg1)
		{
			
			case 0:
			{
				if (Enable)
				{
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff has been \0x0704f448 Disable \0x07ffffff by \0x075fb3dd %s \0x07ffffff.", servername, name);
				
				// weapon_recoil_scale 0
				// weapon_accuracy_nospread 1
				
				}
				
				else
				{
					PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);
				}
			}
			
			case 1:
			{
				if (!Enable)
				{
				PrintToChatAll("\0x0704f448[%s] \0x07e8aaef No Spread \0x07ffffff has been \0x0704f448 Enable \0x07ffffff by \0x075fb3dd %s \0x07ffffff.", servername, name);
				}
				
				else
				{
					PrintToChat(client,"\0x0704f448[%s] \0x07ffffff You can not do this action now, try again later.",servername);
				}
			}
			
			default:
			{
				PrintToChat(client,"\0x0704f448[%s]\0x07ffffff Usage : sm_np 0/1 (0 = Disable | 1 = Enable)", servername);
			}
		}
	}
	
	return Plugin_Handled;
}
Code:
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// [Vote] NoSpread.sp
//
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(32) : warning 217: loose indentation
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(184) : warning 219: local variable "Temp" shadows a variable at a preceding level
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(184) : error 092: number of arguments does not match definition
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(184) : error 008: must be a constant expression; assumed zero
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(184) : error 036: empty statement
// C:\Users\USER\Desktop\SourceMod\addons\sourcemod\scripting\[Vote] NoSpread.sp(184) : fatal error 190: too many error messages on one line
//
// Compilation aborted.
// 4 Errors.
//
// Compilation Time: 0.76 sec
// ----------------------------------------

Press enter to exit ...
NOTE : the red lines are the errors not all of them are showing up on the error thing...

Last edited by GetRektByNoob; 11-16-2018 at 07:53.
GetRektByNoob is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 11-16-2018 , 08:07   Re: Help In My First Plugin (Alot Of Error Messages)
Reply With Quote #10

GetRektByNoob, first, you need to go to manual about GetCmdArg. Enter in search and find this: https://sm.alliedmods.net/new-api/console/GetCmdArg

Next, you have to make up it correctly according to manual.
Declare string (array of chars) with large enough buffer size.
Code:
char sTemp[10];
pass that buffer to GetCmdArg.
Code:
GetCmdArg(1, sTemp, sizeof(sTemp));
But, first, it's better to check the number of cmdline arguments:
Code:
if (GetCmdArgs() > 0)
Also, you don't need use "const" keyword there in StringToInt() func. It is used in prototypes only and in declarations. 10 - is optional and can be omitted.
Also, you don't need GetClientName() func. here at all. You can translate client id to name by %N specifier in your print function.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas 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 23:13.


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