Raised This Month: $51 Target: $400
 12% 

[NMRiH] Weapon Menu (v1.1.0, 01/13/14)


Post New Thread Reply   
 
Thread Tools Display Modes
Leon370
New Member
Join Date: Nov 2013
Old 11-08-2013 , 22:47   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #21

Quote:
Originally Posted by KnzzzaD View Post
i found the reason , thanks for helping

What you do to fix ? I having the same issue
Leon370 is offline
KnzzzaD
Junior Member
Join Date: Jul 2011
Location: HK
Old 11-08-2013 , 23:52   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #22

Quote:
Originally Posted by Leon370 View Post
What you do to fix ? I having the same issue
change the ini name to nmrihf_weapon_menu.ini
KnzzzaD is offline
Leon370
New Member
Join Date: Nov 2013
Old 11-09-2013 , 00:20   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #23

Quote:
Originally Posted by KnzzzaD View Post
change the ini name to nmrihf_weapon_menu.ini

Thx , works now

Last edited by Leon370; 11-09-2013 at 00:20.
Leon370 is offline
KnzzzaD
Junior Member
Join Date: Jul 2011
Location: HK
Old 11-09-2013 , 00:52   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #24

but i still can't spawn ammo
no such ammobox_(*) entity name
KnzzzaD is offline
Sikkens1997
Junior Member
Join Date: Mar 2012
Old 11-09-2013 , 06:54   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #25

Thanks for the upate man. Really nice.

But I am still missing 3 great functions from this plugin, would be awesome if you could add them.
- Ammoboxes, or spawn a weapon with full ammo. (Some way to not run out of ammo)
- Explosives.
- Med Kits, Pills, Bandages


2 Bugs/glitches
The name of the .ini file needs to be nmrihf_weapon_menu.ini, or else the plugin doesn't work.
When you are in a category and you press 'Back' the menu closes, instead of going back to the category menu.

Last edited by Sikkens1997; 11-09-2013 at 07:02.
Sikkens1997 is offline
Frischling
New Member
Join Date: Nov 2013
Old 11-09-2013 , 08:17   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #26

Hi,

i do hope i am not posting this wrongly here.
I am trying to user this Mod on my nmrih Listen server.

I am using:

mmsource-1.10.1-hg870-windows
sourcemod-1.6.0-hg4171-windows

as well as the Mod 1.0.6

the mod is shown as installed and runing when i use sm plugins list
the Commands are there as well.

But when i try to user the i receive the following error:

[SM] Native "IsPlayerAlive" reported: Invalid client index 0
[SM] Displaying call stack trace for plugin "weapon_menu.smx":
[SM] [0] Line 171, /home/groups/alliedmodders/forums/files/2/1/6/0/4/4/118107.attach::Command_WeaponMenu()

Maybe it is something simple to fix, maybe i did something wrong. But searching for the first string showed me tons of threads where on of the worde was found.

I hope you can give me a hint or even better a solution for this.
Frischling is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 11-09-2013 , 09:29   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #27

I should probably check if the client is a client or if it is console. All that means is that you are trying to use that command as Console. If you go in game, and you physically try the command (open chat box and type !guns), it should open up for you.

I completely forgot about changing the config file name .... That is the name of the one running on my server, and I pulled this plugin from my server and removed some stuff from it to upload it here. I do know that I do not have any explosives or medical supplies. On my servers I have two more categories: Donor and Admin, and those objects fall into one of those categories. I have thought about adding those objects in, but I have decided against it. I have to have SOME reason for my server to still get played It is really simple to add those back in though; if you found someone with a little SM experience it should take about five minutes at most.

Quote:
Originally Posted by Sikkens1997
(Some way to not run out of ammo)
Quote:
Originally Posted by Original Post
This specific menu is meant to be ran with Chanz's No More Room In Hell: Unlimited Ammo plugin.
Marcus_Brown001 is offline
Frischling
New Member
Join Date: Nov 2013
Old 11-09-2013 , 09:51   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #28

Yes, that did the trick.
Thank you very much for pointing this out.

I am still completly new to this.
Now i have to wait for an update on the Unlimited Ammo Plugin
Frischling is offline
tdlab
Junior Member
Join Date: Nov 2013
Old 11-09-2013 , 11:42   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #29

Quote:
Originally Posted by Frischling View Post
Yes, that did the trick.Thank you very much for pointing this out.

I am still completly new to this.
Now i have to wait for an update on the Unlimited Ammo Plugin
Well, I tried to edit it a little to add a ammo menu, however I never tested it, and am very new to coding.


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

