AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with a little NS script... (https://forums.alliedmods.net/showthread.php?t=10606)

XunTric 02-24-2005 12:09

Need help with a little NS script...
 
Hey what im trying to make is a plugin that gives a HMG to a player. When i try to compile this, it comes "argument mismatch" or something. Come somebody help me? Avalanche??? hehe :lol: Here it is:
Code:
#include <amxmodx> #include <amxmisc> #include <ns> public plugin_init() {     register_plugin("Weapon Giver (Marines)", "1.0", "XunTric")     register_concmd("amx_hmg", "hmg", ADMIN_KICK, "<name> Gives a player a HMG") } public hmg(id,level,cid) {         if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     new name[64];     get_user_name(player,name,63);     ns_give_item(player, WEAPON_HMG)     client_print(player, print_chat, "The admin gave you a HMG")              return PLUGIN_HANDLED }

XxAvalanchexX 02-24-2005 15:00

What is the point of getting their username? You don't use it.

Anyway, the ns_give_item function accepts a string as the last parameter. It should be the classname of the entity you wish to give. Try this:

Code:
ns_give_item(player,"weapon_hmg")

XunTric 02-24-2005 15:14

It worked! 8) Thanks. Im making a "All in one" with all weapons hehe.
But i still get a "loose indentation" (or what its called :lol: ) warning. How do i get this away?

XxAvalanchexX 02-24-2005 15:19

It's your last PLUGIN_HANDLED that isn't aligned with the other stuff.

XunTric 02-24-2005 17:00

I dont understand... Use PLUGIN_CONTINUE instead then? Anyway it didnt work. It comes "cant create enitity WEAPON_HMG" or something like that when i try to use the command... Could you help me with that too??

XxAvalanchexX 02-24-2005 18:45

Turns out you have to use "weapon_heavymachinegun". These are the names:

weapon_machinegun : Machine gun
weapon_pistol : Pistol
weapon_heavymachinegun : Heavy machine gun
weapon_grenadegun : Grenade launcher
weapon_shotgun : Shotgun
weapon_welder : Welder
weapon_mine : Pack of mines

item_health : Health pack
item_genericammo : Ammo
item_jetpack : Jetpack
item_heavyarmor : Heavy armor
item_mine : Deployed mine

As for the indentation warning, let's take a look:

Code:
#include <amxmodx> #include <amxmisc> #include <ns> public plugin_init() {     register_plugin("Weapon Giver (Marines)", "1.0", "XunTric")     register_concmd("amx_hmg", "hmg", ADMIN_KICK, "<name> Gives a player a HMG") } public hmg(id,level,cid) {         if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     ns_give_item(player, "weapon_heavymachinegun")     client_print(player, print_chat, "The admin gave you a HMG")           // NOTICE HOW ns_give_item and client_print are aligned     // if you look at return PLUGIN_HANDLED, you will see it isn't:          return PLUGIN_HANDLED     // So align it properly:     return PLUGIN_HANDLED }

XunTric 02-25-2005 12:39

Omg how do you know all stuff? Thanks..

Freecode 02-25-2005 12:45

http://forums.alliedmods.net/showthread.php?t=6481

XunTric 02-25-2005 13:01

Thanks freecode reading it now 8)
Download my plugin here :D

XxAvalanchexX 02-25-2005 16:54

How do I know the names of the items? I took a look at the ns.fgd that comes with Natural Selection.


All times are GMT -4. The time now is 13:57.

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