AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   If entity touches player... (https://forums.alliedmods.net/showthread.php?t=25507)

Rixorster 03-15-2006 09:59

If entity touches player...
 
then he loses hp? How can i do like that, if my ent's name is Ent, and when Ent touches player, the player it touched loses hp?

v3x 03-15-2006 10:06

In plugin_init:
Code:
register_touch("Ent" , "player" , "touched_player");

Then:
Code:
public touched_player(ptr , ptd) {   if(is_user_connected(ptd) && is_user_alive(ptd)) {     set_user_health(ptd , get_user_health(ptd) - 5);   } }
;)

ChanT 03-16-2006 15:50

for what stands the ptr and ptd?
and how can i add more then 1 ent.. so like 3 entities?

Rixorster 03-16-2006 15:54

ptr= pToucher(this is the toucher)
ptd= pTouched(one that is touched)

v3x 03-16-2006 16:17

The touched will always be a player.

Rixorster 03-17-2006 01:52

Hmm, just an question, how can i check if its an entity?
Btw, thanks v3x ;D

Greenberet 03-17-2006 01:58

Code:
bool:is_entity( EntityID ) {       if( is_valid_ent( EntityID ) && EntityID > get_maxplayers() )              return true;       return false; }

this should work for you

VEN 03-17-2006 02:52

Player has entity either.

Quote:

The touched will always be a player
Not always.

Twilight Suzuka 03-17-2006 04:56

Yes, always. The touched MUST be a player, unless the transaction does not have a player in it.

VEN 03-17-2006 05:31

I mean in fact player can be toucher or touched.
But for register_touch("Ent" , "player" , "touched_player") touched would be the player since it filter out other classnames.


All times are GMT -4. The time now is 20:25.

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