AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   fake_touch doesn't work for a weaponbox in the air (https://forums.alliedmods.net/showthread.php?t=308901)

sekac 07-07-2018 17:49

fake_touch doesn't work for a weaponbox in the air
 
So if I call fake_touch on a weaponbox that's in the air it doesn't work.
Here is the code:
PHP Code:

new ent find_ent_by_owner(-1"weaponbox"id)
        
fake_touch(entid

And the entity index is always the same, it doesn't matter if it's in the air or not.

Any way to do this?

Ghosted 07-08-2018 02:33

Re: fake_touch doesn't work for a weaponbox in the air
 
weaponbox has owner? Maybe use find_ent_by_class ?

sekac 07-08-2018 06:19

Re: fake_touch doesn't work for a weaponbox in the air
 
When I use find_ent_by_owner when a weapon is in the air it returns the same entity as when the weapon is on the ground, but fake_touch only works if it's on the ground for some reason.

HamletEagle 07-08-2018 06:48

Re: fake_touch doesn't work for a weaponbox in the air
 
https://github.com/s1lentq/ReGameDLL...pons.cpp#L1603

PHP Code:

if (!(pev->flags FL_ONGROUND))
    {
        return;
    } 

That's why it doesn't work. The weaponbox must be on ground for the touch to work. This is done most likely to avoid the initial touch when the weapon is dropped. Without that check you would pick back the weapon instantly.

sekac 07-08-2018 06:59

Re: fake_touch doesn't work for a weaponbox in the air
 
So is there a way of doing this? It doesn't even return a value so we can do it until it's successful...

HamletEagle 07-08-2018 07:08

Re: fake_touch doesn't work for a weaponbox in the air
 
Quote:

Originally Posted by sekac (Post 2601895)
So is there a way of doing this? It doesn't even return a value so we can do it until it's successful...

What return value are you talking about? Better explain what you REALLY want to do because touching a weaponbox that's in air doesn't make much sense.

sekac 07-08-2018 07:12

Re: fake_touch doesn't work for a weaponbox in the air
 
I mean it doesn't return 1 if it is successful and 0 otherwise. Touching a weaponbox in the air is not my intention, but often when I call fake_touch it fails because it's in the air and I want to fix that.

HamletEagle 07-08-2018 07:15

Re: fake_touch doesn't work for a weaponbox in the air
 
Quote:

Originally Posted by sekac (Post 2601904)
I mean it doesn't return 1 if it is successful and 0 otherwise. Touching a weaponbox in the air is not my intention, but often when I call fake_touch it fails because it's in the air and I want to fix that.

Then simply check if it's on ground before calling fake_touch(pev_flags & FL_ONGROUND).

sekac 07-08-2018 07:18

Re: fake_touch doesn't work for a weaponbox in the air
 
Yes, but I need it to work even if it's in the air. So if I call it while it's in the air how would I wait for the weaponbox to be on the ground to call fake touch?

HamletEagle 07-08-2018 07:29

Re: fake_touch doesn't work for a weaponbox in the air
 
I'm afraid this is some kind of XY problem. Again, what are you trying to do? And no, the answer is not "touching a weaponbox". What's the purpose of this? In what context you want to force the touch?


All times are GMT -4. The time now is 12:43.

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