Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* __ ______ ______ __ __ ______ ______ ______ ______ ______ **
- ** /\ \ /\ ___\ /\ __ \ /\ "-.\ \ /\ ___\ /\__ _\ /\ __ \ /\__ _\ /\ ___\ **
- ** _\_\ \ \ \___ \ \ \ \/\ \ \ \ \-. \ \ \___ \ \/_/\ \/ \ \ __ \ \/_/\ \/ \ \___ \ **
- ** /\_____\ \/\_____\ \ \_____\ \ \_\\"\_\ \/\_____\ \ \_\ \ \_\ \_\ \ \_\ \/\_____\ **
- ** \/_____/ \/_____/ \/_____/ \/_/ \/_/ \/_____/ \/_/ \/_/\/_/ \/_/ \/_____/ **
- ** **
- **Coded By R@f (www.rafweb.ch / www.gtaonline.fr) - DJson include by DracoBlue (www.dracoblue.net) **
- ** **/
- /*=== INCLUDES ===*/
- #include <a_samp>
- #include <djson>
- /*=== DEFINES ===*/
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_BLUE 0x33AAFFFF
- #define UPDATE_TIME 10 /*Time in seconds for the server stats update*/
- /*=== VARIABLES ===*/
- new S_LUPDATE[10] = "09.05.09";
- enum sInfo
- {
- sRestarts,
- sVisits,
- sLeaves,
- sTimeouts,
- sKicks,
- sDeaths,
- sKills,
- sCommands,
- sMessages,
- sPMessages,
- sDays,
- sHours,
- sMinutes,
- sSeconds,
- }
- new ServerInfo[sInfo];
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnFilterScriptInit()
- {
- /*Load DJson*/
- djson_GameModeInit();
- /*Add djStyled - Comment this line for faster performence*/
- djStyled(1);
- /*Little Message =P*/
- printf("\n\n+++++++++++++++++++++++++++++++++++++++++++++++");
- printf("++ R@f's JSon Stats + Last Update @ %s ++",S_LUPDATE);
- printf("++ Script by Rafael 'R@f' Keramidas ++");
- printf("+++++++++++++++++++++++++++++++++++++++++++++++\n\n");
- /*Count server starts*/
- djSetInt("data.json","starts",djInt("data.json","starts")+1);
- /*Load all the variables*/
- ServerInfo[sVisits] = djInt("data.json","visits");
- ServerInfo[sLeaves] = djInt("data.json","leaves");
- ServerInfo[sTimeouts] = djInt("data.json","timeouts");
- ServerInfo[sKicks] = djInt("data.json","kicks");
- ServerInfo[sDeaths] = djInt("data.json","deaths");
- ServerInfo[sKills] = djInt("data.json","kills");
- ServerInfo[sCommands] = djInt("data.json","commands");
- ServerInfo[sMessages] = djInt("data.json","messages");
- ServerInfo[sPMessages] = djInt("data.json","pmessages");
- ServerInfo[sSeconds] = djInt("data.json","seconds");
- ServerInfo[sMinutes] = djInt("data.json","minutes");
- ServerInfo[sHours] = djInt("data.json","hours");
- ServerInfo[sDays] = djInt("data.json","days");
- ServerInfo[sRestarts] = djInt("data.json","starts");
- /*Show the server stats*/
- print("++++++++++++++++++++Server Stats++++++++++++++++++++++");
- printf("++ Restarts: %d | Visits: %d | Timeouts: %d", ServerInfo[sRestarts], ServerInfo[sVisits], ServerInfo[sTimeouts]);
- printf("++ Deaths: %d | Kills: %d | Commands: %d", ServerInfo[sDeaths], ServerInfo[sKills], ServerInfo[sCommands]);
- printf("++ Chat Messages: %d | Private Messages: %d", ServerInfo[sMessages], ServerInfo[sPMessages]);
- print("++++++++++++++++++++Online Time+++++++++++++++++++++++");
- printf("++ Days: %d | Hours: %d | Minutes: %d | Seconds : %d", ServerInfo[sDays], ServerInfo[sHours], ServerInfo[sMinutes], ServerInfo[sSeconds]);
- print("++++++++++++++++++++++++++++++++++++++++++++++++++++++");
- /*Timer for updating the server stats. Update time can be changed @ ligne 15*/
- SetTimer("UpdateServerStats", UPDATE_TIME*1000, 1);
- /*Timer for updating the Uptime info*/
- SetTimer("TimeUpdate", 10000, 1);
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnFilterScriptExit()
- {
- /*Save all !*/
- UpdateServerStats();
- /*Unload DJson*/
- djson_GameModeExit();
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnPlayerConnect(playerid)
- {
- /*Augment the variable of the visits*/
- ServerInfo[sVisits]++;
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnPlayerDisconnect(playerid, reason)
- {
- /*If the reason is 0 : Timeout*/
- if(reason == 0) ServerInfo[sTimeouts]++;
- /*If the reason is 1 : Leaving*/
- else if(reason == 1) ServerInfo[sLeaves]++;
- /*If the reason is 2 : Kicked or banned*/
- else if(reason == 2) ServerInfo[sKicks]++;
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnPlayerDeath(playerid, killerid, reason)
- {
- /*If the killed is not an invalid player id*/
- if(killerid != INVALID_PLAYER_ID)
- {
- /*Then augment both variables*/
- ServerInfo[sDeaths]++;
- ServerInfo[sKills]++;
- }
- /*If the killerid is an invalid player id*/
- else
- {
- /*Then just augment one variable*/
- ServerInfo[sDeaths]++;
- }
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnPlayerText(playerid, text[])
- {
- /*For every message in the chat, augment the variable*/
- ServerInfo[sMessages]++;
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnPlayerPrivmsg(playerid, recieverid, text[])
- {
- /*Same that chat message but this is PM*/
- ServerInfo[sPMessages]++;
- return 1;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- /*Same for the commands*/
- ServerInfo[sCommands]++;
- if (strcmp("/sstats", cmdtext, true) == 0)
- {
- new string[128];
- ServerInfo[sRestarts] = djInt("data.json","starts");
- SendClientMessage(playerid, COLOR_GREEN, "=== Server Stats ===");
- format(string, sizeof(string), "Restarts : %d | Visits : %d | Leaves : %d", ServerInfo[sRestarts], ServerInfo[sVisits], ServerInfo[sLeaves]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- format(string, sizeof(string), "Timeouts : %d | Kicks : %d | Commands : %d", ServerInfo[sTimeouts], ServerInfo[sKicks], ServerInfo[sCommands]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- format(string, sizeof(string), "Deaths : %d | Kills : %d | Messages : %d | PMs : %d", ServerInfo[sDeaths], ServerInfo[sKills], ServerInfo[sMessages], ServerInfo[sPMessages]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- format(string, sizeof(string), "Days : %d | Hours : %d | Minutes : %d | Seconds : %d", ServerInfo[sDays], ServerInfo[sHours], ServerInfo[sMinutes], ServerInfo[sSeconds]);
- SendClientMessage(playerid, COLOR_BLUE, string);
- return 1;
- }
- return 0;
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- /*Save all the stats =O */
- forward UpdateServerStats();
- public UpdateServerStats()
- {
- djSetInt("data.json","visits",ServerInfo[sVisits]);
- djSetInt("data.json","leaves",ServerInfo[sLeaves]);
- djSetInt("data.json","timeouts",ServerInfo[sTimeouts]);
- djSetInt("data.json","kicks",ServerInfo[sKicks]);
- djSetInt("data.json","deaths",ServerInfo[sDeaths]);
- djSetInt("data.json","kills",ServerInfo[sKills]);
- djSetInt("data.json","commands",ServerInfo[sCommands]);
- djSetInt("data.json","messages",ServerInfo[sMessages]);
- djSetInt("data.json","pmessages",ServerInfo[sPMessages]);
- djSetInt("data.json","seconds",ServerInfo[sSeconds]);
- djSetInt("data.json","minutes",ServerInfo[sMinutes]);
- djSetInt("data.json","hours",ServerInfo[sHours]);
- djSetInt("data.json","days",ServerInfo[sDays]);
- }
- /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
- forward TimeUpdate();
- public TimeUpdate()
- {
- ServerInfo[sSeconds] += 10;
- if(ServerInfo[sSeconds] == 60)
- {
- ServerInfo[sMinutes]++;
- ServerInfo[sSeconds] = 0;
- }
- if(ServerInfo[sMinutes] == 60)
- {
- ServerInfo[sHours]++;
- ServerInfo[sMinutes] = 0;
- }
- if(ServerInfo[sHours] == 24)
- {
- ServerInfo[sDays]++;
- ServerInfo[sHours] = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment