Raised This Month: $ Target: $400
 0% 

give_item


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 19:51   give_item
Reply With Quote #1

Hi, im having a problem with giving an item to a killer.

It aint giving the nade to the killer.

Code:
#include <amxmodx> #include <fun> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("DeathMsg","giveItem","ae") } public giveItem() {         new killer = read_data(1)     new victim = read_data(2)         new kName[32], vName[32]         get_user_name(killer,kName,31)     get_user_name(victim,vName,31)         client_print(0,print_chat,"Killer: %s - Victim: %s",kName,vName)         give_item(killer,"CSW_HEGRENADE")     }
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-12-2007 , 20:37   Re: give_item
Reply With Quote #2

Use "weapon_hegrenade", not "CSW_HEGRENADE". Also, you don't need to use the "e" flag in register_event, because it's a global event.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-12-2007 , 20:42   Re: give_item
Reply With Quote #3

This is part of my new release(TFC Weapons)
Does this give you a hint?

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <tfcx>
#include <fun>

#define PLUGIN "TFC Weapons"
#define VERSION "1.0"
#define AUTHOR "Phantom Warrior"

public plugin_init() {
    
register_plugin("WeaponMe","0.1","Phantom Warrior)"
    
register_clcmd("say needrocket","fnSayNeedRocket")
    
register_clcmd("say needshotgun","fnSayNeedShotGun")
    
register_clcmd("say needknife","fnSayNeedKnife")
    
register_clcmd("say needsniper","fnSayNeedSniper")
    
register_clcmd("say needautorifle","fnSayNeedAutoRifle")
    
register_clcmd("say needflamer","fnSayNeedFlamer")
    
register_clcmd("say needrail","fnSayNeedRail")
    
register_clcmd("say needmedkit","fnSayNeedMedkit")
    
register_clcmd("say needac","fnSayNeedAc")
   
}

public 
fnSayNeedRocket(id) {
    
give_item(id"tf_weapon_rpg")
    
tfc_setbammo(idTFC_AMMO_ROCKETS,25)
    
client_cmd(id"tf_weapon_rpg")
    
}

public 
fnSayNeedKnife(id) {
    
give_item(id,"tf_weapon_knife")
    
client_cmd(id,"tf_weapon_knife")
    
}

public 
fnSayNeedShotGun(id) {
    
give_item(id"tf_weapon_shotgun")
    
client_cmd(id"tf_weapon_shotgun")
   
   }
   
  public 
fnSayNeedSniper(id) {
       
give_item(id"tf_weapon_sniperrifle")
    
client_cmd(id"tf_weapon_sniperrifle")
    
}

public 
fnSayNeedAutoRifle(id) {
    
give_item(id"tf_weapon_autorifle")
    
client_cmd(id"tf_weapon_autorifle")
    
}

public 
fnSayNeedFlamer(id) {
    
give_item(id"tf_weapon_flamethrower")
    
client_cmd(id"tf_weapon_flamethrower")
    
}

public 
fnSayNeedRail(id) {
    
give_item(id"tf_weapon_railgun")
    
client_cmd(id"tf_weapon_railgun")
    
}

public 
fnSayNeedMedKit(id) {
    
give_item(id"tf_weapon_railgun")
    
client_cmd(id"tf_weapon_railgun")
    
}

public 
fnSayNeedAc(id) {
    
give_item(id"tf_weapon_ac")
    
client_cmd(id"tf_weapon_ac")
    

Phantom Warrior is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 20:47   Re: give_item
Reply With Quote #4

Okay thanks..

I was also wondering, why cant i do this:

Code:
get_user_frags(id) / get_user_deaths(id)


I want to find the kill ratio.. But the i get "Run time error: 11 - Divide"

Edit:

I've just tryed it, and it works, but it is like it's repeating itself 10 times.
I gives me loads of nades when im killing an enemy.. :/?

Last edited by stigma; 02-12-2007 at 20:54.
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-12-2007 , 20:54   Re: give_item
Reply With Quote #5

I'll rewrite your code. (The First Part)

PHP Code:
#include <amxmodx>
#include <fun>

#define PLUGIN "Give Item"
#define VERSION "1.0"
#define AUTHOR "stigma

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg","giveItem","a")
}

public 
giveItem() {
    
    new 
killer read_data(1)
    new 
victim read_data(2)
    
    new 
kName[32], vName[32]
    
    
get_user_name(killer,kName,31)
    
get_user_name(victim,vName,31)
    
    
client_print(0,print_chat,"Killer: %s - Victim: %s",kName,vName)
    
    
give_item(killer,"weapon_hegrenade")
    

Don't know abou the get_user_frags and get_user_deaths.

Hm.
Phantom Warrior is offline
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-12-2007 , 20:55   Re: give_item
Reply With Quote #6

Copy and Post full code.
Phantom Warrior is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 20:55   Re: give_item
Reply With Quote #7

Okay.. I did the same as you.. But it's repeating it self 10 times or something, i just get loads of nades, when i kill an enemy...
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
Phantom Warrior
BANNED
Join Date: Feb 2007
Location: hello, gaben
Old 02-12-2007 , 20:56   Re: give_item
Reply With Quote #8

Quote:
Copy and Post full code.
Phantom Warrior is offline
stigma
Senior Member
Join Date: Mar 2005
Location: Denmark
Old 02-12-2007 , 20:56   Re: give_item
Reply With Quote #9

Code:
#include <amxmodx> #include <fun> #define PLUGIN "New Plugin" #define VERSION "1.0" #define AUTHOR "Author" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)         register_event("DeathMsg","giveItem","a")     } public giveItem() {             new killer = read_data(1)         new victim = read_data(2)             new kName[32], vName[32]             get_user_name(killer,kName,31)         get_user_name(victim,vName,31)           client_print(0,print_chat,"Killer: %s - Victim: %s",kName,vName)       if (killer != victim) {         give_item(killer,"weapon_hegrenade")     } }
stigma is offline
Send a message via MSN to stigma Send a message via Skype™ to stigma
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-12-2007 , 20:57   Re: give_item
Reply With Quote #10

stigma: As for dividing, the result will be an integer, which probably isn't the kind of ratio you want (no decimals). But, what is the context of that code? Are you assigning it to a variable, or just running that piece by itself?

As for it getting lots of grenades, here is the start of the GunGame DeathMsg hook, it should explain it to you:
Code:
    new Float:time = get_gametime();     // a bug with valve's code (dvander said so!):     // sometimes, when using an item giving code     // (as that's where this can lead) within a message     // hook, the message hook can get called twice.     // so, if this player "dies" twice within X seconds,     // it's obviously a bugged message, so ignore.     if(time - lastDeathMsg[victim] < 0.2)         return;     lastDeathMsg[victim] = time;

Phantom Warrior: Umm... it is his full code?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX 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 11:05.


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