AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with new AMXX Menu (https://forums.alliedmods.net/showthread.php?t=184940)

bazhenov93 05-10-2012 18:37

Need help with new AMXX Menu
 
How I can add FPS after player name?

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <colorchat>

#define PLUGIN "FPS"
#define VERSION "0.0.1"
#define AUTHOR "Twix"

new szName[32][33]
new 
Float:GameTime[33]
new 
FramesPer[33]
new 
Fps[33]
new 
CurFps[33]
new 
bool:HasFPS[33]

public 
plugin_init(){
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_clcmd("say /fps""cmdFPS")
    
register_clcmd("say /allfps""cmdFPSMenu")
    
register_forward(FM_PlayerPreThink"fwdPlayerPreThink")
}

public 
client_authorized(id){
    
get_user_name(id szName[id] , charsmax(szName[] ))
}

public 
client_disconnect(id){
    
HasFPS[id] = false
}

public 
cmdFPSMenu(id){
    
    new 
menu menu_create("\rPlayers FPS""cmdFPSMenu_handler")
    new 
players[32], fps_in_menu[64], pnumtempidszName[32], szTempid[10]
    
get_players(playerspnum)
    
formatex(fps_in_menu63"\d[\r%d\d]"Fps[id]) // ?
    
    
for( new ii<pnumi++ )
    {
        
    
tempid players[i]
    
get_user_name(tempidszNamecharsmax(szName))
    
menu_additem(menuszNameszTempid0)

    }
    
    
menu_display(idmenu0)
}

public 
cmdFPSMenu_handler(idmenuitem){
    
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu)
    }

    return 
PLUGIN_CONTINUE
}

public 
cmdFPS(id)
{
    if(!
HasFPS[id])
    {
        
HasFPS[id] = true
        ColorChat
(idGREY"^4[FPS] ^3FPS displaying enabled. To disable, type /fps")
    }
    else
    {
        
HasFPS[id] = false
        ColorChat
(idGREY"^4[FPS] ^3FPS displaying disabled. To enable, type /fps")
    }
}

public 
fwdPlayerPreThink(id)
{
    if(
is_user_alive(id))
    {
        
GameTime[id] = get_gametime()
        
        if(
FramesPer[id] >= GameTime[id]) Fps[id] += 1
        
else
        {
            
FramesPer[id] += 1
            
            
if (HasFPS[id])
            {
                
set_hudmessage(25500, -1.00.901.01.00.10.11337)
                
show_hudmessage(id"FPS: %d"Fps[id])
            }
            
CurFps[id] = Fps[id]
            
            
Fps[id] = 0
        
}
    }



Exolent[jNr] 05-10-2012 19:11

Re: Need help with new AMXX Menu
 
FYI, it is not possible to accurately calculate a player's FPS using server-side AMXX.

bazhenov93 05-11-2012 07:39

Re: Need help with new AMXX Menu
 
1 Attachment(s)
Really? look this :)

Exolent[jNr] 05-11-2012 10:01

Re: Need help with new AMXX Menu
 
Quote:

Originally Posted by Exolent[jNr] (Post 1706431)
accurately

Meaning that you can try to calculate it, but doesn't mean that it will be the real FPS of the player.

That plugin is using the same method from this tutorial:
https://forums.alliedmods.net/showthread.php?t=66890

Read the thread, or even better, read Hawk's post specifically:
https://forums.alliedmods.net/showpo...96&postcount=7

Quote:

Originally Posted by Hawk552 (Post 584196)
It's extremely inaccurate. In fact, it's actually based more on the server's FPS than the client's and it's only accurate when both the client and server are very fast.


bazhenov93 05-11-2012 10:14

Re: Need help with new AMXX Menu
 
Hm, sad :(


All times are GMT -4. The time now is 00:22.

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