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

Client Specific Variables


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dreae
Junior Member
Join Date: Mar 2012
Old 03-21-2012 , 17:21   Client Specific Variables
Reply With Quote #1

Ok, let me preface this by saying that I'm unsure of how SM plugins are executed. I assume that they are server-wide, and thus global variables are global. I'm writing a plugin that involves querying a integer from an SQL database, but because of the function of the plugin this query would be performed often. I'm wondering whether it is possible, or even necessary, to define a variable as specific to a certain client, and then calling that variable rather then querying the SQL database every time the event is triggered.
Dreae is offline
TheAvengers2
BANNED
Join Date: Jul 2011
Old 03-21-2012 , 17:28   Re: Client Specific Variables
Reply With Quote #2

Make a global array at the top of the plugin. Perhaps something like this:

new g_iQueryCache[MAXPLAYERS + 1];

Then on the players first query, set the value to the clients index. i.e. g_iQueryCache[client] = result;

Last edited by TheAvengers2; 03-21-2012 at 17:31.
TheAvengers2 is offline
Dreae
Junior Member
Join Date: Mar 2012
Old 03-21-2012 , 17:30   Re: Client Specific Variables
Reply With Quote #3

Great, thanks!
__________________
Dreae 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 05:54.


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