#define MESS "\x01[\x04Notice\x01]"
#define ERROR "\x01\x04Error\x01"
#define MAX_CONFIG_WEAPONS 24

new Handle:g_iToolCount = INVALID_HANDLE;

new String:g_sWepNumbers[MAX_CONFIG_WEAPONS][64];
new String:g_sWepNames[MAX_CONFIG_WEAPONS][64];
new String:g_sWepDNames[MAX_CONFIG_WEAPONS][64];
new String:g_sWepCategory[MAX_CONFIG_WEAPONS][64];

new g_iWeps = 0, g_iMaxTools = 0, g_iTools[MAXPLAYERS+1];
new bool:bAlive[MAXPLAYERS+1], bool:bPrimary[MAXPLAYERS+1], bool:bSecondary[MAXPLAYERS+1];

public Plugin:myinfo = 
{
	name = "[NMRiH] Weapon Menu",
	author = "Marcus",
	description = "A simple and customizable weapon menu for NMRiH.",
	version = "1.0.1",
	url = "http://www.redspeedservers.com"
};

public OnPluginStart()
{
	CreateConVar("sv_weapon_menu_version", "1.0.1", "This is the version of the Weapon Menu the server is running.", FCVAR_DONTRECORD|FCVAR_NOTIFY|FCVAR_CHEAT);

	g_iToolCount = CreateConVar("sv_tool_count", "10", "Sets the number of tools a player can select.", FCVAR_NONE, true, 0.0, true, 7.0);
	HookConVarChange(g_iToolCount, OnSettingsChange);

	RegAdminCmd("sm_guns", Weapon_Menu, 0);
	RegAdminCmd("sm_primary", Primary_Menu, 0);
	RegAdminCmd("sm_secondary", Secondary_Menu, 0);
	RegAdminCmd("sm_tools", Tool_Menu, 0);
	RegAdminCmd("sm_ammo", Ammo_Menu, 0);
	
	HookEvent("player_spawn", Player_Spawn);
	HookEvent("player_death", Player_Death);
	
	Load_Weapons();
}

public OnSettingsChange(Handle:cvar, const String:oldvalue[], const String:newvalue[])
{
	if (cvar == g_iToolCount)
	{
		g_iMaxTools = StringToInt(newvalue);
	}
}

public OnClientPutInServer(client)
{
	if (IsValidClient(client))
	{
		g_iTools[client] = 0;
		
		bPrimary[client] = false;
		bSecondary[client] = false;
	}
}

public Player_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if (client > 0)
	{
		if (IsClientConnected(client) && IsPlayerAlive(client))
		{
			bAlive[client] = true;
			g_iTools[client] = 0;
			
			bPrimary[client] = false;
			bSecondary[client] = false;
		}
	}

}

public Player_Death(Handle:event, const String:name[], bool:dontBroadcast)
{
	new client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if (client > 0)
	{
		if (IsClientConnected(client) && IsPlayerAlive(client))
		{
			bAlive[client] = false;
		}
	}

}

Load_Weapons() // Originally, this was from TwistedPanda's BuildWars : It helped alot!!
{
	decl String:sPath[PLATFORM_MAX_PATH];
	BuildPath(Path_SM, sPath, PLATFORM_MAX_PATH, "configs/weapon_menu.ini");

	new Handle:_hKV = CreateKeyValues("Weapons");
	if(FileToKeyValues(_hKV, sPath))
	{
		KvGotoFirstSubKey(_hKV);
		do
		{
			KvGetSectionName(_hKV, g_sWepNumbers[g_iWeps], 64);
			
			KvGetString(_hKV, "display_name", g_sWepDNames[g_iWeps], sizeof(g_sWepDNames[]));
			KvGetString(_hKV, "weapon_name", g_sWepNames[g_iWeps], sizeof(g_sWepNames[]));
			KvGetString(_hKV, "category", g_sWepCategory[g_iWeps], sizeof(g_sWepCategory[]));

			g_iWeps++;
		}
		while (KvGotoNextKey(_hKV));
		CloseHandle(_hKV);
		
		PrintToServer("Weapon-Menu: Loaded %d weapons", g_iWeps);
	} else
	{
		CloseHandle(_hKV);
		SetFailState("Weapon-Menu: Could not locate \"configs/weapon_menu.ini\"");
	}
}

