Raised This Month: $ Target: $400
 0% 

Help with while


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-31-2011 , 15:38   Re: Help with while
Reply With Quote #1

Because player indexes are before entity indexes.

You have to check if that entity is near before checking for players, meaning 2 different loops.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Kiske
Veteran Member
Join Date: May 2009
Old 07-31-2011 , 15:46   Re: Help with while
Reply With Quote #2

Quote:
Originally Posted by Exolent[jNr] View Post
Because player indexes are before entity indexes.

You have to check if that entity is near before checking for players, meaning 2 different loops.
Thanks.

Quote:
Originally Posted by Javivi View Post
Thats because players are entities too, you can solve that by checking that your ent is not a player.
!( 1 <= ent <= 32 )
PHP Code:
#define is_user_valid_alive(%1) (1 <= %1 <= g_maxplayers && is_user_alive(id))

if(!is_user_valid_alive(e)) continue; 
Kiske is offline
Send a message via Skype™ to Kiske
Kiske
Veteran Member
Join Date: May 2009
Old 07-31-2011 , 18:20   Re: Help with while
Reply With Quote #3

Quote:
Originally Posted by Exolent[jNr] View Post
Because player indexes are before entity indexes.

You have to check if that entity is near before checking for players, meaning 2 different loops.
I will try.
Can you explain me please? I can't make it.

Thanks in advanced.
Kiske is offline
Send a message via Skype™ to Kiske
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 07-31-2011 , 18:25   Re: Help with while
Reply With Quote #4

Code:
new Float:ent_origin[3]

pev(entity, pev_origin, ent_origin)

new maxplayers = get_maxplayers()
new e = maxplayers // start after player entities

while((e = find_ent_in_sphere(e, ent_origin, 200.0)) != 0)
{
    // entities loop
}

e = 1 // reset and start before player entities

while((e = find_ent_in_sphere(e, ent_origin, 200.0)) <= maxplayers)
{
    // players loop
}
__________________

Last edited by Hunter-Digital; 07-31-2011 at 18:28.
Hunter-Digital is offline
Kiske
Veteran Member
Join Date: May 2009
Old 07-31-2011 , 21:57   Re: Help with while
Reply With Quote #5

Quote:
Originally Posted by Hunter-Digital View Post
Code:
new Float:ent_origin[3]

pev(entity, pev_origin, ent_origin)

new maxplayers = get_maxplayers()
new e = maxplayers // start after player entities

while((e = find_ent_in_sphere(e, ent_origin, 200.0)) != 0)
{
    // entities loop
}

e = 1 // reset and start before player entities

while((e = find_ent_in_sphere(e, ent_origin, 200.0)) <= maxplayers)
{
    // players loop
}
I can't make it

PHP Code:
        new Float:ent_origin[3]
        
pev(entitypev_originent_origin)
        
        new 
maxplayers
        
while((find_ent_in_sphere(eent_origin200.0)) != 0)
        {
            
pev(epev_modelmodelcharsmax(model))
            if(!
equal(model"models/balls/w_ball3.mdl"))
                return;
        }
        
        
1
        
while((find_ent_in_sphere(eent_origin200.0)) <= maxplayers)
        {
            if(!
is_user_valid(e) || !is_user_alive(e)) continue;
            
            
// ....
        
}
        
        
set_pev(entitypev_nextthinkget_gametime() + 0.1
Kiske is offline
Send a message via Skype™ to Kiske
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-01-2011 , 04:07   Re: Help with while
Reply With Quote #6

More details ? I can't know what you're trying to do if you don't post the entire code or explain in detail what exacly you can't do.

It's also possible I got the logics wrong, try debugging by printing client or server messages in those loops.
__________________
Hunter-Digital is offline
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:24.


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