Raised This Month: $ Target: $400
 0% 

Grenade stuff + Kill money


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sputnik53
Senior Member
Join Date: Jun 2005
Old 10-07-2007 , 14:37   Grenade stuff + Kill money
Reply With Quote #1

I'm having problems with grenade stuff and the Kill money plugin in Condition Zero

1. How would I detect when a grenade touches the player and then make the grenade explode on touch.
2. I'm trying to detect if a player is killed with a grenade.
Code:
public event_death() { new iFlags = get_gore_flags() new iOrigin[3] new sWeapon[MAX_NAME_LENGTH] new iVictim = read_data(2) if(is_user_connected(iVictim)) { new iHeadshot = read_data(3) new wWeapon = read_data(4) read_data(4,sWeapon,MAX_NAME_LENGTH) if (iFlags&GORE_HEADSHOT && iHeadshot) { get_user_origin(iVictim,iOrigin) fx_headshot(iOrigin) } if (wWeapon == 4 && iFlags&GORE_GIB) { get_user_origin(iVictim,iOrigin) // Effects //fx_trans(iVictim,0) fx_gib_explode(iOrigin,20) fx_blood_large(iOrigin,20) fx_blood_small(iOrigin,20) // Hide body iOrigin[2] = iOrigin[2]-200 set_user_origin(iVictim,iOrigin) } } }
This doesn't seem to be working, I've also tried CSW_HEGRENADE but it still didn't work.
3. This plugin doesn't seem to work.
Code:
#include <amxmod> #include <amxmisc> #include <fun> #define PLUGIN      "Kill Money" #define VERSION     "1.3" #define AUTHOR      "Sputnik53" public plugin_init() {     register_plugin(PLUGIN,VERSION,AUTHOR)     register_cvar("amx_money_kill","300")     register_cvar("amx_money_hs","300")     register_cvar("amx_money_knife","600")     register_event("DeathMsg","DeathEvent","a") } public DeathEvent() {     new killer = read_data(1)     new victim = read_data(2)     new headshot = read_data(3)     new weapon = read_data(4)     new killer_team = get_user_team(killer)     new victim_team = get_user_team(victim)         if(killer_team == victim_team) return PLUGIN_CONTINUE         set_user_money(killer,get_user_money(killer)-300)         if(headshot == 1) {         set_user_money(killer,get_user_money(killer)+get_cvar_num("amx_money_hs"))     }         if(weapon == 29) {         set_user_money(killer,get_user_money(killer)+get_cvar_num("amx_money_knife"))     }         set_user_money(killer,get_user_money(killer)+get_cvar_num("amx_money_kill"))     return PLUGIN_CONTINUE }

EDIT: 2. and 3. fixed.

Last edited by Sputnik53; 10-07-2007 at 17:41. Reason: Solved 2 problems.
Sputnik53 is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 06:59   Re: Grenade stuff + Kill money
Reply With Quote #2

A little bit of register_touch() would make you happy, I assume.

Just gotta find the thrown hegren classname, and you're sorted.

(To make a nade explode, I think you set its next think time to now+0.1 )

EDIT: It's called "grenade"

Here is how to do it with FakeMeta :
PHP Code:
#include <amxmodx>
#include <fakemeta>
public plugin_init() 
{
    
register_forward(FM_Touch,"on_touch"// call the function "on_touch" when two ent's collide
}
public 
on_touch(ent1,ent2)
{
    static 
class1[32],class2[32],temp,Float:thetime// use static variables, since this could be called a lot ...
    
pev(ent1,pev_classname,class1,sizeof class1 1// get the classname of ent 1
    
pev(ent2,pev_classname,class2,sizeof class2 1// and ent 2
    
    
if ( equal(class1,"player") && equal(class2,"grenade") ) // if it's a player and a 'nade
    
{
        
global_get(glb_time,thetime// get the current time
        
set_pev(ent2,pev_nextthink,thetime+0.1//  tell it to "think" (explode) in 0.1 seconds
        
return ; // and quit
    
}
    if ( 
equal(class2,"player") && equal(class1,"grenade") ) // same as above, but this time the other ent is the nade. (this might not ever happen, I don't know whether, say, ent1 will always be the one with the lower ent-id )
    
{
        
global_get(glb_time,thetime)
        
set_pev(ent1,pev_nextthink,thetime+0.1)
        return ;        
    }

If you really want it in engine I can probably show you how it's done with engine.

Last edited by purple_pixie; 10-08-2007 at 07:17.
purple_pixie is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 10-08-2007 , 09:58   Re: Grenade stuff + Kill money
Reply With Quote #3

Quote:
Originally Posted by purple_pixie View Post
If you really want it in engine I can probably show you how it's done with engine.
Would love if you showed it.

EDIT: Haha

Last edited by Sputnik53; 10-08-2007 at 10:45.
Sputnik53 is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 10-08-2007 , 11:13   Re: Grenade stuff + Kill money
Reply With Quote #4

This is actually much easier with engine, since the "register_touch" function allows you to input the two classnames.

So we don't have to examine the two touchers - we know they are a player and a nade.
PHP Code:
#include <amxmodx>
#include <engine>
public plugin_init() 
{
    
register_touch("player","grenade","on_touch"// call the function "on_touch" when a grenade and player collide
}
public 
on_touch(id,nade)
{
    
entity_set_float(nade,EV_FL_nextthink,halflife_time()+0.01)

purple_pixie is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 10-08-2007 , 11:19   Re: Grenade stuff + Kill money
Reply With Quote #5

Dunno if you set the nade think will make it explode but, setting
Code:
set_pev(ent, pev_dmgtime, 0.0)
will!
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 10-08-2007 , 14:40   Re: Grenade stuff + Kill money
Reply With Quote #6

Ok I got it working, thank you both.

Last edited by Sputnik53; 10-08-2007 at 14:42.
Sputnik53 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 16:09.


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