public Action:Weapon_Menu(client, args)
{
	if(bAlive[client])
	{
		new Handle:hMenu = CreateMenu(Menu_Weapon);
		SetMenuTitle(hMenu, "Weapon Menu");
		
		AddMenuItem(hMenu, "1", "Primary Weapons");
		AddMenuItem(hMenu, "2", "Secondary Weapons");
		AddMenuItem(hMenu, "3", "Tools");
		AddMenuItem(hMenu, "4", "Ammo");

		SetMenuExitButton(hMenu, true);
		DisplayMenu(hMenu, client, 120);
		
		PrintToChat2(client, "%s Press [\x04Esc\x01] to view the weapon menu!", MESS);
	} else
	PrintToChat2(client, "%s %s: You must be alive to use this command!", MESS, ERROR)

	return Plugin_Handled;
}

public Menu_Weapon(Handle:weapon, MenuAction:action, param1, param2)
{
	if (action == MenuAction_End)
	{
        CloseHandle(weapon);
	}
	
	if (action == MenuAction_Select)
	{
		new String:info[32];
		GetMenuItem(weapon, param2, info, sizeof(info));
		
		if (StrEqual(info, "1"))
		{
			FakeClientCommand(param1, "sm_primary");
		} else if (StrEqual(info, "2"))
		{
			FakeClientCommand(param1, "sm_secondary");
		} else if (StrEqual(info, "3"))
		{
			FakeClientCommand(param1, "sm_tools");
		}
		{
			FakeClientCommand(param1, "sm_ammo");
		}
	}
}

public Action:Primary_Menu(client, args)
{
	if(bAlive[client])
	{
		new Handle:hMenu = CreateMenu(Menu_Primary);
		SetMenuTitle(hMenu, "Primary Weapon Menu");
		
		for(new i = 0; i < g_iWeps; i++)
		{
			if (StrEqual(g_sWepCategory[i], "primary", false))
				AddMenuItem(hMenu, g_sWepNumbers[i], g_sWepDNames[i]);
		}
		
		SetMenuExitButton(hMenu, true);
		DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
		
		PrintToChat2(client, "%s Press [\x04Esc\x01] to view the primary weapons menu!", MESS);
	} else
	PrintToChat2(client, "%s %s: You must be alive to use this command!", MESS, ERROR);
	
	return Plugin_Handled;
}

public Menu_Primary(Handle:primary, MenuAction:action, param1, param2)
{
	if (action == MenuAction_End)
	{
        CloseHandle(primary);
	}
	if (action == MenuAction_Select)
	{
		new String:info[32];
		GetMenuItem(primary, param2, info, sizeof(info));
		
		for (new i = 0; i < g_iWeps; i++)
		{
			if (StrEqual(info, g_sWepNumbers[i]))
			{
				new weapon = GivePlayerItem(param1, g_sWepNames[i], 0);
				
				bPrimary[param1] = true;
				AcceptEntityInput(weapon, "use", param1, param1);
				
				PrintToChat2(param1, "%s You have selected the \x04%s\x01.", MESS, g_sWepDNames[i]);
			}
		}
	}
}

public Action:Secondary_Menu(client, args)
{
	if(bAlive[client])
	{
		new Handle:hMenu = CreateMenu(Menu_Secondary);
		SetMenuTitle(hMenu, "Secondary Weapon Menu");
	
		for(new i = 0; i < g_iWeps; i++)
		{
			if (StrEqual(g_sWepCategory[i], "secondary", false))
				AddMenuItem(hMenu, g_sWepNumbers[i], g_sWepDNames[i]);
		}
		
		SetMenuExitButton(hMenu, true);
		DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
		
		PrintToChat2(client, "%s Press [\x04Esc\x01] to view the secondary weapons menu!", MESS);
	} else
	PrintToChat2(client, "%s %s: You must be alive to use this command!", MESS, ERROR);
	
	return Plugin_Handled;
}

public Menu_Secondary(Handle:secondary, MenuAction:action, param1, param2)
{
	if (action == MenuAction_End)
	{
        CloseHandle(secondary);
	}
	if (action == MenuAction_Select)
	{
		new String:info[32];
		GetMenuItem(secondary, param2, info, sizeof(info));
		
		for (new i = 0; i < g_iWeps; i++)
		{
			if (StrEqual(info, g_sWepNumbers[i]))
			{
				new weapon = GivePlayerItem(param1, g_sWepNames[i], 0);
				
				bSecondary[param1] = true;
				AcceptEntityInput(weapon, "use", param1, param1);
				
				PrintToChat2(param1, "%s You have selected the \x04%s\x01.", MESS, g_sWepDNames[i]);
			}
		}
	}
}

