Raised This Month: $ Target: $400
 0% 

KillCounter for CSGO


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StealthGus
Junior Member
Join Date: Mar 2015
Old 01-08-2017 , 23:51   KillCounter for CSGO
Reply With Quote #1

I'm trying to make just a simple kill counter plugin. This is semi-one of my first times messing around with SQL inside of sourcemod. I know it looks super rough and it's mostly because my original code didn't work so I started trying to piece together from other plugins I had been finding.

Any help would be appreciated, thanks!
Spoiler

Last edited by StealthGus; 01-08-2017 at 23:51.
StealthGus is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 01-09-2017 , 00:03   Re: KillCounter for CSGO
Reply With Quote #2

and what do you need help with...
__________________
8guawong is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-09-2017 , 01:47   Re: KillCounter for CSGO
Reply With Quote #3

Quote:
Originally Posted by 8guawong View Post
and what do you need help with...
just a quick glance at the code what issue he is probably facing is that when ever a player connects it creates a new row for the client starting at zero, meaning that there is multiple rows for the same steamid.
Also he's missing the 'Query' callback.
Mitchell is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 01-09-2017 , 02:16   Re: KillCounter for CSGO
Reply With Quote #4

Quote:
Originally Posted by Mitchell View Post
just a quick glance at the code what issue he is probably facing is that when ever a player connects it creates a new row for the client starting at zero, meaning that there is multiple rows for the same steamid.
Also he's missing the 'Query' callback.
__________________
8guawong is offline
StealthGus
Junior Member
Join Date: Mar 2015
Old 01-09-2017 , 14:17   Re: KillCounter for CSGO
Reply With Quote #5

Oh geez, I did a great job explaining didn't I?

SQL Never fires. I can't get it to even add a row. I'm aware I'll have an issue with a creating a new row every connect but that's easily fixable with making the steamID row unique (right?). But for whatever reason it seems that my DB is not initializing in any way.
StealthGus is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-09-2017 , 16:07   Re: KillCounter for CSGO
Reply With Quote #6

First thing I notice is OnClientConnected is not the right place to pull a clients steamid.

Use OnClientFullyAuthorized? I think it is...
__________________
Neuro Toxin is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 01-09-2017 , 16:08   Re: KillCounter for CSGO
Reply With Quote #7

You need to wait on the thread query first for it to SELECT how many kills the player has, then update the kill count +1.
Mitchell is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 01-09-2017 , 16:16   Re: KillCounter for CSGO
Reply With Quote #8

You shouldn't be updating SQL after every kill, just do "SELECT * FROM table WHERE steamid ='%s'" every connection, store their kill count in a global var, and then update when they leave. You can also use SQL_GetRowCount there in order to tell if they even exist in the db in the first place. Consider using Threaded queries, aswell.

Is your table even being created? That's a good place to start

Quote:
Originally Posted by Neuro Toxin View Post
Use OnClientFullyAuthorized? I think it is...
OnClientPostAdminCheck is a good place for a guaranteed steamid

Last edited by headline; 01-09-2017 at 16:21.
headline is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 01-09-2017 , 16:42   Re: KillCounter for CSGO
Reply With Quote #9

Quote:
Originally Posted by Mitchell View Post
You need to wait on the thread query first for it to SELECT how many kills the player has, then update the kill count +1.
You can use `column`=`column`+1 in MySQL
__________________
Neuro Toxin is offline
StealthGus
Junior Member
Join Date: Mar 2015
Old 01-09-2017 , 22:58   Re: KillCounter for CSGO
Reply With Quote #10

Quote:
Originally Posted by Headline View Post
You shouldn't be updating SQL after every kill, just do "SELECT * FROM table WHERE steamid ='%s'" every connection, store their kill count in a global var, and then update when they leave. You can also use SQL_GetRowCount there in order to tell if they even exist in the db in the first place. Consider using Threaded queries, aswell.

Is your table even being created? That's a good place to start


OnClientPostAdminCheck is a good place for a guaranteed steamid
Hmmm, alright I'll check that.

Yes the table is being created.
StealthGus 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 02:11.


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