AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Grenade stuff + Kill money (https://forums.alliedmods.net/showthread.php?t=61699)

Sputnik53 10-07-2007 14:37

Grenade stuff + Kill money
 
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.

purple_pixie 10-08-2007 06:59

Re: Grenade stuff + Kill money
 
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.

Sputnik53 10-08-2007 09:58

Re: Grenade stuff + Kill money
 
Quote:

Originally Posted by purple_pixie (Post 539944)
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

purple_pixie 10-08-2007 11:13

Re: Grenade stuff + Kill money
 
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)



Alka 10-08-2007 11:19

Re: Grenade stuff + Kill money
 
Dunno if you set the nade think will make it explode but, setting
Code:

set_pev(ent, pev_dmgtime, 0.0)
will! :)

Sputnik53 10-08-2007 14:40

Re: Grenade stuff + Kill money
 
Ok I got it working, thank you both.


All times are GMT -4. The time now is 16:09.

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