| Trp. Jed |
09-21-2004 13:51 |
Depending on who touched who first you could check properties of the toucher and touchee entity (such as classname) to identify if they are ones you want to care about. Ones you've identified that they are, you'll need to write the relevant logic to make a descision on what to do.
An example from some code I've written in my own plugin:
Code:
// check if the grenade has hit something
//
public pfn_touch(ptr, ptd) {
// get the name of the touching entity
new classname[32]
entity_get_string(ptr, EV_SZ_classname, classname, 32)
// was it a smoke grenade?
if (equali(classname, "smoke_grenade")) {
// is it on the ground?
if (entity_get_int(ptr, EV_INT_flags) & FL_ONGROUND)
{
// handle smoke grenade hitting ground
}else {
// hangle grenade hitting anything but ground
}
}
return PLUGIN_CONTINUE
}
In this case ptr is the "toucher", ptd is the "touched". Im checking if the entity was of classname "smoke_grenade" and if it was on the ground.
You would use something similar but alter the logic to taste. However ptr and ptd are still valid.
|