Raised This Month: $ Target: $400
 0% 

Unknown command?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
KingCommentor
Senior Member
Join Date: Jan 2008
Location: Floridaaaa
Old 08-01-2008 , 14:17   Unknown command?
Reply With Quote #1

When you type "wpnmenu" in the console or say "/wpnmenu" a menu is suppose to come up in-game. I keep getting just "unknown command, anyone know why?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <weaponmod>
#include <weaponmod_stocks>
 
// Plugin informations
new const PLUGIN[] = "WPN Buysystem"
new const VERSION[] = "0.6"
new const AUTHOR[] = "DevconeS"
new const PREFIX[] = "[WeaponMod]"
 
// List of supported mods
#define MAX_SUPPORTED_MODS 3
new const SUPPORTED_MODS[MAX_SUPPORTED_MODS][] = {"cstrike""czero""ts"}
 
// CVAR Pointers
new g_BuyMode
new g_Advertise
new g_Enabled
 
// User Informations
new g_InBuyzone[33]
new 
g_MenuPage[33]
 
// Others
new g_MenuTitle[64]
new 
g_ColoredMenus
 
// Register the plugin
 
public plugin_init()
{
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
// Before doing anything, we wanna make sure we're running on a supported mod
 
wpn_set_supported_mods(SUPPORTED_MODSMAX_SUPPORTED_MODS"addon")
 
 
wpn_register_addon()
 
 
// CVARs
 
g_BuyMode register_cvar("wpn_buymode""2")
 
g_Advertise register_cvar("wpn_advertise""1")
 
g_Enabled get_cvar_pointer("wpn_enabled")
 
 
// Commands
 
register_clcmd("wpnbuy""cmdBuy"0"<wpnid> - buys a weapon")
 
register_clcmd("wpnmenu""cmdMenu"0"- displays weapon menu")
 
register_clcmd("say /wpnmenu""cmdMenu"0"- displays weapon menu")
 
 
// Events
 
new mod[32]
 
get_modname(mod31)
 if(
equal(mod"cstrike") || equal(mod"czero"))
 {
  
register_event("StatusIcon""eventStatusIcon""be")
 }
 
register_event("RoundTime""eventRoundTime""bc")
 
 
// Menu
 
g_ColoredMenus colored_menus()
 if(
g_ColoredMenus)
  
formatex(g_MenuTitle63"\y%s Buymenu"PREFIX)
 else
  
formatex(g_MenuTitle63"%s Buymenu"PREFIX)
 
register_menucmd(register_menuid(g_MenuTitle), 1023"actionBuyMenu")
}
// Manages message display on round begin
public eventRoundTime()
{
 if (
read_data(1) == get_cvar_num("mp_roundtime")*60)
 {
  
// New round has started, if the advertisment option is enabled, print the text
  
if(get_pcvar_num(g_Advertise))
   
client_print(0print_chat"%s Type wpnmenu in console to open the WeaponMod menu or bind <key> wpnmenu"PREFIX)
 }
}
// Event StatusIcon (to check if the user is in the buyzone)
public eventStatusIcon(id)
{
 new 
icon[32]
 
read_data(2,icon,31)
 if(
equal(icon"buyzone"))
 {
  if(
read_data(1))
   
g_InBuyzone[id] = true
  
else
  
g_InBuyzone[id] = false
 
}
}
// Checks if the given player is able to buy a weapon
canBuyWeapon(id)
{
 new 
mode get_pcvar_num(g_BuyMode)
 if(
mode == 0)
 {
  
// Buying disabled
  
client_print(idprint_console"%s Buying of weapons has been disabled"PREFIX)
  return 
false
 
}
 
 if(!
g_InBuyzone[id] && mode == 2)
 {
  
// Player not in buyzone but buyzone is required
  
client_print(idprint_console"%s You aren't in buyzone"PREFIX)
  return 
false
 
}
 
 return 
true
}
// Buy command
public cmdBuy(id)
{
 if(!
get_pcvar_num(g_Enabled)) return PLUGIN_HANDLED
 
if(!canBuyWeapon(id)) return PLUGIN_HANDLED
 
 
new wpnCount wpn_weapon_count()
 if(
wpnCount 0)
 {
  if(
read_argc() < 2)
  {
   
// No weapon given, list all available weapon and buy command
   
client_print(idprint_console"%s Available Weapons are:^nTo buy type: wpnbuy <weaponid>"PREFIX)
   new 
weapon[32]
   for(new 
0wpnCounti++)
   {
    
// Only display information, if the weapon is enabled
    
if(!is_plugin_enabled(wpn_get_integer(iwpn_pluginid))) continue
 
    
wpn_get_string(iwpn_nameweapon31)
    
client_print(idprint_console"%d - %s - $%d"iweaponwpn_get_integer(i,wpn_cost))
   }
  } else {
   new 
wpn[64], wpnid
   read_argv
(1wpn63)
   
wpnid str_to_num(wpn)
 
   if(
wpnid > -&& wpnid wpnCount)
   {
    if(!
is_plugin_enabled(wpn_get_integer(wpnidwpn_pluginid)))
    {
     
// Player tryed to buy a disabled weapon
     
client_print(idprint_console"%s This weapon is currently disabled"PREFIX)
     return 
PLUGIN_HANDLED
    
}
 
    new 
money wpn_gi_get_offset_int(idoffset_money)
    new 
cost wpn_get_integer(wpnidwpn_cost)
 
    new 
weapon[32]
    
wpn_get_string(wpnidwpn_nameweapon31)
 
    if(
money cost)
    {
     
// User has less money than required
     
client_print(idprint_console"%s You haven't got enough money for a '%s' ($%d)"PREFIXweaponcost)
     
client_print(idprint_chat"%s You haven't got enough money for a '%s' ($%d)"PREFIXweaponcost)
     return 
PLUGIN_HANDLED
    
}
 
    
// Take the money :)
    
wpn_gi_set_offset_int(idoffset_moneymoney-cost)
 
    
// Give him the weapon or refill it
    
if(wpn_give_weapon_or_refill(idwpnid) == 1)
    {
     
// New weapon was given
     
client_print(idprint_console"%s You've got now a '%s'"PREFIXweapon)
     
client_print(idprint_chat"%s You've got now a '%s'"PREFIXweapon)
    } else {
     
// Refilled
     
client_print(idprint_console"%s Your '%s' has now full ammo"PREFIXweapon)
     
client_print(idprint_chat"%s Your '%s' has now full ammo"PREFIXweapon)
    }
   } else {
    
// Player tryed to buy an unknown weapon
    
client_print(idprint_console"%s Invalid Weapon ID '%s'"PREFIXwpnid)
   }
  }
 } else {
  
// No weapons are registered to WeaponMod
  
client_print(idprint_console"%s No weapons available"PREFIX)
 }
 
 return 
PLUGIN_HANDLED
}
// Checks if the given plugin is enabled
is_plugin_enabled(id)
{
 new 
temp[2],status[16]
 
get_plugin(idtemp1temp1temp1temp1status15)
 if(
status[0] == 's' || status[0] == 'p')
 {
  return 
false
 
}
 return 
true
}
// Menu command
public cmdMenu(id)
{
 if(!
get_pcvar_num(g_Enabled)) return PLUGIN_HANDLED
 
if(!canBuyWeapon(id)) return PLUGIN_HANDLED
 
 
if(wpn_weapon_count() > 0)
 {
  
// Display menu at page 1
  
g_MenuPage[id] = 0
  showBuyMenu
(id)
 } else {
  
// No weapons available
  
client_print(idprint_chat"%s No weapons available"PREFIX)
 }
 
 return 
PLUGIN_HANDLED
}
// Displays WeaponMod buymenu
public showBuyMenu(id)
{
 
// Init variables, get weapon count and calculate amount of pages
 
new menu[512], keys
 
new wpnCount wpn_weapon_count()
 new 
pageCount = (wpnCount/8) + (((wpnCount%8) > 0) ? 0)
 
 
// Add menu header
 
new len
 
if(g_ColoredMenus)
  
len formatex(menu511"%s\R%d/%d^n\w^n"g_MenuTitleg_MenuPage[id]+1pageCount)
 else
  
len formatex(menu511"%s - Page %d/%d^n^n"g_MenuTitleg_MenuPage[id]+1pageCount)
 
 
// Calculate weapon start index and end index of all available weapons
 
new start g_MenuPage[id]*8
 
new end = (((start+8) <= wpnCount) ? start+wpnCount)
 new 
money wpn_gi_get_offset_int(idoffset_money)
 new 
costweapon[32]
 
 
// Now cycle through all weapons
 
for(new startendi++)
 {
  
cost wpn_get_integer(iwpn_cost)
  
wpn_get_string(iwpn_nameweapon31)
  if(
cost <= money)
  {
   if(
is_plugin_enabled(wpn_get_integer(iwpn_pluginid)))
   {
    
// Weapon is enabled, add it to the menu and allow pressing the specifiec number
    
keys |= (1<<i-start)
    if(
g_ColoredMenus)
     
len += formatex(menu[len], 511-len"%d. %s \R\y$%d\w^n"i+1-startweaponcost)
    else
     
len += formatex(menu[len], 511-len"%d. %s - $%d^n"i+1-startweaponcost)
   } else {
    
// The current weapon is disabled
    
if(g_ColoredMenus)
     
len += formatex(menu[len], 511-len"\d%d. %s \R\rDISABLED\w^n"i+1-startweaponcost)
    else
     
len += formatex(menu[len], 511-len"#. %s - DISABLED^n"weaponcost)
   }
  } else {
   
// Player does not have enough money
   
if(g_ColoredMenus)
    
len += formatex(menu[len], 511-len"\d%d. %s \R\y$%d\w^n"i+1-startweaponcost)
   else
    
len += formatex(menu[len], 511-len"#. %s - $%d^n"weaponcost)
  }
 }
 
 if(
end wpnCount)
 {
  
// There are more weapons available and so more pages, add next button
  
keys |= (1<<8)
  
len += formatex(menu[len], 511-len"^n9. Next")
 }
 
 
// If we're on the first page, we add the exit button, otherwise the back
 
keys |= (1<<9)
 if(
start <= 0)
  
len += formatex(menu[len], 511-len"^n0. Exit")
 else
  
len += formatex(menu[len], 511-len"^n0. Back")
 
 
// Finally show the generated menu
 
show_menu(idkeysmenu)
 return 
PLUGIN_CONTINUE
}
// Handles WeaponMod buymenu
public actionBuyMenu(id,key)
{
 switch(
key)
 {
  case 
8:
  {
   
// Next page
   
g_MenuPage[id]++
   
showBuyMenu(id)
  }
  case 
9:
  {
   if(
g_MenuPage[id] > 0)
   {
    
// Previous page
    
g_MenuPage[id]--
    
showBuyMenu(id)
   }
  }
  default:
  {
   
// Buy weapon
   
client_cmd(id"wpnbuy %d"g_MenuPage[id]*8+key)
  }
 } 
__________________
+Karma is appreciated! |Be PROUD, leave your name!

Last edited by KingCommentor; 08-01-2008 at 14:57.
KingCommentor is offline
Send a message via AIM to KingCommentor
 



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:33.


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