Advertisement
Guest User

doorKeeper 1.1

a guest
Feb 17th, 2015
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. {$CLEO}
  2. 0000: NOP
  3. repeat
  4. wait 50
  5. until 0AFA: is_samp_structures_available
  6. 0AF8: samp add_message_to_chat "doorKeeper is {00CC00}Enabled {F7F694}[Switch: /dk]" color 0xF7F694
  7. 0B34: samp register_client_command "dk" to_label @activate
  8. 0AF0: 31@ = get_int_from_ini_file "CLEO\INI\doorKeeper.ini" section "Settings" key "Auto on"
  9. 0AF0: 30@ = get_int_from_ini_file "CLEO\INI\doorKeeper.ini" section "Settings" key "Max players on your server"
  10. 0AF0: 29@ = get_int_from_ini_file "CLEO\INI\doorKeeper.ini" section "Settings" key "How often checks will be made"
  11.  
  12. 29@ *= 1000
  13. 33@ = 0
  14. 27@ = 0
  15. 26@ = 0 //lower range of players to check
  16. 29@ /= 20 //divide timeNeeded, to avoid lag and spread the checks through the time
  17. 28@ = 1 //multiplier of the timer
  18. 30@ /= 20 //divide max players, to avoid lag and spread the checks through the time
  19. 0085: 24@ = 29@ //24@ = stable 1/20 of the timeNeeded
  20. 0085: 25@ = 30@ //25@ = stable 1/20 of the players (needed to substract to get lower range of players to check)
  21. wait 10000
  22.  
  23. :First
  24. wait 0
  25. if and
  26. 31@ == 1
  27. 001D: 33@ > 29@ // (int)
  28. 0AAB: file_exists "CLEO\INI\doorKeeper.ini"
  29. then
  30. //0AD1: show_formatted_text_highpriority "multip=%d timeN=%d min=%d max=%d first=%d" time 10000 28@ 29@ 26@ 30@ 27@
  31. for 0@ = 26@ to 30@
  32. if 27@ == 0
  33. then
  34. //first time
  35. if 0B23: samp is_player_connected 0@
  36. then
  37. 0AB1: call_scm_func @save_to_ini 2 id 0@ isPlayer? 1
  38. else
  39. 0AB1: call_scm_func @save_to_ini 2 id 0@ isPlayer? 0
  40. end
  41. else
  42. //main work
  43. if 0B23: samp is_player_connected 0@
  44. then
  45. 0AB1: call_scm_func @compare_with_ini 2 id 0@ isPlayer? 1
  46. else
  47. 0AB1: call_scm_func @compare_with_ini 2 id 0@ isPlayer? 0
  48. end
  49. end
  50. end
  51. 28@++ //multiplier
  52. 0085: 29@ = 24@
  53. 0085: 30@ = 25@
  54. 006A: 29@ *= 28@ // multiply timer
  55. 006A: 30@ *= 28@ // multiply higher range of players to check
  56. 0085: 26@ = 30@ // copy higher range of players
  57. 0062: 26@ -= 25@ // substract 1/20 to get lower range of players
  58. if 28@ > 20
  59. then
  60. //reset to start all the checks again from ID: 0
  61. 28@ = 1
  62. 0085: 29@ = 24@
  63. 0085: 30@ = 25@
  64. 26@ = 0
  65. 33@ = 0
  66. 27@ = 1 //to make sure that the first flow of the script will be save only (without compare)
  67. end
  68. end
  69. jump @First
  70.  
  71.  
  72. :activate
  73. 0B12: 31@ = 31@ XOR 1
  74. if 31@ == 1
  75. then
  76. 0AD1: show_formatted_text_highpriority "doorKeeper ~G~on" time 1000
  77. 28@ = 1
  78. 0085: 29@ = 24@
  79. 0085: 30@ = 25@
  80. 33@ = 0
  81. 26@ = 0
  82. 27@ = 0
  83. else
  84. 0AD1: show_formatted_text_highpriority "doorKeeper ~R~off" time 1000
  85. end
  86. samp.CmdRet
  87.  
  88.  
  89. //0AB1: call_scm_func @save_to_ini 0
  90. :save_to_ini
  91. 0AC8: 2@ = allocate_memory_size 260
  92. if 1@ == 1
  93. then
  94. 0B36: samp 2@ = get_player_nickname 0@
  95. else
  96. 0AD3: 2@ = format "nope"
  97. end
  98. 0AD3: 25@v = format "ID: %d" 0@
  99. 0AF5: write_string 2@ to_ini_file "CLEO\INI\doorKeeper.ini" section "Name" key 25@v
  100. 0AC9: free_allocated_memory 2@
  101. 0AB2: ret 0
  102.  
  103. //0AB1: call_scm_func @compare_with_ini 1 num
  104. :compare_with_ini
  105. 0AC8: 24@ = allocate_memory_size 260
  106. 0AC8: 10@ = allocate_memory_size 260
  107. 0AD3: 25@v = format "ID: %d" 0@
  108. 0AF4: 24@ = read_string_from_ini_file "CLEO\INI\doorKeeper.ini" section "Name" key 25@v
  109. if 1@ == 1 //check if the player just connected
  110. then
  111. 0B36: samp 2@ = get_player_nickname 0@
  112. if 8C14: strcmp string1 24@ string2 2@
  113. then
  114. //player just connected
  115. 0B37: samp 3@ = get_player_color 0@
  116. 0AF8: samp add_message_to_chat "%s(%d){F7F694} connected" color 3@ 2@ 0@
  117. 0AF5: write_string 2@ to_ini_file "CLEO\INI\doorKeeper.ini" section "Name" key 25@v
  118. end
  119. else
  120. //check if disconnected
  121. 0AD3: 10@ = format "nope"
  122. if 8C14: strcmp string1 24@ string2 10@
  123. then
  124. //player just disconnected
  125. 0AF8: samp add_message_to_chat "%s(%d) disconnected" color 0xABABAB 24@ 0@
  126. 0AF5: write_string 10@ to_ini_file "CLEO\INI\doorKeeper.ini" section "Name" key 25@v
  127. end
  128. end
  129. 0AC9: free_allocated_memory 24@
  130. 0AC9: free_allocated_memory 10@
  131. 0AB2: ret 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement