Raised This Month: $51 Target: $400
 12% 

[BUG] is_visible native


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-28-2016 , 08:44   [BUG] is_visible native
Reply With Quote #1

is_visible native doesn't work correctly, even tho there is another player in my sight the client print is not displayed, however if the entity = target it works...

Tested on -> 1.8.3 last dev / 1.8.2 same result
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>

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


public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say check""checkvis")
    
    
// Add your code here...
}

public 
checkvis(id)
{
    new 
iPlayers[32], iNumpl2
    
    get_players
(iPlayersiNum"h")
    
    for(new 
0iNumi++)
    {
        
pl2 iPlayers[i]
        
        if( (
id != pl2 ) && is_visible(idpl2))
        {
            
client_print(0print_chat"Another player in sight")
        }
    }

__________________

Last edited by Depresie; 11-28-2016 at 08:48.
Depresie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-28-2016 , 10:35   Re: [BUG] is_visible native
Reply With Quote #2

is_visible is very basic and just trace a straight line between your eye position (origin + view_ofs) and the other player as well. If there is something blocking the line (like a well corner), it will return false. Check the tutorial section for engineX or whatever, don't remember.
__________________

Last edited by Arkshine; 11-28-2016 at 10:36.
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-28-2016 , 11:14   Re: [BUG] is_visible native
Reply With Quote #3

I was standing right in front of the target... nothing in between us
__________________
Depresie is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-28-2016 , 12:00   Re: [BUG] is_visible native
Reply With Quote #4

It's a copy paste of the HLDS function, I don't see how it could fail unless you're messing with player's flags or trace handle.
__________________
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-28-2016 , 12:01   Re: [BUG] is_visible native
Reply With Quote #5

Wasn't messing with anything, it was tested on stock amxmodx 1.8.3 and 1.8.2 no other plugins running, the script used was the one above
__________________
Depresie is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 11-28-2016 , 12:10   Re: [BUG] is_visible native
Reply With Quote #6

Fraction can't be 1.0 because ray hits target head before end point.
You can check it:
Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init() {
    register_clcmd("say /checkvis", "OnClientCmdSayCheckVisReceive");
}

public OnClientCmdSayCheckVisReceive(player) {
    new anotherPlayer = FindAnotherPlayer(player);
    if (anotherPlayer != 0) {
        new traceResult = create_tr2();
        engfunc(
            EngFunc_TraceLine,
            GetPlayerEyePosition(player),
            GetPlayerEyePosition(anotherPlayer),
            DONT_IGNORE_MONSTERS,
            player,
            traceResult);
        
        new Float:fraction;
        get_tr2(traceResult, TR_flFraction, fraction);
        client_print(
            player,
            print_chat,
            "InOpen: %s, InWater: %s, Fraction: %.3f",
            get_tr2(traceResult, TR_InOpen) != 0 ? "True" : "False",
            get_tr2(traceResult, TR_InWater) != 0 ? "True" : "False",
            fraction);
        
        free_tr2(traceResult);
    }
}

FindAnotherPlayer(currentPlayer) {
    new bool:found = false;
    new savedPlayer = 0;
    for (new anotherPlayer = 1; anotherPlayer <= get_maxplayers(); anotherPlayer++) {
        if (!is_user_alive(anotherPlayer)) {
            continue;
        }
        if (anotherPlayer != currentPlayer) {
            if (found) {
                return 0;
            }
            
            savedPlayer = anotherPlayer;
            found = true;
        }
    }
    
    return savedPlayer;
}

Float:GetPlayerEyePosition(player) {
    new Float:position[3];
    pev(player, pev_origin, position);
    new Float:eyeOffset[3];
    pev(player, pev_view_ofs, eyeOffset);
    position[0] += eyeOffset[0];
    position[1] += eyeOffset[1];
    position[2] += eyeOffset[2];
    return position;
}
__________________

Last edited by PRoSToTeM@; 11-28-2016 at 12:13.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 11-28-2016 , 12:18   Re: [BUG] is_visible native
Reply With Quote #7

^ He's right, fraction will be never 1.0, not sure why it hasn't been reported already .
__________________
Arkshine is offline
Depresie
Veteran Member
Join Date: Nov 2013
Old 11-28-2016 , 12:25   Re: [BUG] is_visible native
Reply With Quote #8

Another bug, another cookie...
__________________
Depresie is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 11-28-2016 , 12:26   Re: [BUG] is_visible native
Reply With Quote #9

I don't know the best way, but this works good:
Code:
new oldSolid = pev(anotherPlayer, pev_solid);
set_pev(anotherPlayer, pev_solid, SOLID_NOT);
engfunc(
    EngFunc_TraceLine,
    GetPlayerEyePosition(player),
    GetPlayerEyePosition(anotherPlayer),
    DONT_IGNORE_MONSTERS,
    player,
    traceResult);
set_pev(anotherPlayer, pev_solid, oldSolid);
__________________

Last edited by PRoSToTeM@; 11-28-2016 at 12:27.
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Old 12-09-2016, 00:48
jackseason
This message has been deleted by Arkshine. Reason: Spambot
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 22:20.


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