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

how to use SVC_PINGS


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reinert
Veteran Member
Join Date: Feb 2007
Old 09-09-2011 , 07:09   how to use SVC_PINGS
Reply With Quote #1

does anyone knows how to use:

SVC_PINGS ?

PHP Code:
message_begin(MSG_ONE_UNRELIABLESVC_PINGS_id)
write_byte() // What is here?
write_short() // What is here? 
</span>
reinert is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-09-2011 , 07:27   Re: how to use SVC_PINGS
Reply With Quote #2

http://wiki.amxmodx.org/Half-Life_1_...ages#SVC_PINGS
http://forums.alliedmods.net/showthread.php?p=767048
__________________
Arkshine is offline
reinert
Veteran Member
Join Date: Feb 2007
Old 09-09-2011 , 07:33   Re: how to use SVC_PINGS
Reply With Quote #3

It didn't helped much. Maybe someone could explain it ? or give me easy example ;D
reinert is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-09-2011 , 08:03   Re: how to use SVC_PINGS
Reply With Quote #4

Wow, you're lazier than I am... I don't even need this but I had a few minutes to see the code and I transcribed a working chunk of the code, it sets all player's ping to 928.

PHP Code:
#include <amxmodx>
#include <fakemeta>

public plugin_init()
{
    
register_forward(FM_UpdateClientData"fw_updateClientData")
}

public 
fw_updateClientData(id)
{
    
// Scoreboard key being pressed?
    
if (!(pev(idpev_button) & IN_SCORE) && !(pev(idpev_oldbuttons) & IN_SCORE))
        return;
        
    new 
ping 928 // make sure it's not negative or above 4095
    
new ping1
    
new ping2
    
new offset1
    
new offset2
    
new sending

    
for(new player 1player get_maxplayers(); player++)
    {
        if(!
is_user_connected(id))
            continue;
    
        for(new 
offset1 0offset1 4offset1++)
        {
            if ((
ping offset1) % == 0)
            {
                
ping1 = (ping offset1) / 4
                
break;
            }
        }

        for(new 
offset2 0offset2 2offset2++)
        {
            if ((
ping offset2) % == 0)
            {
                
ping2 = (ping offset2) / 4
                
break;
            }
        }

        switch(
sending)
        {
            case 
0:
            {
                
message_begin(MSG_ONE_UNRELIABLESVC_PINGS_id)
                
write_byte((offset1 64) + (* (player 1)))
                
write_short(ping1)

                
sending++
            }
            case 
1:
            {
                
write_byte((offset2 128) + (* (player 1)))
                
write_short(ping2)

                
sending++
            }
            case 
2:
            {
                
write_byte((* (player 1)))
                
write_short(ping)
                
write_byte(0)
                
message_end()

                
sending 0
            
}
        }
    }
    
    if(
sending)
    {
        
write_byte(0)
        
message_end()
    }

The offsets are cached in a slower repeatitive task in fake pinger, I suggest you get them out of there and do the same.

PS: if it's not clear, the code is highly unoptimized and may cause lag, it's just a example, you should optimize it accordingly.
__________________

Last edited by Hunter-Digital; 09-09-2011 at 08:09.
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 18:17.


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