mi0_utils.inc
Original include source with line numbers.
| 1 | #if defined _mi0_utils_included // call the file mi0_utils even though uve stolen everything in it xDDD |
| 2 | #endinput |
| 3 | #endif |
| 4 | |
| 5 | #define _mi0_utils_included |
| 6 | |
| 7 | #define SECONDS_TO_UNITS(%1) (4096 * %1) |
| 8 | |
| 9 | #if defined UTIL_FADEEFFECT // UTIL_FADEEFFECT -- Stalinnn |
| 10 | stock UTIL_MakeFadeEffect(id, iColors[3], iAlpha, Float:fDuration, iType = 0x0000) |
| 11 | { |
| 12 | message_begin(id == 0 ? MSG_ALL : MSG_ONE, SVC_DIRECTOR, .player = id) |
| 13 | write_short(floatround(SECONDS_TO_UNITS(fDuration))) |
| 14 | write_short(floatround(SECONDS_TO_UNITS(fDuration))) |
| 15 | write_short(iType) |
| 16 | write_byte(iColors[0]) |
| 17 | write_byte(iColors[1]) |
| 18 | write_byte(iColors[2]) |
| 19 | write_byte(iAlpha) |
| 20 | message_end() |
| 21 | } |
| 22 | #endif // UTIL_FADEEFFECT |
| 23 | |
| 24 | #if defined UTIL_HUDMESSAGE // UTIL_HUDMESSAGE -- Stolennn |
| 25 | stock UTIL_SendHudmessage(id, const szMessage[], R, G, B, Float:X, Float:Y, A=255, effect=0, effect_R=0, effect_G=0, effect_B=0, effect_A=255, Float:holdtime=5.0, Float:fadeintime=0.1, Float:fadeouttime=0.1, channel=-1, Float:effecttime=0.0) |
| 26 | { |
| 27 | if (id) |
| 28 | message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, {0,0,0}, id) |
| 29 | else |
| 30 | message_begin(MSG_BROADCAST, SVC_TEMPENTITY) |
| 31 | write_byte(TE_TEXTMESSAGE) |
| 32 | write_byte(channel) |
| 33 | write_short(coord_to_hudmsgshort(X)) |
| 34 | write_short(coord_to_hudmsgshort(Y)) |
| 35 | write_byte(effect) |
| 36 | write_byte(R) |
| 37 | write_byte(G) |
| 38 | write_byte(B) |
| 39 | write_byte(A) |
| 40 | write_byte(effect_R) |
| 41 | write_byte(effect_G) |
| 42 | write_byte(effect_B) |
| 43 | write_byte(effect_A) |
| 44 | write_short(seconds_to_hudmsgshort(fadeintime)) |
| 45 | write_short(seconds_to_hudmsgshort(fadeouttime)) |
| 46 | write_short(seconds_to_hudmsgshort(holdtime)) |
| 47 | if (effect == 2) |
| 48 | write_short(seconds_to_hudmsgshort(effecttime)) |
| 49 | write_string(text) |
| 50 | message_end() |
| 51 | } |
| 52 | |
| 53 | stock seconds_to_hudmsgshort(Float:sec) |
| 54 | { |
| 55 | new output = floatround(sec * 256) |
| 56 | return output < 0 ? 0 : output > 65535 ? 65535 : output |
| 57 | } |
| 58 | |
| 59 | stock coord_to_hudmsgshort(Float:coord) |
| 60 | { |
| 61 | new output = floatround(coord * 8192) |
| 62 | return output < -32768 ? -32768 : output > 32767 ? 32767 : output |
| 63 | } |
| 64 | #endif // UTIL_HUDMESSAGE |
| 65 | |
| 66 | #if defined UTIL_CLIENTCMD // UTIL_CLIENTCMD -- Who said dont steal all my code??? Huehue was it u? |
| 67 | stock UTIL_ClientCMD(id, const szText[], any:...) |
| 68 | { |
| 69 | #pragma unused szText |
| 70 | |
| 71 | if (id == 0 || is_user_connected(id)) |
| 72 | { |
| 73 | new szMessage[256] |
| 74 | format_args(szMessage, charsmax(szMessage), 1) |
| 75 | |
| 76 | message_begin(id == 0 ? MSG_ALL : MSG_ONE, SVC_DIRECTOR, .player = id) |
| 77 | write_byte(strlen(szMessage) + 2) |
| 78 | write_byte(10) |
| 79 | write_string(szMessage) |
| 80 | message_end() |
| 81 | } |
| 82 | } |
| 83 | #endif // UTIL_CLIENTCMD |
| 84 | |
| 85 | #if defined UTIL_LICENSE // UTIL_LICENSE -- Definately not stolen xDDD |
| 86 | stock UTIL_CheckServerLicense(const szIP[], szFileName[]) |
| 87 | { |
| 88 | new szServerIP[20] |
| 89 | get_user_ip(0, szServerIP, charsmax(szServerIP), 0) |
| 90 | |
| 91 | if (!equal(szServerIP, szIP)) |
| 92 | { |
| 93 | #if UTIL_LICENSE 0 |
| 94 | log_amx("[License] ERROR: Checking Failed. Fixing Begins in 5 Seconds!!!") |
| 95 | set_task(5.0, "FixServer") |
| 96 | #elseif |
| 97 | log_amx("[License] ERROR: Checking Failed. Shutting Down!!!") |
| 98 | server_cmd("exit") |
| 99 | #endif |
| 100 | } |
| 101 | else |
| 102 | { |
| 103 | log_amx("[License] License IP: <%s>. Your Server IP is: <%s>. IP Checking verified! DONE.", szIP, szServerIP) |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | #if UTIL_LICENSE 0 |
| 108 | public FixServer() |
| 109 | { |
| 110 | delete_file(szFileName) |
| 111 | set_task(1.0, "ResetMap") |
| 112 | } |
| 113 | |
| 114 | public ResetMap() |
| 115 | { |
| 116 | server_cmd("restart") |
| 117 | } |
| 118 | #endif |
| 119 | #endif // UTIL_LICENSE |
| 120 | |
| 121 | #if defined UTIL_KUR // UTIL_KUR -- The Best Thing in the mod rn |
| 122 | stock UTIL_Kur(id) |
| 123 | { |
| 124 | client_print(id, UTIL_KUR, "Ti poluchavash:") |
| 125 | client_print(id, UTIL_KUR, "K") |
| 126 | client_print(id, UTIL_KUR, "U") |
| 127 | client_print(id, UTIL_KUR, "R") |
| 128 | client_print(id, UTIL_KUR, "_|_") |
| 129 | } |
| 130 | #endif // UTIL_KUR |
| 131 | |
| 132 | #if defined UTIL_PERCENT // some useless shit |
| 133 | stock bool:UTIL_Percent(Float:fPercent) |
| 134 | { |
| 135 | return random(100) < fPercent |
| 136 | } |
| 137 | #endif |
| 138 | |