Raised This Month: $ Target: $400
 0% 

Register touch and pick up?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 02-19-2007 , 19:15   Re: Register touch and pick up?
Reply With Quote #1

I don't understand what you're asking. Maybe you could rephrase it.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Davidos
Senior Member
Join Date: Feb 2005
Old 02-20-2007 , 04:19   Re: Register touch and pick up?
Reply With Quote #2

Wow, Sorry about that... late night yesterday...

Ok.

So, I have set up a basic inventory mod that allows you to pick up stuff from the ground and put them into your inventory.

Now frankly, the problem is... I have no idea how to make a script so you can pick an item up (Ammo, batteries etc.), delete the ent of the picked up item, and make it so that when you use it in your inventory,
it doesn't get re-added to your inventory in like 4 seconds, but is picked up by the player in game <so it gives you ammo and then disapears mod based, like how you would pick up anything in normal half-life 1>...


Code:
give item_healthkit //spawns healthkit in player


So frankly, if someone could write up an example/tutorial on how to use the
pfn_touch function, I can learn from that -_-.

Do you understand now?

Code:
pfn_touch(ent,id)
that's as far as my knowledge takes me...

Last edited by Davidos; 02-20-2007 at 04:31.
Davidos is offline
Cheap_Suit
Veteran Member
Join Date: May 2004
Old 02-20-2007 , 14:23   Re: Register touch and pick up?
Reply With Quote #3

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 #4

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