AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] My first plugin (https://forums.alliedmods.net/showthread.php?t=106214)

Milano 10-12-2009 12:06

[HELP] My first plugin
 
Hi.
First I wanna say that this my first plugin, and I new to scripting. So I was wondering if I can get help. Here is code, but I get many errors I dont know to fix. So if you can help me fix the errors, I appreciate.

PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <cstrike>
#include <fun>
#include <fakemeta_util>
 
#define PLUGIN "Weaponmod"
#define VERSION "1.0"
#define AUTHOR "Milano"
 
new g_CvarOn
new szPrefix[19] = "[WM]"
new g_MaxPlayers;
 
public 
plugin_init() {
 
register_plugin(PLUGINVERSIONAUTHOR)
 
 
register_clcmd"say /weapons""MenuWeapons" )
 
register_clcmd"say_team /weapons""MenuWeapons" )
 
 
g_CvarOn register_cvar"wm_enable""1" )
 
register_cvar("wm_blockbuy""1"
 
register_cvar("wm_prefix"szPrefix)
 
 
g_MaxPlayers get_maxplayers( );
 
 
 if (
get_cvar_num("wm_blockbuy"))
 {
  
register_clcmd("buy""bblocked");
  
register_clcmd("cl_autobuy""bblocked");
  
register_clcmd("cl_rebuy""bblocked");
  
register_clcmd("cl_setautobuy""bblocked");
  
register_clcmd("cl_setrebuy""bblocked");
 
  
register_clcmd("glock""bblocked");
  
register_clcmd("usp""bblocked");
  
register_clcmd("p228""bblocked");
  
register_clcmd("deagle""bblocked");
  
register_clcmd("elites""bblocked");
  
register_clcmd("fn57""bblocked");
 
  
register_clcmd("mp5""bblocked");
  
register_clcmd("smg""bblocked");
  
register_clcmd("mac10""bblocked");
  
register_clcmd("tmp""bblocked");
  
register_clcmd("ump45""bblocked");
  
register_clcmd("p90""bblocked");
 
  
register_clcmd("m3""bblocked");
  
register_clcmd("xm1014""bblocked");
 
  
register_clcmd("famas""bblocked");
  
register_clcmd("m4a1""bblocked");
  
register_clcmd("ak47""bblocked");
  
register_clcmd("sg552""bblocked");
  
register_clcmd("galil""bblocked"); 
  
register_clcmd("aug""bblocked");
 
  
register_clcmd("scout""bblocked");
  
register_clcmd("awp""bblocked");
  
register_clcmd("sg550""bblocked");
  
register_clcmd("g3sg1""bblocked");
 
  
register_clcmd("m249""bblocked");
 
  
register_clcmd("hegren""bblocked");
  
register_clcmd("flash""bblocked");
  
register_clcmd("sgren""bblocked");
  
register_clcmd("vest""bblocked");
  
register_clcmd("vesthelm""bblocked");
  
register_clcmd("shield""bblocked");
  
register_clcmd("buyammo1""bblocked");
  
register_clcmd("buyammo1""bblocked");
  
register_clcmd("buyequip""bblocked");
 }
}
public 
MenuWeaponsid )
{
 if( 
get_user_teamid ) == CS_TEAM_CT 
 
&& get_pcvar_numg_CvarOn 
 && 
is_user_aliveid ) )
{
 new 
menu menu_create"Weapons""WeaponsHandle" )
 
 
menu_additemmenu"Rifleman""1")
 
menu_additemmenu"Support Infantry""2")
 
menu_additemmenu"Assault""3")
 
menu_additemmenu"Light Infantry""4")
 
menu_additemmenu"Sniper""5")
 
menu_additemmenu"Machine Gunner""6"
 
 
menu_setpropmenuMPROP_EXITMEXIT_NEVER ); 
 
menu_displayidmenu)
 return 
PLUGIN_HANDLED;
}
return 
PLUGIN_CONTINUE
}
public 
WeaponsHandleidmenuitem )
{
if( 
item == MENU_EXIT )
{
 
menu_destroymenu )
 return 
PLUGIN_HANDLED
}
new 
szData], szName64 ], iAccessiCallbackszWeapon33 ][ 32 ], szPrint33 ][ 32 ]
menu_item_getinfomenuitemiAccessszData5szName63iCallback )
new 
key str_to_numszData )
switch( 
key )
{
 case 
1
 {
  
szWeaponid ] = "weapon_m4a1"
  
szWeaponid ] = "weapon_usp"
  
szPrintid ] = "M4A1 & Usp"
 
}
 case 
2:
 {
  
szWeaponid ] = "weapon_m3"
  
szWeaponid ] = "weapon_deagle"
  
szPrintid ] = "M3 & Deagle"
 
}
 case 
3:
 {
  
szWeaponid ] = "weapon_famas"
  
szWeaponid ] = "weapon_glock18"
  
szPrintid ] = "Famas & Glock"
 
}
 case 
4:
 {
  
szWeaponid ] = "weapon_mp5"
  
szWeaponid ] = "weapon_usp"
  