public Action:Tool_Menu(client, args)
{
	if(bAlive[client])
	{
		new Handle:hMenu = CreateMenu(Menu_Tool);
		SetMenuTitle(hMenu, "Tool Menu");
	
		for(new i = 0; i < g_iWeps; i++)
		{
			if (StrEqual(g_sWepCategory[i], "tool", false))
				AddMenuItem(hMenu, g_sWepNumbers[i], g_sWepDNames[i]);
		}
			
		SetMenuExitButton(hMenu, true);
		DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
		
		PrintToChat2(client, "%s Press [\x04Esc\x01] to view the tool menu!", MESS);
	} else
	PrintToChat2(client, "%s %s: You must be alive to use this command!", MESS, ERROR);
	
	return Plugin_Handled;
}

public Menu_Tool(Handle:tool, MenuAction:action, param1, param2)
{
	if (action == MenuAction_End)
	{
        CloseHandle(tool);
	}
	if (action == MenuAction_Select)
	{
		new String:info[32];
		GetMenuItem(tool, param2, info, sizeof(info));
		
		if (g_iTools[param1] < g_iMaxTools)
		{
			for (new i = 0; i < g_iWeps; i++)
			{
				if (StrEqual(info, g_sWepNumbers[i]))
				{
					new weapon = GivePlayerItem(param1, g_sWepNames[i], 0);
					
					g_iTools[param1]++;
					AcceptEntityInput(weapon, "use", param1, param1);
					
					PrintToChat2(param1, "%s You have selected the \x04%s\x01.", MESS, g_sWepDNames[i]);
				}
			}
		} else
		PrintToChat2(param1, "%s %s: You are only allowed 3 tools!", MESS, ERROR);
	}
}
public Action:Ammo_Menu(client, args)
{
	if(bAlive[client])
	{
		new Handle:hMenu = CreateMenu(Menu_Tool);
		SetMenuTitle(hMenu, "Ammo Menu");
	
		for(new i = 0; i < g_iWeps; i++)
		{
			if (StrEqual(g_sWepCategory[i], "ammo", false))
				AddMenuItem(hMenu, g_sWepNumbers[i], g_sWepDNames[i]);
		}
			
		SetMenuExitButton(hMenu, true);
		DisplayMenu(hMenu, client, MENU_TIME_FOREVER);
		
		PrintToChat2(client, "%s Press [\x04Esc\x01] to view the tool menu!", MESS);
	} else
	PrintToChat2(client, "%s %s: You must be alive to use this command!", MESS, ERROR);
	
	return Plugin_Handled;
}

public Menu_Ammo(Handle:tool, MenuAction:action, param1, param2)
{
	if (action == MenuAction_End)
	{
        CloseHandle(tool);
	}
	if (action == MenuAction_Select)
	{
		new String:info[32];
		GetMenuItem(tool, param2, info, sizeof(info));
		
		if (g_iTools[param1] < g_iMaxTools)
		{
			for (new i = 0; i < g_iWeps; i++)
			{
				if (StrEqual(info, g_sWepNumbers[i]))
				{
					new weapon = GivePlayerItem(param1, g_sWepNames[i], 0);
					
					g_iTools[param1]++;
					AcceptEntityInput(weapon, "use", param1, param1);
					
					PrintToChat2(param1, "%s You have selected the \x04%s\x01.", MESS, g_sWepDNames[i]);
				}
			}
		} else
		PrintToChat2(param1, "%s %s: You are only allowed 3 tools!", MESS, ERROR);
	}
}


stock bool:IsValidClient(client) 
{
    if ((1 <= client <= MaxClients) && IsClientInGame(client)) 
        return true; 
     
    return false; 
}

public PrintToChat2(client, const String:format[], any:...)
{
	decl String:buffer[256];
	SetGlobalTransTarget(client);
	VFormat(buffer, sizeof(buffer), format, 3);
	
	new Handle:bf = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
	BfWriteByte(bf, -1);
	BfWriteByte(bf, true);
	BfWriteString(bf, buffer);
	EndMessage();
}

I haven't tested this, and if anyone could try it out, please give me feedback. If anyone noticed code errors i'm open to suggestions.
tdlab is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 11-09-2013 , 14:40   Re: [NMRiH] Weapon Menu (v1.0.6, 11/08/13)
Reply With Quote #30

I recommend you try again with the newest version of the weapon menu. Aside from the mix-up with the weapon menu ini, it does fix a lot of things.

** Edit **

I changed the copy of the weapon menu ini that the original post has. I renamed it to what is needed inside the plugin. The next update I do I will change it inside the plugin itself. I found a very minor glitch inside the code so far, and that will also be fixed with the next update. I can almost promise you will never see the glitch in game, but all the same, needs to be fixed. I want to say I will be able to push an update by tomorrow. If not by tomorrow, sometime mid-week then.

Last edited by Marcus_Brown001; 11-09-2013 at 14:47.
Marcus_Brown001 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 01:31.


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