Raised This Month: $ Target: $400
 0% 

Register touch and pick up?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 02-20-2007 , 14:23   Re: Register touch and pick up?
Reply With Quote #1

If you are going do it with engine, register_touch is alot easier to use imo.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Owner"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_touch("item_healthkit""player""touch_healthkit")
}

public 
touch_healthkit(entid)
{
    if(!
is_valid_ent(ent) || !is_user_alive(id))
        return 
PLUGIN_CONTINUE
    
    
//do stuff
    
    //remove ent if touched (do some checks first to make sure they player meets your requirements)
    
remove_entity(ent)
    
    
    return 
PLUGIN_CONTINUE

Another way is setting the classname and let hl handle it. An example would be Healthkit (like in HL) by VEN.
__________________
HDD fried, failed to backup files. Sorry folks, just don't have free time anymore. This is goodbye.
Cheap_Suit is offline
Davidos
Senior Member
Join Date: Feb 2005
Old 02-20-2007 , 17:29   Re: Register touch and pick up?
Reply With Quote #2

Quote:
Originally Posted by Cheap_Suit View Post
If you are going do it with engine, register_touch is alot easier to use imo.

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <engine>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Owner"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_touch("item_healthkit""player""touch_healthkit")
}

public 
touch_healthkit(entid)
{
    if(!
is_valid_ent(ent) || !is_user_alive(id))
        return 
PLUGIN_CONTINUE
    
    
//do stuff
    
    //remove ent if touched (do some checks first to make sure they player meets your requirements)
    
remove_entity(ent)
    
    
    return 
PLUGIN_CONTINUE

Another way is setting the classname and let hl handle it. An example would be Healthkit (like in HL) by VEN.

Thanks alot, too bad I can't karma you anymore... damn system...


anyway...

I tested this on SCSTUFF plugin

Code:
public touch_healthkit(ent, id) {     if(is_valid_ent(ent) || is_user_alive(id) || get_user_health(id) > 75)     {         player_kits[id] +=1         client_print(id,print_chat,"[SCSP] You picked up a medkit! (%i medkits left)",player_kits[id])         remove_entity(ent)         return PLUGIN_HANDLED     }       else     {               return PLUGIN_HANDLED     }     return PLUGIN_HANDLED }

gives me tag mismatch, and when on <75 hp it forces the entity to go into inventory.

Although if I spawn it on myself it works so I just have to pick it up and use it <more realistic anyway -_->

Plus the medkits don't respawn, I suspected this... but how do I fix it?

Last edited by Davidos; 02-20-2007 at 17:34.
Davidos 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 00:42.


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