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

Infractions - The Early Stages


Post New Thread Reply   
 
Thread Tools Display Modes
QuantumToast
Member
Join Date: May 2017
Location: US
Old 06-23-2017 , 12:23   Re: Infractions - The Early Stages
Reply With Quote #41

Apologies for the second post so quickly.
Quote:
Originally Posted by Kryptanyte View Post
Just looking at your code I realize you can shorten a function by doing this (that was my bad haha):

*snip*

Otherwise it looks a lot cleaner.

A note when you implement SQL, you want to run threaded queries so using a query instantly won't really work (For threaded queries you pass a callback function to the query and once the query is run it will send the results to said callback function where you can handle them. This prevents hanging in your plugin)

I would say check the player for infractions early so it's (probably) returned the results by the time you want to check the player for infractions. The earliest you can do this would be OnClientAuthorized()
Based on that, if I'm reading correctly, I will have to actually run a query to check for infractions before I actually read that information into PlayerHasInfractions()? I'm trying my best to not be spoonfed, but I think I just have a lot to learn about SQL before this project gains any footing...
QuantumToast is offline
hmmmmm
Great Tester of Whatever
Join Date: Mar 2017
Location: ...
Old 06-23-2017 , 18:44   Re: Infractions - The Early Stages
Reply With Quote #42

Theres a lot of documentation and tutorials out there on SQL and it really isn't too difficult. Basically just tables that store data (like infractions for every player), and you send 'queries' to do stuff like read some of the info, update the info, delete stuff, or add new stuff.

What Kryptanite was trying to say is, when you run the query using SQL_Query the result might take a while and make the server lag. Instead you should using something called a threaded query (SQL_TQuery) where you feed it in the query and instead of delaying the server frame or causing lag, it'll just execute a function that you pass it (called callback functions) when its ready.

There are some good examples of this in the thing I posted, and if you want to know more about queries I suggest this: https://www.w3schools.com/SQL/deFault.asp. You won't need to know everything there, mostly just the important stuff like INSERT, UPDATE and SELECT.
hmmmmm is offline
Kryptanyte
Junior Member
Join Date: Dec 2015
Old 06-24-2017 , 04:41   Re: Infractions - The Early Stages
Reply With Quote #43

Quote:
Originally Posted by hmmmmm View Post
What Kryptanite was trying to say is, when you run the query using SQL_Query the result might take a while and make the server lag. Instead you should using something called a threaded query (SQL_TQuery) where you feed it in the query and instead of delaying the server frame or causing lag, it'll just execute a function that you pass it (called callback functions) when its ready.
hmmmmm is 100% correct. It's less of a strain on the server to pull the information you need from the database and store it in variables within the plugin you can reference in other places. You will need to clear this information when a player disconnects though.

I made something that might help you understand what I mean.
Spoiler


That's an example of a threaded query, with a regular (inline) query it could cause a hang in the plugin.
Kryptanyte is offline
QuantumToast
Member
Join Date: May 2017
Location: US
Old 06-27-2017 , 13:10   Re: Infractions - The Early Stages
Reply With Quote #44

Well, I haven't had much time to work on the plugin, but I have a small optimization-related question:
Would it be more efficient to have a single command hook callback for commands like sm_kick, sm_ban, sm_mute, etc.? And then just check for which command was used within the callback? Currently I have a single callback for each command hook, and I was thinking that since you can hook multiple commands to the same callback, would it be more efficient, or just complicate things?
__________________
QuantumToast is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 06-27-2017 , 13:59   Re: Infractions - The Early Stages
Reply With Quote #45

Quote:
Originally Posted by QuantumToast View Post
Well, I haven't had much time to work on the plugin, but I have a small optimization-related question:
Would it be more efficient to have a single command hook callback for commands like sm_kick, sm_ban, sm_mute, etc.? And then just check for which command was used within the callback? Currently I have a single callback for each command hook, and I was thinking that since you can hook multiple commands to the same callback, would it be more efficient, or just complicate things?
More efficient? Not really, it's one more check.

Less code? Yes, and for this reason I'd create one callback, organize all the data, and the route them to different self-defined functions that do whatever.
headline is offline
Reply


Thread Tools
Display Modes

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 07:23.


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