szPrintid ] = "MP5 & Usp"
 
}
 case 
5:
 {
  
szWeaponid ] = "weapon_awp"
  
szWeaponid ] = "weapon_glock18"
  
szPrintid ] = "AWP & Glock"
 
}
 case 
6:
 {
  
szWeaponid ] = "weapon_m249"
  
szWeaponid ] = "weapon_fiveseven"
  
szPrintid ] = "Para & Fiveseven"
 
}
 
 
strip_user_weaponsid )
 
give_itemidszWeaponid ] )
 
client_printidprint_chat"You now have %s"szPrint )
 
 
menu_destroymenu )
 return 
PLUGIN_HANDLED;
}  
public 
MenuWeapons1id )
{
 if( 
get_user_teamid ) == CS_TEAM_T 
 
&& get_pcvar_numg_CvarOn 
 && 
is_user_aliveid ) )
{
 new 
menu menu_create"Weapons""WeaponsHandle1" )
 
 
menu_additemmenu"Rifleman""1")
 
menu_additemmenu"Support Infantry""2")
 
menu_additemmenu"Assault""3")
 
menu_additemmenu"Light Infantry""4")
 
menu_additemmenu"Sniper""5")
 
menu_additemmenu"Machine Gunner""6"
 
 
menu_setpropmenuMPROP_EXITMEXIT_NEVER ); 
 
menu_displayidmenu)
 return 
PLUGIN_HANDLED;
}
return 
PLUGIN_CONTINUE
}
public 
WeaponsHandle1idmenuitem )
{
if( 
item == MENU_EXIT )
{
 
menu_destroymenu )
 return 
PLUGIN_HANDLED
}
new 
szData], szName64 ], iAccessiCallbackszWeapon33 ][ 32 ], szPrint33 ][ 32 ]
menu_item_getinfomenuitemiAccessszData5szName63iCallback )
new 
key str_to_numszData )
switch( 
key )
{
 case 
1
 {
  
szWeaponid ] = "weapon_AK47"
  
szWeaponid ] = "weapon_glock18"
  
szPrintid ] = "AK47 & Glock"
 
}
 case 
2:
 {
  
szWeaponid ] = "weapon_xm1014"
  
szWeaponid ] = "weapon_deagle"
  
szPrintid ] = "XM1014 & Deagle"
 
}
 case 
3:
 {
  
szWeaponid ] = "weapon_galil"
  
szWeaponid ] = "weapon_fiveseven"
  
szPrintid ] = "Galil & Fiveseven"
 
}
 case 
4:
 {
  
szWeaponid ] = "weapon_ump45"
  
szWeaponid ] = "weapon_elite"
  
szPrintid ] = "UMP45 & Dualies"
 
}
 case 
5:
 {
  
szWeaponid ] = "weapon_awp"
  
szWeaponid ] = "weapon_usp"
  
szPrintid ] = "AWP & Usp"
 
}
 case 
6:
 {
  
szWeaponid ] = "weapon_m249"
  
szWeaponid ] = "weapon_p228"
  
szPrintid ] = "Para & P228"
 
}
 
 
strip_user_weaponsid )
 
give_itemidszWeaponid ] )
 
client_printidprint_chat"You now have %s"szPrint )
 
 
menu_destroymenu )
 return 
PLUGIN_HANDLED;
}  
public 
bblocked(id)
{
 
show_motd(id,GREEN"%L"id"%s Buy and Buy Bind's are Blocked."szPrefix);
 return 
PLUGIN_HANDLED


I want weaponshandle1 and menuweapons1 to be for Terrorist only, and WeaponsHandle and menuweapons to be for CT only. And I want to disable buy command. Please help, sorry for bad english.

xPaw 10-12-2009 12:15

Re: [HELP] My first plugin
 
If you coded all this (probably not) then you would easily know how to fix errors.

Milano 10-12-2009 12:17

Re: [HELP] My first plugin
 
I code mostly all myself, I saw on others how they do, and I do myself. I just copy the stuff to block buy command, rest I make by tutorials and look on other plugins.

I see on errors I get when compile, but I dont understand how fix them.

xPaw 10-12-2009 12:23

Re: [HELP] My first plugin
 
get_user_team -> cs_get_user_team

You forget to add } line 147 & 225
Code:
 case 6:  {   szWeapon[ id ] = "weapon_m249"   szWeapon[ id ] = "weapon_fiveseven"   szPrint[ id ] = "Para & Fiveseven"  } }  strip_user_weapons( id )

Why you're doing show_motd ? Maybe you wanted to do ColorChat?

SnoW 10-12-2009 12:23

Re: [HELP] My first plugin
 
Don't bother xPaw.
He obviously can't listen anyone or fix the errors even they are told to him. http://forums.alliedmods.net/showthread.php?t=106211

Milano 10-12-2009 12:26

Re: [HELP] My first plugin
 
I did what you tell me snow, but it still has errors.

OneMoreLevel 10-12-2009 16:21

Re: [HELP] My first plugin
 
Try Ctrl-I, your code doesnt look indented.


All times are GMT -4. The time now is 22:36.

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