Raised This Month: $ Target: $400
 0% 

Better Way (Difference)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
OvidiuS
Chillaxin'
Join Date: Dec 2009
Location: Serbia
Old 04-16-2011 , 07:42   Better Way (Difference)
Reply With Quote #1

which way is better (less cpu, faster), and does anyone know even better way than this one

1.
PHP Code:
public radar_block(id
{
    new 
Players[32]
    new 
playerCountiplayer
    get_players
(PlayersplayerCount"c")
    for (
i=0i<playerCounti++)
    {
        
player Players[i
        if(
get_user_team(player) != get_user_team(id))
        {
            
emit_sound(playerCHAN_ITEM"counter_enemy.wav"1.0ATTN_NORM0PITCH_NORM);
            
cblocked[player] = true
            set_task
(15.0"remove_block"player)
        }
        else if(
get_user_team(player) == get_user_team(id))
        {
            
emit_sound(playerCHAN_ITEM"counter_friend.wav"1.0ATTN_NORM0PITCH_NORM);
        }
    }

2.
somewhere in plugin_init -> g_maxplayers = get_maxplayers();

PHP Code:
public radar_block(id
{
    for(new 
1<= g_maxplayersi++)
    {
        if(
get_user_team(i) != get_user_team(id))
        {
            
emit_sound(iCHAN_ITEM"counter_enemy.wav"1.0ATTN_NORM0PITCH_NORM);
            
cblocked[i] = true
            set_task
(15.0"remove_block"i)
        }
        else if(
get_user_team(i) == get_user_team(id))
        {
            
emit_sound(iCHAN_ITEM"counter_friend.wav"1.0ATTN_NORM0PITCH_NORM);
        }
    }


Last edited by OvidiuS; 04-16-2011 at 07:47.
OvidiuS is offline
Send a message via Skype™ to OvidiuS
 



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 19:46.


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