Raised This Month: $ Target: $400
 0% 

Faster/Better Way to make this? Yes? No?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
harbu
Senior Member
Join Date: Aug 2004
Location: Finland
Old 10-30-2004 , 07:30   Faster/Better Way to make this? Yes? No?
Reply With Quote #1

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?

What i have at beggining
Code:
set_task(10.0,"activehud",0,"",0,"b")

Actual Code:
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?
harbu is offline
Send a message via MSN to harbu
.Prometheus.
Member
Join Date: Sep 2004
Old 10-30-2004 , 07:48  
Reply With Quote #2

Well, if the hud message only shows for 9.9 seconds, when it updatesd every 10, yeh problem...As I said to you on MSN I'll rip a seperate version of mine.
.Prometheus. is offline
Send a message via AIM to .Prometheus. Send a message via MSN to .Prometheus.
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 10-30-2004 , 08:24  
Reply With Quote #3

I don't think using SQL databases in realtime environments ever was that a good idea. I think you better load all necessary data at map load, or when someone logs on, then not do any more querying until player disconnects (this also happens when map changes).
Johnny got his gun is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 10-30-2004 , 08:28  
Reply With Quote #4

Quote:
Originally Posted by Johnny got his gun
I don't think using SQL databases in realtime environments ever was that a good idea. I think you better load all necessary data at map load, or when someone logs on, then not do any more querying until player disconnects (this also happens when map changes).
So more of what he's say is, in client_connect, query the database, and store everything in global variables. After that, just update the database when something changes (or on client_disconnect/mapchange)
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull 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 20:20.


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