Ok im adding to my plugin which is my version of twilight suzukas moneymod, a hud on the left with playername, balance, salary etc.
Now this is very cpu coslty and when the hud updates it kind of flickes and sometimes takes a long time to go on the screen. Is there any better, faster, less cpu costly way to code this?
Code:
set_task(10.0,"activehud",0,"",0,"b")
Code:
public activehud(id)
{
new query[256]
new authid[32]
new playername[32]
new num, players[32]
get_players(players,num,"ac")
for( new i = 0; i < num; i++ )
{
get_user_authid( players[i], authid, 31)
get_user_name( players[i], playername, 31)
format( query, 255, "SELECT balance,salary,timeleft,job FROM money WHERE steamid='%s'", authid)
result = dbi_query( dbc, query)
if ( dbc == SQL_FAILED )
{
server_print( "Query failed!")
dbi_free_result(result)
return PLUGIN_HANDLED
}
new strBalance[32], strSalary[32], strTime[32], strJob[32]
if( dbi_nextrow( result ) > 0 )
{
dbi_field( result, 1, strBalance, 31)
dbi_field( result, 2, strSalary, 31)
dbi_field( result, 3, strTime, 31)
dbi_field( result, 4, strJob, 31)
dbi_free_result(result)
set_hudmessage(0,175,0,-2.0,0.35,0,0.0,9.9,0.0,0.0,2)
show_hudmessage( players[i], " [TEM] %s ^n Balance: %i € ^n Salary: %i € ^n Job: %s ^n Payday Time: %i", playername, str_to_num(strBalance), str_to_num(strSalary), strJob, str_to_num(strTime))
Is there any way to make the HUD not flicker or dissapear when it updates? Or make it anyway better?