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

Remember the Score


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   Statistical        Approver:   Exolent[jNr] (178)
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 03-19-2009 , 14:44   Remember the Score
Reply With Quote #1

Remember the Score by Nextra
( save frags save score save deaths remember the frags rememberthefrags rememberthescore rts )
.: Description
This plugin will keep track of players scores through a mysql (or optionally sqlite) database.
Everytime the user joins the server his score will be set to what is saved in the database (i.e. the score he has left the server with last time). It was made as per request.
.: Features
- Automatic saving on disconnect + configurable prevention saving to minimize loss of data after a crash
- Automatic pruning and per-map storing
- Uses threaded-querying
- Configuration of when and what to save
- API to allow for easy implementation into other plugins
.: Cvars
rts_host - DB Host
rts_user - DB User
rts_pass - DB Password
rts_db - DB
rts_table - DB Table
rts_type - DB Type (mysql or sqlite)
rts_auth - Track users by:
0 = steamid
1 = ip
2 = name
rts_max - Maximum of Score/Deaths to save (score saved in db will not go beyond this value)
rts_min - Score minimum to save (deaths minimum if rts_track = 2)
rts_prune - When to prune data (in days, 0 = disable)
rts_permap - Only save for one map. Table gets emptied completely on a new map. (Overrides rts_prune, rts_max and rts_min)
rts_track - What to track:
1 = track score
2 = track deaths
3 = track both
0 = plugin disabled
rts_save - The plugin saves on disconnect, additionally (prevents loss of data on crash) save on:
0 = never
1 = roundend
2 = every respawn (for deathmatch servers)
3 = every score update (may cause lots of traffic)
.: Required Modules
- CStrike
- FakeMeta
- Ham Sandwich
- MySQL / SQLite
.: Notes
#1 - I know that there is a plugin that essentially does the same but as I said this was a request, done due to the other one not working for the requester. I just wanted to share this in the hope it will be useful for others. For clearance why there are no credits: This was entirely done from scratch - no code was taken from any (esp. not rememberthefrags) plugins in the creation process.

#2 - I made the plugin rts_complement to showcase the API functions of RTS. It is made to be used as a reference and therefore only includes limited features, do not expect anything special from it.

#3 - This plugin did not go through much testing, unlike I usually prefer to do it with my stuff. This is because I currently do not need it myself. It is, however, working without errors for a few days on the requesters server (MySQL). SQLite has been only tested locally but everything should work fine. Please report any bugs you may encounter.
.: Changelog ( latest changes )
* 1.0.791
- Fixed not escaping strings for nickname saving.
* 1.0.800
- Fixed Auth problems.
- Added integrity checks and sync setting for SQLite, fixing problems that occured for some.
* 1.0.810
- Fixed typo.
- Changed errorlogging in startup routine to now use set_fail_and_fwd.
.: Downloads: 502+ :.
Attached Files
File Type: sma Get Plugin or Get Source (rememberthescore.sma - 4277 views - 20.0 KB)
File Type: inc rememberthescore.inc (2.3 KB, 1665 views)
File Type: sma Get Plugin or Get Source (rts_complement.sma - 2969 views - 5.6 KB)

Last edited by Nextra; 08-02-2009 at 10:09.
Nextra is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 03-19-2009 , 14:49   Re: Remember the Score
Reply With Quote #2

nice job
__________________
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-19-2009 , 15:53   Re: Remember the Score
Reply With Quote #3

The plugin is well done. Not looking deeply though. You could cache the value of is_user_connected/is_userbot.
Arkshine is offline
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 03-19-2009 , 16:05   Re: Remember the Score
Reply With Quote #4

Quote:
Originally Posted by arkshine View Post
The plugin is well done. Not looking deeply though. You could cache the value of is_user_connected/is_userbot.
Its a pleasure to see code like this. It looks like poetry.

Let me just tell you a minimal thing:

Pawn is lazy so you can safely join conditions like:

Instead of:

PHP Code:
    if( !( <= id <= g_iMaxPlayers ) )
        return 
0;
    else if( !
is_user_connectedid ) || is_user_botid ) )
        return 
0;
        
    
save_playerid); 
PHP Code:
    if( ( <= id <= g_iMaxPlayers )  && is_user_connectedid ) && !is_user_botid ) )
        
save_playerid); 
__________________

Last edited by joaquimandrade; 03-19-2009 at 16:19.
joaquimandrade is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 03-19-2009 , 16:26   Re: Remember the Score
Reply With Quote #5

Quote:
Originally Posted by tuty View Post
nice job
Thanks.

Quote:
Originally Posted by arkshine View Post
The plugin is well done. Not looking deeply though. You could cache the value of is_user_connected/is_userbot.
Thank you, I implemented that. Version 1.0.786.

Quote:
Originally Posted by joaquimandrade View Post
Its a pleasure to see code like this. It looks like poetry.
Hehe, thank you aswell. Nice that you like my style

Quote:
Originally Posted by joaquimandrade View Post
Let me just tell you a minimal thing:

Pawn is lazy so you can safely join conditions like:

Instead of:

PHP Code:
    if( !( <= id <= g_iMaxPlayers ) )
        return 
0;
    else if( !
is_user_connectedid ) || is_user_botid ) )
        return 
0;
        
    
save_playerid); 
PHP Code:
    if( ( <= id <= g_iMaxPlayers )  && is_user_connectedid ) && !is_user_botid ) )
        
save_playerid); 
I do like it better the way I did it now. If there are any practical improvements besides how it looks please tell me. Otherwise I'll keep it.
__________________
In Flames we trust!
Nextra is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-19-2009 , 17:29   Re: Remember the Score
Reply With Quote #6

FYI, if someone uses a source code editor with a tab space != 4 spaces it won't look so poetic (if you are refering to the spacing like in the register cvar section). But it does look nice when tab = 4spaces .
__________________
fysiks is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 03-19-2009 , 17:41   Re: Remember the Score
Reply With Quote #7

But the tab size 4 is the standard I believe (I'm using N++)? This is at least what I am using so it looks best for my setting, obviously. The rest looks fine regardless of the size anyway.
__________________
In Flames we trust!
Nextra is offline
Old 03-19-2009, 17:43
Arkshine
This message has been deleted by Arkshine. Reason: nvm
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-19-2009 , 17:46   Re: Remember the Score
Reply With Quote #8

In my plugins ( I'm using Np++ too ) I've activated the option to replace tab by 4 spaces. Using spaces, it should show well on all editor I think.
Arkshine is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-19-2009 , 17:59   Re: Remember the Score
Reply With Quote #9

I'm using Notepad++ too. The default is to show tabs as 4 spaces in width. You can change that to whatever you want and opt to replace with actual spaces as Arkshine said.

If you haven't already, check out the link in my signature. I have CS syntax highlighting for Notepad++.
__________________
fysiks is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 03-19-2009 , 18:10   Re: Remember the Score
Reply With Quote #10

Thanks, I already saw your thread and highlighting syntax for N++ but actually I prefer the way it is when you set C++ highlighting. I looked at your thing and I do not like every single function highlighted. For me it is enough to have highlighted braces and operators and stuff.

And for the tab thing, I know I can replace things by spaces but I do not like it while I am coding. I always have to backspace four instead of one character. If you know how to change all tabs at once I will do it before releasing my plugin, otherwise you will have to live with that minor issue ;)
__________________
In Flames we trust!
Nextra 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 20:28.


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