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

[L4D] give player weapon


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
{7~11} TROLL
Senior Member
Join Date: Oct 2008
Location: Atlanta,Georgia
Old 02-26-2009 , 15:40   [L4D] give player weapon
Reply With Quote #1

im currently working on making a gun type menu for L4d but im having issue with giving players weapons ive tryed GivePlayerItem(client, "gun here") and that didnt work so i looked up the cvars and saw it has a give command so i change it to give(client, "gun") and still nothing code provided below. also im pretty sure the gun names are right but i could be wrong cant really find an offical list of gun names so please correct me if there typed wrong

any help would be super awesome

PHP Code:
/***************GUNS***************
*Pistol
*Shotgun
*SMG
*Assault Rifle
*Hunting Rifle
*Autoshotgun
*Pipe Bomb
*Molotov
*Dual Pistols
*Chaingun/Minigun/Whatever it is
************END LIST***************/
 
#pragma semicolon 1
#include <sourcemod>
#define PLUGIN_VERSION "1.0.0"
public Plugin:myinfo 
{
 
name "[L4D] Tank Buster Wepons Menu",
 
author "{7~11} TROLL",
 
description "Gives Clients Gun Menu Incase There Out Of Ammo",
 
version PLUGIN_VERSION,
 
url "www.711clan.net"
}
public 
OnPluginStart()
{
 
//tank buster weapons menu cvar
 
RegConsoleCmd("tankbuster"TankBusterMenu);
 
//plugin version
 
CreateConVar("tank_buster_version"PLUGIN_VERSION"Tank_Buster_Version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
}
public 
Action:TankBusterMenu(client,args)
{
 
TankBuster(client);
}
public 
Action:TankBuster(clientId) {
 new 
Handle:menu CreateMenu(TankBusterMenuHandler);
 
SetMenuTitle(menu"Tank Buster Weapons Menu");
 
AddMenuItem(menu"option1""Shotgun");
 
AddMenuItem(menu"option2""SMG");
 
AddMenuItem(menu"option3""Assault Rifle");
 
AddMenuItem(menu"option4""Hunting Rifle");
 
AddMenuItem(menu"option5""Auto Shotgun");
 
AddMenuItem(menu"option6""Pipe Bomb");
 
AddMenuItem(menu"option7""Molotov");
 
AddMenuItem(menu"option8""Dual Pistols");
 
SetMenuExitButton(menutrue);
 
DisplayMenu(menuclientIdMENU_TIME_FOREVER);
 
 return 
Plugin_Handled;
}
public 
TankBusterMenuHandler(Handle:menuMenuAction:actionclientitemNum) {
 if ( 
action == MenuAction_Select ) {
  new 
String:info[32];
 
  
GetMenuItem(menuitemNuminfosizeof(info));
  
//menu item 1 (shotgun)
  
if ( strcmp(info,"option1") == ) {
        
//gives shotgun
     
{
      
Give(client"weapon_shotgun");
        }
 
  }
  
//menu item 2 (SMG)
  
else if ( strcmp(info,"option2") == ) {
     {
      
Give(client"weapon_smg");
        }
 
  }
  
//menu item 3 (Assault Rifle)
  
else if ( strcmp(info,"option3") == ) {
     {
      
Give(client"weapon_assault_rifle");
        }
  }
  
//menu item 4 (Hunting Rifle)
  
else if ( strcmp(info,"option4") == ) {
     {
      
Give(client"weapon_hunting_rifle");
        }
        }
  
//menu item 5 (Auto Shotgun)
  
else if ( strcmp(info,"option4") == ) {
   {
      
Give(client"weapon_auto_shotgun");
        }  
  }
  
//menu item 6 (Pipe Bomb)
  
else if ( strcmp(info,"option4") == ) {
   {
      
Give(client"weapon_pipe_bomb");
        }  
  }
  
//menu item 7 (Molotov)
  
else if ( strcmp(info,"option4") == ) {
   {
      
Give(client"weapon_molotov");
        }  
  }
  
//menu item 8 (Dual Pistols)
  
else if ( strcmp(info,"option4") == ) {
   {
      
Give(client"weapon_dual_pistols");
        }  
  }
 }
 else if ( 
action == MenuAction_End )
  
CloseHandle(menu);

__________________
{7~11} TROLL is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 02-26-2009 , 15:56   Re: [L4D] give player weapon
Reply With Quote #2

This is from something I wrote for someone else a few months ago, but it would apply here. Not the best method, but probably the best your going to get without an SDKCall.

Code:
public Action:Timer_GiveItems(Handle:timer, any:client)
{
    new flags = GetCommandFlags("give");
    SetCommandFlags("give", flags & ~FCVAR_CHEAT);
    
    new iTeam = GetClientTeam(client);

    if(iTeam == SURVIVORS)
    {
        if(IsClientInGame(client))
        {
            FakeClientCommand(client, "give rifle");
            FakeClientCommand(client, "give pipe_bomb");
            FakeClientCommand(client, "give pain_pills");
        }
    }

    SetCommandFlags("give", flags|FCVAR_CHEAT);
}
__________________
CrimsonGT is offline
{7~11} TROLL
Senior Member
Join Date: Oct 2008
Location: Atlanta,Georgia
Old 02-26-2009 , 16:00   Re: [L4D] give player weapon
Reply With Quote #3

so for each menu item i add

PHP Code:
{
    new 
flags GetCommandFlags("give");
    
SetCommandFlags("give"flags & ~FCVAR_CHEAT);
    
    new 
iTeam GetClientTeam(client);

    if(
iTeam == SURVIVORS)
    {
        if(
IsClientInGame(client))
        {
            
FakeClientCommand(client"give rifle");
            
FakeClientCommand(client"give pipe_bomb");
            
FakeClientCommand(client"give pain_pills");
        }
    }

    
SetCommandFlags("give"flags|FCVAR_CHEAT);

__________________
{7~11} TROLL is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 02-26-2009 , 16:03   Re: [L4D] give player weapon
Reply With Quote #4

No, at the top of the handler use the code to strip the cheat flag off of the "give" command. Inside the appropriate if() add the FakeClientCommand() for the specific weapon, and at the end of the function put the cheat flag back on the "give command.
__________________
CrimsonGT is offline
{7~11} TROLL
Senior Member
Join Date: Oct 2008
Location: Atlanta,Georgia
Old 02-26-2009 , 16:21   Re: [L4D] give player weapon
Reply With Quote #5

Quote:
Originally Posted by CrimsonGT View Post
No, at the top of the handler use the code to strip the cheat flag off of the "give" command. Inside the appropriate if() add the FakeClientCommand() for the specific weapon, and at the end of the function put the cheat flag back on the "give command.
sorry im still new at coding lol but can you give me an example of what you mean im better learning with examples

and thanks for the help
__________________
{7~11} TROLL is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 02-26-2009 , 16:28   Re: [L4D] give player weapon
Reply With Quote #6

Code:
public TankBusterMenuHandler(Handle:menu, MenuAction:action, client, itemNum)
{
    //Strip the CHEAT flag off of the "give" command
    new flags = GetCommandFlags("give");
    SetCommandFlags("give", flags & ~FCVAR_CHEAT);

    if ( action == MenuAction_Select ) {
        new String:info[32];

    if (strcmp(info,"option1") == 0 ) {
    {
        //Give the player a rifle
        FakeClientCommand(client, "give rifle");
    }
    else if ( strcmp(info,"option2") == 0 ) {
    {
        //Give the player a pipe_bomb
        FakeClientCommand(client, "give pipe_bomb");
    }

    //Add the CHEAT flag back to "give" command
    SetCommandFlags("give", flags|FCVAR_CHEAT);
}
__________________
CrimsonGT is offline
{7~11} TROLL
Senior Member
Join Date: Oct 2008
Location: Atlanta,Georgia
Old 02-26-2009 , 16:31   Re: [L4D] give player weapon
Reply With Quote #7

thank you so much bro +karma and special thank you is goin in my plugin.
__________________
{7~11} TROLL is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 02-26-2009 , 16:33   Re: [L4D] give player weapon
Reply With Quote #8

No problem, goodluck!
__________________
CrimsonGT is offline
{7~11} TROLL
Senior Member
Join Date: Oct 2008
Location: Atlanta,Georgia
Old 02-26-2009 , 16:35   Re: [L4D] give player weapon
Reply With Quote #9

also can you give me a list of the weapons and such if you can?

and thanks for all the help
__________________
{7~11} TROLL is offline
CrimsonGT
Veteran Member
Join Date: Oct 2007
Location: Gainesville, FL
Old 02-26-2009 , 16:37   Re: [L4D] give player weapon
Reply With Quote #10

Oh I have no clue, I rarely touch L4D at all. If you go into console and type give it should give you a drop down of items.
__________________
CrimsonGT 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 05:11.


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