This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

get_players() fail with flag "e"


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-20-2010 , 18:21   get_players() fail with flag "e"
Reply With Quote #1

so ive got this code
PHP Code:
public cmdTeleTeam(id)
{
    if(
is_user_alive(id))
    {
        new 
iPlayers[32], iTotal;
        new 
CsTeams:iTeam cs_get_user_team(id);
        
        if(
iTeam == CS_TEAM_CT)
            
get_players(iPlayersiTotal"e""TERRORIST");
        else if(
iTeam == CS_TEAM_T)
            
get_players(iPlayersiTotal"e""CT");
        else
            return 
PLUGIN_CONTINUE;
        
        
client_print(0print_chat"playersnum: %i"get_playersnum());
        
client_print(0print_chat"iTotal: %i"iTotal);
        
        for(new 
ii<iTotali++)
        {
            if(
is_user_alive(iPlayers[i]))
            {
                new 
Float:flOrigin[3];
                
                
pev(iPlayers[i], pev_originflOrigin);
                
flOrigin[2] += 73.0;
                
set_pev(idpev_originflOrigin);
                
client_print(idprint_console"Teleported Above An Enemy");
                
                return 
PLUGIN_CONTINUE;
            }
        }
        
        
client_print(idprint_console"There Are No Enemies!");
    }
    
    return 
PLUGIN_HANDLED;

but its not working
yes, i know the funcwiki says that "Note: "e" flag can return incorrect results (for cstrike/czero at least)."
Ive figured out that if im a CT trying to tele above a Ts head, it dosent work but if im a T trying to teleport above a CTs head, it does work


Is there something wrong with my code? or is it just that the "incorrect results" have come along to destory my day?

if its the latter, what other code can i use to get the same effect?
im guessing looping through to get_maxplayers() and checking cs_get_user_team(i)

posting here is my last resort btw
ive done so many tests on so many different maps using bots bots and players, but it only ever worked for Ts teleporting onto CTs =[
__________________
minimiller is offline
Send a message via MSN to minimiller
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-20-2010 , 18:37   Re: get_players() fail with flag "e"
Reply With Quote #2

ive had inconsistent results with getplayers too. the same exact code one day returned correct and valid players other days it returned no players when it should have returned some.i recommend checking manually
__________________
Bugsy is offline
01101101
BANNED
Join Date: Nov 2009
Location: 9`su 09`n0n7e`r0f76a
Old 01-20-2010 , 23:00   Re: get_players() fail with flag "e"
Reply With Quote #3

Quote:
Originally Posted by BAILOPAN
We don't really support get_players() with flags anymore. It was a bad idea and if it was our choice, it would have never been added to the original AMX Mod.
And, if you see at the func list it says

Quote:
Originally Posted by http://www.amxmodx.org/funcwiki.php?go=func&id=174
Note: "e" flag can return incorrect results (for cstrike/czero at least).
01101101 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-20-2010 , 23:03   Re: get_players() fail with flag "e"
Reply With Quote #4

Quote:
Originally Posted by 01101101 View Post
And, if you see at the func list it says
he did note that he saw that in the funcwiki
__________________
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-21-2010 , 00:32   Re: get_players() fail with flag "e"
Reply With Quote #5

Try to also use flag "a" since it seems you only need to retrieve alive players.
If it still returns false results (i thought i could return false results for dead players only), do manually a loop.
Also, don't forget to check the hull before you teleport yourself, and don't forget that set_pev is not the correct way to teleport, see engine set_entity_origin source code :

Code:
static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params)
{
	int iEnt = params[1];

	CHECK_ENTITY_SIMPLE(iEnt);
	
	edict_t *pEnt = INDEXENT2(iEnt);
	cell *vVector = MF_GetAmxAddr(amx, params[2]);
	REAL fX = amx_ctof(vVector[0]);
	REAL fY = amx_ctof(vVector[1]);
	REAL fZ = amx_ctof(vVector[2]);
	Vector vOrigin = Vector(fX, fY, fZ);

	SET_SIZE(pEnt, pEnt->v.mins, pEnt->v.maxs);
	SET_ORIGIN(pEnt, vOrigin);

	return 1;
}
SET_SIZE would be EngFunc_SetSize or entity_set_size, and SET_ORIGIN would be EngFunc_SetOrigin.

I would try something like this :

PHP Code:
new const Float:VEC_DUCK_HULL_MIN[3]    = {-16.0, -16.0, -18.0 }
new const 
Float:VEC_DUCK_HULL_MAX[3]    = { 16.0,  16.0,  32.0 }
new const 
Float:VEC_DUCK_VIEW[3]        = {  0.0,   0.0,  12.0 }

public 
cmdTeleTeam(id)
{
    if(
is_user_alive(id))
    {
        new 
iPlayers[32], iTotalplr
        get_players
(iPlayersiTotal"ae"cs_get_user_team(id) == CS_TEAM_CT "TERRORIST" "CT")

        new 
Float:fVecOrigin[3], Float:fVecMaxs[3]
        for(new 
ii<iTotali++)
        {
            
plr iPlayers[i]
            
pev(plrpev_originfVecOrigin)
            
pev(plrpev_maxsfVecMaxs)
            
fVecOrigin[2] += ( fVecMaxs[2] + VEC_DUCK_HULL_MIN[2] + 1.0 /* + 2.0 ? */)
            if( 
trace_hull(fVecOriginHULL_POINTplr /* 0 ? */DONT_IGNORE_MONSTERS) == )
            {
                
Util_SetOrigin(idfVecOrigin)
                
client_print(idprint_console"Teleported Above An Enemy")
                break
            }
        }

        
client_print(idprint_console"There Are Avaible Place Above Enemies!")
    }

    return 
PLUGIN_HANDLED
}

Util_SetOrigin(const id, const Float:fVecOrigin[3])
{    
    
entity_set_int(idEV_INT_flagsentity_get_int(idEV_INT_flags) | FL_DUCKING)
    
engfunc(EngFunc_SetSizeidVEC_DUCK_HULL_MINVEC_DUCK_HULL_MAX)
    
engfunc(EngFunc_SetOriginidfVecOrigin)
    
entity_set_vector(idEV_VEC_view_ofsVEC_DUCK_VIEW)

If it works, could be a good solution for campers, open a menu to ennemy like "NAME is camping, do you want to be teleported above his head ?"
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 01-21-2010 at 00:51.
ConnorMcLeod is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-21-2010 , 09:32   Re: get_players() fail with flag "e"
Reply With Quote #6

Ok thx for the help guys

@Connor: Im guessing that checks if either of the players are ducked before teleporting them (i couldnt really read it on my phone =[)

Would it be better if i looped through to get_maxplayers() and left out get_players() alltogether? or should i use get_players(iPlayers, iTotal, "ah") then in the loop to iTotal check cs_get_user_team(iPlayers[i])?

PHP Code:
new iPlayers[32], iTotalCsTeams:iTeam cs_get_user_team(id);
get_players(iPlayersiTotal"ah"); 

for(new 
ii<iTotali++)
{
    if(
cs_get_user_team(iPlayers[i]) != iTeam)
    {
        
//Do stuff
    
}

Also: Does ne1 know why they dropped support for get_players()? its such a handy tool =]
__________________
minimiller is offline
Send a message via MSN to minimiller
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-21-2010 , 11:21   Re: get_players() fail with flag "e"
Reply With Quote #7

No, the check is if the target player is ducked, so you retrieve a more accurate above origin, then you check the hull of a ducked player and you teleport yourself as if you were ducked.
I've never had any problem with flag "e" combinated with fag "a".
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-21-2010 , 19:58   Re: get_players() fail with flag "e"
Reply With Quote #8

ahh i c
ill test that on 2moro after work
thx again
__________________
minimiller is offline
Send a message via MSN to minimiller
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-22-2010 , 01:04   Re: get_players() fail with flag "e"
Reply With Quote #9

I thinks it's because get_user_team is updated when ScoreInfo message is sent, and when a player is dead that message is not sent (sometimes ?).
Not sure though.

Anyway, have you tested the code i gave you ?
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
minimiller
Veteran Member
Join Date: Aug 2007
Location: United Kingdom
Old 01-22-2010 , 03:28   Re: get_players() fail with flag "e"
Reply With Quote #10

not yet
i havent been @ my PC since i posted this thread
__________________
minimiller is offline
Send a message via MSN to minimiller
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 03:55.


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