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

weaponmenu for insurgency


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
IrishFire
Junior Member
Join Date: Apr 2006
Location: Syracuse NY
Old 07-29-2007 , 11:37   weaponmenu for insurgency
Reply With Quote #1

I am trying to make a menu to give an m16 or ar47 to players. I have weapons listed in file called rifles.txt and have in my sourcemod/configs folder.
This is what I did:
Code:
#include <sourcemod>
public Plugin:rifle = {
	name = "rifle",
	author = "Irishfire",
	description = "Give rifle",
	version = "1.0",
	url = "http://insurgency.ipkclan.com/forum/"
};






new Handle:g_weaponmenu = INVALID_HANDLE
 
public OnPluginStart()
{
	RegConsoleCmd("weaponmenu", Command_give_weapon)
}
 
public OnweaponStart()
{
	g_weaponmenu = Buildweaponmenu()
}
 
public OnweaponEnd()
{
	if (g_weaponmenu != INVALID_HANDLE)
	{
		CloseHandle(g_weaponmenu)
		g_weaponmenu = INVALID_HANDLE
	}
}
 
Handle:Buildweaponmenu()
{
	/* Open the file */
	new Handle:file = OpenFile("rifles.txt", "/addons/sourcemod/configs")
	if (file == INVALID_HANDLE)
	{
		return INVALID_HANDLE
	}
 
	/* Create the menu Handle */
	new Handle:menu = CreateMenu(weaponmenu);
	new String:weaponname[255]
	while (!IsEndOfFile(file) && ReadFileLine(file, weaponname, sizeof(weaponname)))
	{
		if (weaponname[0] == ';' || !IsCharAlpha(weaponname[0]))
		{
			continue
		}
		/* Cut off the name at any whitespace */
		new len = strlen(weaponname)
		for (new i=0; i<len; i++)
		{
			if (IsCharSpace(weaponname[i]))
			{
				weaponname[i] = '\0'
				break
			}
		}
		/* Check if the weapon is valid */
		/*if (!IsgunValid(weaponname))*/
		/*{*/
		/*	continue*/
		/*}*/
		/* Add it to the menu */
		AddMenuItem(menu, weaponname, weaponname)
	}
	/* Make sure we close the file! */
	CloseHandle(file)
 
	/* Finally, set the title */
	SetMenuTitle(menu, "Please select a Rifle:")
 
	return menu
}
 
public weaponmenu(Handle:menu, MenuAction:action, param1, param2)
{
	if (action == MenuAction_Select)
	{
		new String:info[32]
 
		/* Get item info */
		new bool:found = GetMenuItem(menu, param2, info, sizeof(info))
 
		/* Tell the client */
		PrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info)
 
		/* Change the Rifle */
		ServerCommand("give_weapon %s", info)
	}
}
 
public Action:Command_give_weapon(client, args)
{
	if (g_weaponmenu == INVALID_HANDLE)
	{
		PrintToConsole(client, "The rifles.txt file was not found!")
		return Plugin_Handled
	}	
 
	DisplayMenu(g_weaponmenu, client, MENU_TIME_FOREVER)
 
	return Plugin_Handled
}
If some could help please
__________________
The IRISH rule as long as they dont stop making BEER

-|IPK|-IRISH PUB KILLERS

Last edited by IrishFire; 07-29-2007 at 11:40.
IrishFire is offline
Send a message via Yahoo to IrishFire
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 07-29-2007 , 13:57   Re: weaponmenu for insurgency
Reply With Quote #2

Honestly, Insurgency broke a lot of standards on it's release, at least 50-75% of normal functions that would work in just about any other mod will not work in Insurgency (CommitSuicide being one of them).

We're not exactly sure how to go forward when it comes to supporting it, I honestly don't support it in my plugins, as it's too much a hassle, and will be until they change these things back.
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose is offline
BAILOPAN
Join Date: Jan 2004
Old 07-29-2007 , 19:03   Re: weaponmenu for insurgency
Reply With Quote #3

Indeed, in order to make an Insurgency plugin that does this you will have to bust open a disassembler and see the replacement functions it has, and then write SDKCall() support for it using sdktools.

Not really trivial, unfortunately, although the INS developers might be willing to give you more information (for example, the function call and what parameters are required).
__________________
egg
BAILOPAN is offline
tcviper
Veteran Member
Join Date: Oct 2005
Location: Netherlands
Old 08-02-2007 , 07:31   Re: weaponmenu for insurgency
Reply With Quote #4

in Insurgency 1.2 there will be a weapon menu in the VGUI of Insurgency itself so there is no need for this i think.
__________________
tcviper is offline
Send a message via MSN to tcviper
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 17:10.


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