AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Scripting Question (https://forums.alliedmods.net/showthread.php?t=10523)

FoX Rider 02-21-2005 21:36

Scripting Question
 
I would like to make a plugin that can give weapons to players.

Code:


#include <amxmodx>
#include <fun>

public plugin_init() {
        register_plugin("Give-Weapon","1.00","FoX")
        register_clcmd("amx_giveweapon","giveweapon",ADMIN_LEVEL_A,"Gives client a weapon")
}

public giveweapon(id) {

Would I just have to add get_user_weapon(m4a1,4,90) and then compile it?

Yes, I'm a newb.

XxAvalanchexX 02-21-2005 21:55

You would do it like this:

Code:
#include <amxmodx> #include <fun> public plugin_init() {    register_plugin("Give-Weapon","1.00","FoX")    register_clcmd("amx_giveweapon","giveweapon",ADMIN_LEVEL_A,"Gives client a weapon") } public giveweapon(id) {    give_item(id,"weapon_m4a1"); }

FoX Rider 02-21-2005 22:05

Thanks.

FoX Rider 02-22-2005 01:06

Heres what I have so far...

Code:

#include <amxmodx>
#include <fun>

public plugin_init() {
  register_plugin("Give-Weapon","1.00","FoX")
  register_clcmd("amx_giveweapon","giveweapon",ADMIN_LEVEL_A,"- Gives client a weapon")
  register_clcmd("amx_giveammo","giveammo",ADMIN_LEVEL_A,"- Gives client ammo")
}
public giveweapon(id) {
  give_item(id,"weapon_m4a1");
  return PLUGIN_HANDLED
}
 
public giveammo(id) {
        give_item(id,"ammo_m4a1")
        return PLUGIN_CONTINUE
}

But for some reason it wont give any ammo..Help?

XxAvalanchexX 02-22-2005 16:07

ammo_m4a1 is not a valid entity name for Counter-Strike.

FoX Rider 02-22-2005 19:12

Where would I find a list of valid entitys?

Or would i just have to use..

create_entity(ammo_m4a1)

??

Votorx 02-22-2005 19:19

You should use the easiest and most simple possible method given to you

*Hint Hint*
cs_set_weapon_ammo(index, newammo)

FoX Rider 02-22-2005 19:30

Ok heres my updated script..

Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

public plugin_init() {
  register_plugin("Give-Weapon","1.00","FoX")
  register_clcmd("amx_giveweapon","giveweapon",ADMIN_LEVEL_A,"- Gives client a weapon")
  register_clcmd("amx_giveammo","giveammo",ADMIN_LEVEL_A,"- Gives client ammo")
}
public giveweapon(id) {
  give_item(id,"weapon_m4a1");
  return PLUGIN_HANDLED
}
   
public giveammo(id) {
  cs_set_weapon_ammo(id,90)
  return PLUGIN_CONTINUE
}

Yet when I go in and test it, it says "Unknown command: amx_giveammo"

v3x 02-22-2005 19:35

Try..
Code:
#include <amxmodx> #include <cstrike> #include <fun> public plugin_init() {    register_plugin("Give-Weapon","1.00","FoX")    register_concmd("amx_giveweapon","giveweapon",ADMIN_LEVEL_A,"- Gives client a weapon")    register_concmd("amx_giveammo","giveammo",ADMIN_LEVEL_A,"- Gives client ammo") } public giveweapon(id) {    give_item(id,"weapon_m4a1");    return PLUGIN_CONTINUE }     public giveammo(id) {    cs_set_weapon_ammo(id,90)    return PLUGIN_CONTINUE }

FoX Rider 02-22-2005 19:46

That didnt work..

Ok, heres my current code.

Code:

#include <amxmodx>
#include <cstrike>
#include <fun>

public plugin_init() {
  register_plugin("Give-Weapon","1.00","FoX")
  register_concmd("amx_giveweapon","giveweapon",ADMIN_LEVEL_A,"- Gives client a weapon") 
}
public giveweapon(id) {
  give_item(id,"weapon_m4a1");
  give_item(id,"ammo_m4a1")
  client_print(id,print_chat,"[AMXX] The admin has given you a weapon")
  return PLUGIN_CONTINUE
}

It only gives me m4a1 with 30 bullets.


All times are GMT -4. The time now is 14:00.

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