Witamy w Nieoficjalnym polskim support'cie AMX Mod X
Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.
|
Guest Message by DevFuse
Wklejka n5brnd7jcliv dodana przez patryQ1997, 28.09.2014 19:50
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109.
/*
*
* Author: Cheesy Peteza
* Date: 18-Mar-2004
*
*
* Description: A generic AFK Kicker that should work with nearly all Half-Life mods.
* Tested with Natural-Selection v3.0 beta 3, Counter-Strike 1.6 and Day of Defeat.
*
* Cvars:
* mp_afktime 90 Time a player is allowed to be AFK in seconds before they are kicked. (minimum 30 sec)
* They time is only accumulated while they are alive.
* mp_afkminplayers 8 Minimum number of players required to be on the server before the plugin starts kicking.
*
*
* Requirements: AMXModX
*
*
*/
#include <amxmodx>
#include <ColorChat>
#define MIN_AFK_TIME 30 // I use this incase stupid admins accidentally set mp_afktime to something silly.
#define WARNING_TIME 15 // Start warning the user this many seconds before they are about to be kicked.
#define CHECK_FREQ 5 // This is also the warning message frequency.
new g_oldangles[33][3]
new g_afktime[33]
new bool:g_spawned[33] = {true, ...}
public plugin_init() {
register_plugin("AFK Kicker","1.0b","Cheesy Peteza")
register_cvar("afk_version", "1.0b", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
register_cvar("mp_afktime", "15") // Kick people AFK longer than this time
register_cvar("mp_afkminplayers", "1") // Only kick AFKs when there is atleast this many players on the server
set_task(float(CHECK_FREQ),"checkPlayers",_,_,_,"b")
register_event("ResetHUD", "playerSpawned", "be")
}
public checkPlayers() {
for (new i = 1; i <= get_maxplayers(); i++) {
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned[i]) {
new newangle[3]
get_user_origin(i, newangle)
if ( newangle[0] == g_oldangles[i][0] && newangle[1] == g_oldangles[i][1] && newangle[2] == g_oldangles[i][2] ) {
g_afktime[i] += CHECK_FREQ
check_afktime(i)
} else {
g_oldangles[i][0] = newangle[0]
g_oldangles[i][1] = newangle[1]
g_oldangles[i][2] = newangle[2]
g_afktime[i] = 0
}
}
}
return PLUGIN_HANDLED
}
check_afktime(id) {
new numplayers = get_playersnum()
new minplayers = get_cvar_num("mp_afkminplayers")
if (numplayers >= minplayers) {
new maxafktime = get_cvar_num("mp_afktime")
if (maxafktime < MIN_AFK_TIME) {
log_amx("cvar mp_afktime %i is too low. Minimum value is %i.", maxafktime, MIN_AFK_TIME)
maxafktime = MIN_AFK_TIME
set_cvar_num("mp_afktime", MIN_AFK_TIME)
}
if ( maxafktime-WARNING_TIME <= g_afktime[id] < maxafktime) {
new timeleft = maxafktime - g_afktime[id]
ColorChat(id, GREEN, "de_dust2^x01 # Za^x03 %i^x01 sekund zostaniesz wyrzucony jako AFK!", timeleft)
} else if (g_afktime[id] > maxafktime) {
new name[32]
get_user_name(id, name, 31)
ColorChat(0, GREEN, "de_dust2^x01 # Gracz^x03 %s^x01 zostal wyrzucony jako AFK.", name)
log_amx("%s was kicked for being AFK longer than %i seconds", name, maxafktime)
server_cmd("kick #%d ^"Zostales wyrzucony z powodu AFK^"", get_user_userid(id), maxafktime)
}
}
}
public client_connect(id) {
g_afktime[id] = 0
return PLUGIN_HANDLED
}
public client_putinserver(id) {
g_afktime[id] = 0
return PLUGIN_HANDLED
}
public playerSpawned(id) {
g_spawned[id] = false
new sid[1]
sid[0] = id
set_task(0.75, "delayedSpawn",_, sid, 1) // Give the player time to drop to the floor when spawning
return PLUGIN_HANDLED
}
public delayedSpawn(sid[]) {
get_user_origin(sid[0], g_oldangles[sid[0]])
g_spawned[sid[0]] = true
return PLUGIN_HANDLED
}
Dodanych wklejek: 15354
Powered By (Pav32) Pastebin © 2011


Dodatki SourceMod


