Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2011
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.57 KB | None | 0 0
  1. /*
  2.  
  3. Copyright [2011] [Anthony_prince aka Archer]
  4.  
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8.  
  9. http://www.apache.org/licenses/LICENSE-2.0
  10.  
  11. Unless required by applicable law or agreed to in writing, software
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16.  
  17. */
  18.  
  19. //===================Includes===================================================
  20. #include <a_samp>
  21. #include <YSI\y_ini> // thanks to Y_Less
  22. //===================Config=====================================================
  23. //#define FileName "Test.ini" // default name of the file which will be saved (disable it if you don't want to save the countdown
  24. #define PrintCount // Disable this if you dont wan't to print.
  25. #define Path "LoadData.ini"
  26. #define ServerName "This is my server" // This string will show when the countdown finishes
  27. //==================Strings=====================================================
  28. //Please don't touch this if you're newbie
  29. new SrvName[] = ServerName;
  30. new GeneralString[32+26];
  31. // I use "+" beacuse in this way i remember how many strings are here [CountDown, CountDownStop]
  32. //==================CountDown Settings==========================================
  33. new CountDown,
  34. _days=1,
  35. _hours=0,
  36. _minutes=0,
  37. _seconds=0
  38. ; // Set the time to CountDown
  39.  
  40. //==================Callbacks===================================================
  41. forward OpenCountDown();
  42. //==============================================================================
  43.  
  44. public OnFilterScriptInit()
  45. {
  46. print(" CountDown FilterScript Loaded" );
  47. CountDown=SetTimer("OpenCountDown",1000,true);
  48. return 1;
  49. }
  50.  
  51. public OnFilterScriptExit()
  52. {
  53. print(" CountDown FilterScript UnLoaded ");
  54. return 1;
  55. }
  56.  
  57. public OpenCountDown()
  58. {
  59. if(fexist(Path)) INI_ParseFile(Path, "%s", .bFileFirst = true);
  60. _seconds--;
  61. switch(_seconds)
  62. {
  63. case -1:
  64. _seconds = 59,
  65. _minutes--;
  66. }
  67. switch(_minutes)
  68. {
  69. case -1:
  70. _minutes = 59,
  71. _hours--;
  72. }
  73. switch(_hours)
  74. {
  75. case -1:
  76. _hours = 23,
  77. _days--;
  78. }
  79. SaveData();
  80. format(GeneralString, sizeof(GeneralString), "hostname Opens In %01dd:%02dh:%02dm:%02ds",_days,_hours,_minutes,_seconds);
  81. SendRconCommand(GeneralString);
  82. #if defined PrintCount
  83. printf(GeneralString);
  84. #endif
  85. if(!_days&&!_hours&&!_minutes&&!_seconds) CountDownStop();
  86. }
  87.  
  88. stock SaveData()
  89. {
  90. new INI:File = INI_Open(Path);
  91. //INI_SetTag(File,"CountDown");
  92. INI_WriteInt(File, "Days", _days);
  93. INI_WriteInt(File, "Hours", _hours);
  94. INI_WriteInt(File, "Minutes", _minutes);
  95. INI_WriteInt(File, "Seconds", _seconds);
  96. INI_Close(File);
  97. return 1;
  98. }
  99.  
  100. forward LoadData(name[], value[]);
  101. public LoadData(name[],value[])
  102. {
  103. INI_Int("Days", _days);
  104. INI_Int("Hours", _hours);
  105. INI_Int("Minutes", _minutes);
  106. INI_Int("Seconds", _seconds);
  107. return 1;
  108. }
  109.  
  110. stock CountDownStop()
  111. {
  112. format(GeneralString, sizeof(GeneralString), "hostname %s ", SrvName); // Here will show your Original Server Name after the count.
  113. SendRconCommand(GeneralString); // Send the RCON command
  114. SendRconCommand("password 0"); // This will open the server
  115. print(" Server Opened " ); // I use print instead of a string as above i prefer to have less lag.
  116. KillTimer(CountDown); // Stops the timer
  117. fremove(Path);
  118. }
  119.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement