AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Remember the Score (https://forums.alliedmods.net/showthread.php?t=88034)

Nextra 03-19-2009 14:44

Remember the Score
 
20 Attachment(s)
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+ :.

tuty 03-19-2009 14:49

Re: Remember the Score
 
nice job :crab:

Arkshine 03-19-2009 15:53

Re: Remember the Score
 
The plugin is well done. Not looking deeply though. You could cache the value of is_user_connected/is_userbot.

joaquimandrade 03-19-2009 16:05

Re: Remember the Score
 
Quote:

Originally Posted by arkshine (Post 784613)
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); 


Nextra 03-19-2009 16:26

Re: Remember the Score
 
Quote:

Originally Posted by tuty (Post 784577)
nice job :crab:

Thanks.

Quote:

Originally Posted by arkshine (Post 784613)
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 (Post 784625)
Its a pleasure to see code like this. It looks like poetry.

Hehe, thank you aswell. Nice that you like my style :wink:

Quote:

Originally Posted by joaquimandrade (Post 784625)
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.

fysiks 03-19-2009 17:29

Re: Remember the Score
 
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 :).

Nextra 03-19-2009 17:41

Re: Remember the Score
 
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.

Arkshine 03-19-2009 17:46

Re: Remember the Score
 
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.

fysiks 03-19-2009 17:59

Re: Remember the Score
 
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++.

Nextra 03-19-2009 18:10

Re: Remember the Score
 
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 ;)


All times are GMT -4. The time now is 09:04.

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