AlliedModders

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

stigma 02-12-2007 19:51

give_item
 
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")     }

XxAvalanchexX 02-12-2007 20:37

Re: give_item
 
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.

Phantom Warrior 02-12-2007 20:42

Re: give_item
 
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")
    



stigma 02-12-2007 20:47

Re: give_item
 
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.. :/?

Phantom Warrior 02-12-2007 20:54

Re: give_item
 
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 02-12-2007 20:55

Re: give_item
 
Copy and Post full code.

stigma 02-12-2007 20:55

Re: give_item
 
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 02-12-2007 20:56

Re: give_item
 
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")     } }

Phantom Warrior 02-12-2007 20:56

Re: give_item
 
Quote:

Copy and Post full code.

XxAvalanchexX 02-12-2007 20:57

Re: give_item
 
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?


All times are GMT -4. The time now is 11:05.

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