Raised This Month: $ Target: $400
 0% 

help with simple give_item plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ZiP*
Senior Member
Join Date: Jul 2004
Old 03-13-2005 , 17:11   help with simple give_item plugin
Reply With Quote #1

I made a plugin so simple that my cat could do it bettet o_O
But anyway it won't work

When i type "amx_weapon brhbgfrdbgfse" i get the weapons anyway?!

Code:
 #include   <amxmodx>  #include   <amxmisc>  #include   <fun>  public plugin_init()  {     register_plugin("Weapon Plugin","1.0","[ZiP*]")     register_concmd("amx_weapon","admin_weapon",ADMIN_SLAY,"'name'")     register_concmd("amx_weaponf","admin_weapon1",ADMIN_SLAY,"'name'")     register_concmd("amx_weaponm","admin_weapon2",ADMIN_SLAY,"'name'")     register_concmd("amx_weaponb","admin_weapon3",ADMIN_SLAY,"'name'")     return PLUGIN_CONTINUE  }  public admin_weapon(id, level, cid)  {     if ( !cmd_access(id,level,cid,2) )         return PLUGIN_HANDLED     new name[32]     get_user_name(id,name,32)     give_item(id,"weapon_vsstake")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vscue")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsdbshotgun")     set_hudmessage(20,200,10,-1.0,0.30,0,6.0,6.0,0.5,0.15,1)     show_hudmessage(0,"%s got the ALL-IN-ONE weapon pack!",name)     return PLUGIN_HANDLED  }  public admin_weapon1(id, level, cid)  {     if ( !cmd_access(id,level,cid,2) )         return PLUGIN_HANDLED     new name[32]     get_user_name(id,name,32)     give_item(id,"weapon_vsstake")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsdbshotgun")     give_item(id,"weapon_vsdbshotgun")         set_hudmessage(30,200,10,-1.0,0.30,0,6.0,6.0,0.5,0.15,1)     show_hudmessage(0,"%s got the FATHER D weapon pack!",name)     return PLUGIN_HANDLED  }  public admin_weapon2(id, level, cid)  {     if ( !cmd_access(id,level,cid,2) )         return PLUGIN_HANDLED     new name[32]     get_user_name(id,name,32)     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     give_item(id,"weapon_vscolt")     give_item(id,"weapon_vsmp5")     give_item(id,"weapon_vscrossbow")     set_hudmessage(10,220,16,-1.0,0.30,0,6.0,6.0,0.5,0.15,1)     show_hudmessage(0,"%s got the 8BALL weapon pack!",name)     return PLUGIN_HANDLED  }  public admin_weapon3(id, level, cid)  {     if ( !cmd_access(id,level,cid,2) )         return PLUGIN_HANDLED     new name[32]     get_user_name(id,name,32)     give_item(id,"weapon_vscue")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     give_item(id,"weapon_vsthunderfive")     give_item(id,"weapon_vswinchester")     set_hudmessage(10,200,10,-1.0,0.30,0,6.0,6.0,0.5,0.15,1)     show_hudmessage(0,"%s got the 8BALL weapon pack!",name)     return PLUGIN_HANDLED  }

there must be an easier way to code that =)
ZiP* is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-13-2005 , 19:45  
Reply With Quote #2

Make your command functions look like this...

Code:
public admin_weapon(id, level, cid) {     if ( !cmd_access(id,level,cid,1) )         return PLUGIN_HANDLED     new name[32], argv[32]     read_argv( 1, argv, 31 )     new target = cmd_target( id, argv, 2 )     if( !target )     {         client_print( id, print_chat, "Target '%s' Not Found!", argv )         return PLUGIN_HANDLED     }     get_user_name(target ,name,31)     give_item(target,"weapon_vsstake")     // etc...     set_hudmessage(20,200,10,-1.0,0.30,0,6.0,6.0,0.5,0.15,1)     show_hudmessage(0,"%s got the ALL-IN-ONE weapon pack!",name)     return PLUGIN_HANDLED }
xeroblood is offline
Send a message via MSN to xeroblood
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-13-2005 , 19:52  
Reply With Quote #3

Silly xeroblood, cmd_target automatically prints out a message if it couldn't find the target, just like cmd_access does if you don't have access or use invalid parameters.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-13-2005 , 19:53  
Reply With Quote #4

Yes, I know.. but either way, you dont want to continue if the target is invalid, and since this is an example, I put a sample statement, so the reader may know what's going on..

There is a method to my madness!!
xeroblood is offline
Send a message via MSN to xeroblood
ZiP*
Senior Member
Join Date: Jul 2004
Old 03-14-2005 , 01:05  
Reply With Quote #5

Thank you, i'll test it later today.

I didn't know how to use arguments, and i still don't know what they're doing
I think it's a way to make 'if the one value is wrong, it takes the other'?
ZiP* is offline
ZiP*
Senior Member
Join Date: Jul 2004
Old 03-16-2005 , 09:39  
Reply With Quote #6

It seems to display the right name, but however when i type "amx_weapons LoLlolLOL" it gives the weapons to me..
ZiP* is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-16-2005 , 13:38  
Reply With Quote #7

Did you change the "id" in all the give_item's to "target"?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
ZiP*
Senior Member
Join Date: Jul 2004
Old 03-16-2005 , 14:44  
Reply With Quote #8

Thank You

Such a small thing
ZiP* 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 14:03.


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