Advertisement
System32

S32_Changelog

Feb 16th, 2012
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.29 KB | None | 0 0
  1. /*
  2.      ••••    •     •      ••••    •••••     •••••     ••     ••   •••••     •••••
  3.     •         •   •      •          •     •       • •   • •       •   •  •
  4.      ••••      • •        ••••      •     •••     •  • •  •   •••••     •
  5.          •      •             •     •     •       •   •   •       •    •
  6.      ••••        •          ••••      •     •••••   •       •   •••••   •••••
  7. */
  8.  
  9. #include <a_samp>
  10. #include <a_mysql>
  11. #include <YSI\y_commands>
  12.  
  13. #define TOTAL_LOGS_SHOWED 3
  14.  
  15. new clQuery[1200];
  16.  
  17. public OnFilterScriptInit()
  18. {
  19.     print("\n");
  20.     print("  \4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4");
  21.     print("  \4 S32_Changelog \4");
  22.     print("  \4 by            \4");
  23.     print("  \4 System32      \4");
  24.     print("  \4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\4\n");
  25.    
  26.     mysql_connect("localhost", "root", "sa:mp", "");
  27.     mysql_debug(1);
  28.     return 1;
  29. }
  30.  
  31. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  32. {
  33.     switch(dialogid)
  34.     {
  35.         case 31000: return 0;
  36.     }
  37.     return 1;
  38. }
  39.  
  40. YCMD:changelog(playerid, params[], help)
  41. {
  42.     #pragma unused help
  43.     new id, text[512], Date_Time[6], Final_Date_Time[50];
  44.     if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "Only RCON admins can use this!");
  45.     if(sscanf(params, "s[512]", text)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /changelog [Text]");
  46.     if(strlen(text) < 15 || strlen(text) > 512) return SendClientMessage(playerid, 0xFF0000FF, "Text must be between 15 & 512 characters!");
  47.     getdate(Date_Time[0], Date_Time[1], Date_Time[2]);
  48.     gettime(Date_Time[3], Date_Time[4], Date_Time[5]);
  49.     format(Final_Date_Time, sizeof(Final_Date_Time), "%d.%d.%d. %d:%d", Date_Time[2], Date_Time[1], Date_Time[0], Date_Time[3], Date_Time[4], Date_Time[5]);
  50.     SendClientMessage(playerid, -1, "Change log is succesfully updated!");
  51.  
  52.     mysql_query("SELECT `ID` FROM `changelog` ORDER BY `ID` DESC LIMIT 1");
  53.     mysql_store_result();
  54.     id = mysql_fetch_int();
  55.     id ++;
  56.     mysql_free_result();
  57.    
  58.     mysql_format(1, clQuery, "INSERT INTO `changelog` (`Text`, `Player`, `Date`, `ID`) VALUES ('%e', '%e', '%e', %d)", text, GetName(playerid), Final_Date_Time, id);
  59.     mysql_query(clQuery);
  60.     return 1;
  61. }
  62.  
  63. YCMD:updates(playerid, params[], help)
  64. {
  65.     #pragma unused help
  66.     #pragma unused params
  67.     new id, clstring[520 * TOTAL_LOGS_SHOWED], textstr[TOTAL_LOGS_SHOWED][512], player[TOTAL_LOGS_SHOWED][24], date[TOTAL_LOGS_SHOWED][50];
  68.     mysql_query("SELECT * FROM `changelog` ORDER BY `ID` DESC LIMIT "#TOTAL_LOGS_SHOWED"");
  69.     mysql_store_result();
  70.     while(mysql_retrieve_row())
  71.     {
  72.         mysql_fetch_field_row(textstr[id], "Text");
  73.         mysql_fetch_field_row(player[id], "Player");
  74.         mysql_fetch_field_row(date[id], "Date");
  75.         format(clstring, sizeof(clstring), "{FFFFFF}%s %d. {F81414}%s {FFFFFF}- %s   {F81414}Posted on: {FFFFFF}%s\n", clstring, id + 1, player[id], textstr[id], date[id]);
  76.         id++;
  77.     }
  78.     ShowPlayerDialog(playerid, 31000, DIALOG_STYLE_MSGBOX, "{FFFFFF}      Changelog", clstring, "Ok", "");
  79.     mysql_free_result();
  80.     return 1;
  81. }
  82.  
  83. stock GetName(playerid)
  84. {
  85.     new PlayerName[MAX_PLAYER_NAME];
  86.     GetPlayerName(playerid, PlayerName, sizeof(PlayerName));
  87.     return PlayerName;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement