Cześć, Ostatnio myślałem o próbie napisania pluginu który zamraża gracza oraz nie pozwala mu strzelać, co się udało.
Chciałem go rozbudować o zapisywanie SID do pliku TXT i blokowanie każdego gracza z danym SID który jest obecnie na serwerze.
Niestety nie mogę przeprowadzić tego pluginu przez proces kompilacji i nie rozumiem dlaczego, czy możecie mi w tym pomóc?
Załączam plugin który zatrzymuje (podstawke) i w cytacie to co rozbudowałem.
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> #include <fun> #define PLUGIN "AMX Stay" #define VERSION "1.0" #define AUTHOR "mT[1]g" new bool:g_bStayBlocked[33]; new Float:g_fMaxSpeed[33]; new String:g_szBlockedSIDs[100][32]; new g_iBlockedCount = 0; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); register_concmd("amx_stay", "cmd_amx_stay", ADMIN_BAN, "<nick/steamid> - Zatrzymaj/odblokuj gracza"); register_concmd("amx_stay_remove", "cmd_amx_stay_remove", ADMIN_BAN, "<SID> - Usuń SID z blokady"); RegisterHam(Ham_Spawn, "player", "client_spawn", 1); register_forward(FM_CmdStart, "on_cmd_start", 1); LoadBlockedSIDs(); } LoadBlockedSIDs() { new file[64]; formatex(file, sizeof(file), "blocked_sids.txt"); new handle = fopen(file, "r"); if (handle) { while (!feof(handle)) { new line[32]; fgets(line, sizeof(line), handle); if (line[0] != '\0') { trim(line); formatex(g_szBlockedSIDs[g_iBlockedCount], sizeof(g_szBlockedSIDs[g_iBlockedCount]), "%s", line); g_iBlockedCount++; } } fclose(handle); } } SaveBlockedSID(szSID[]) { new file[64]; formatex(file, sizeof(file), "blocked_sids.txt"); new handle = fopen(file, "a"); if (handle) { fprintf(handle, "%s^n", szSID); fclose(handle); } } RemoveBlockedSID(szSID[]) { new file[64]; formatex(file, sizeof(file), "blocked_sids.txt"); new handle = fopen(file, "r"); new tempFile[64]; formatex(tempFile, sizeof(tempFile), "temp_blocked_sids.txt"); new tempHandle = fopen(tempFile, "w"); if (handle && tempHandle) { while (!feof(handle)) { new line[32]; fgets(line, sizeof(line), handle); if (line[0] != "\0") { trim(line); if (!equal(line, szSID)) { fprintf(tempHandle, "%s^n", line); } } } fclose(handle); fclose(tempHandle); delete_file(file); rename_file(tempFile, file); } } public cmd_amx_stay(id, level, cid) { if (!(get_user_flags(id) & ADMIN_BAN)) { client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy."); return PLUGIN_HANDLED; } if (read_argc() < 2) { client_print(id, print_console, "[AMX Stay] Użycie: amx_stay <nick/steamid>"); return PLUGIN_HANDLED; } new arg[32]; read_argv(1, arg, charsmax(arg)); new target = FindTarget(arg); if (!target) { client_print(id, print_console, "[AMX Stay] Nie znaleziono gracza o nicku/SteamID: %s", arg); return PLUGIN_HANDLED; } new targetSID[32]; get_user_authid(target, targetSID, charsmax(targetSID)); for (new i = 0; i < g_iBlockedCount; i++) { if (equal(g_szBlockedSIDs[i], targetSID)) { client_print(id, print_console, "[AMX Stay] Gracz z SID %s jest zablokowany.", targetSID); return PLUGIN_HANDLED; } } SaveBlockedSID(targetSID); g_bStayBlocked[target] = true; g_fMaxSpeed[target] = get_user_maxspeed(target); set_user_maxspeed(target, 0.1); new target_name[32]; get_user_name(target, target_name, charsmax(target_name)); new message[64]; formatex(message, charsmax(message), "[AMX Stay] Zatrzymano gracza %s.", target_name); client_print(id, print_console, message); return PLUGIN_HANDLED; } public cmd_amx_stay_remove(id, level, cid) { if (!(get_user_flags(id) & ADMIN_BAN)) { client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy."); return PLUGIN_HANDLED; } if (read_argc() < 2) { client_print(id, print_console, "[AMX Stay] Użycie: amx_stay_remove <SID>"); return PLUGIN_HANDLED; } new arg[32]; read_argv(1, arg, charsmax(arg)); bool found = false; for (new i = 0; i < g_iBlockedCount; i++) { if (equal(g_szBlockedSIDs[i], arg)) { found = true; break; } } if (!found) { client_print(id, print_console, "[AMX Stay] SID %s nie został znaleziony w blokadzie.", arg); return PLUGIN_HANDLED; } RemoveBlockedSID(arg); client_print(id, print_console, "[AMX Stay] SID %s został usunięty z blokady.", arg); return PLUGIN_HANDLED; } public client_disconnect(id) { g_bStayBlocked[id] = false; g_fMaxSpeed[id] = 0.1; } public client_spawn(id) { if (g_bStayBlocked[id]) { set_user_maxspeed(id, 0.1); } } public on_cmd_start(id, uc_handle, seed) { if (!g_bStayBlocked[id]) { return FMRES_IGNORED; } set_user_maxspeed(id, 0.1); static uc_cmd; uc_cmd = get_uc(uc_handle, UC_Buttons); set_uc(uc_handle, UC_Buttons, uc_cmd & ~(IN_ATTACK | IN_ATTACK2 | IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT | IN_JUMP | IN_USE)); return FMRES_SUPERCEDE; } FindTarget(szKey[]) { new iTarget = 0; trim(szKey); remove_quotes(szKey); if (szKey[0] == "#") { iTarget = find_player("a", szKey + 1); } else if ((iTarget = find_player("b", szKey))) { return iTarget; } else if ((iTarget = find_player("c", szKey))) { return iTarget; } return iTarget; }
Cześć, Ostatnio myślałem o próbie napisania pluginu który zamraża gracza oraz nie pozwala mu strzelać, co się udało.
Chciałem go rozbudować o zapisywanie SID do pliku TXT i blokowanie każdego gracza z danym SID który jest obecnie na serwerze.
Niestety nie mogę przeprowadzić tego pluginu przez proces kompilacji i nie rozumiem dlaczego, czy możecie mi w tym pomóc?
Załączam plugin który zatrzymuje (podstawke) i w cytacie to co rozbudowałem.
#include <amxmodx> #include <amxmisc> #include <fakemeta> #include <hamsandwich> #include <fun> #define PLUGIN "AMX Stay" #define VERSION "1.0" #define AUTHOR "mT[1]g" new bool:g_bStayBlocked[33]; new Float:g_fMaxSpeed[33]; new String:g_szBlockedSIDs[100][32]; new g_iBlockedCount = 0; public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR); register_concmd("amx_stay", "cmd_amx_stay", ADMIN_BAN, "<nick/steamid> - Zatrzymaj/odblokuj gracza"); register_concmd("amx_stay_remove", "cmd_amx_stay_remove", ADMIN_BAN, "<SID> - Usuń SID z blokady"); RegisterHam(Ham_Spawn, "player", "client_spawn", 1); register_forward(FM_CmdStart, "on_cmd_start", 1); LoadBlockedSIDs(); } LoadBlockedSIDs() { new file[64]; formatex(file, sizeof(file), "blocked_sids.txt"); new handle = fopen(file, "r"); if (handle) { while (!feof(handle)) { new line[32]; fgets(line, sizeof(line), handle); if (line[0] != '\0') { trim(line); formatex(g_szBlockedSIDs[g_iBlockedCount], sizeof(g_szBlockedSIDs[g_iBlockedCount]), "%s", line); g_iBlockedCount++; } } fclose(handle); } } SaveBlockedSID(szSID[]) { new file[64]; formatex(file, sizeof(file), "blocked_sids.txt"); new handle = fopen(file, "a"); if (handle) { fprintf(handle, "%s^n", szSID); fclose(handle); } } RemoveBlockedSID(szSID[]) { new file[64]; formatex(file, sizeof(file), "blocked_sids.txt"); new handle = fopen(file, "r"); new tempFile[64]; formatex(tempFile, sizeof(tempFile), "temp_blocked_sids.txt"); new tempHandle = fopen(tempFile, "w"); if (handle && tempHandle) { while (!feof(handle)) { new line[32]; fgets(line, sizeof(line), handle); if (line[0] != "\0") { trim(line); if (!equal(line, szSID)) { fprintf(tempHandle, "%s^n", line); } } } fclose(handle); fclose(tempHandle); delete_file(file); rename_file(tempFile, file); } } public cmd_amx_stay(id, level, cid) { if (!(get_user_flags(id) & ADMIN_BAN)) { client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy."); return PLUGIN_HANDLED; } if (read_argc() < 2) { client_print(id, print_console, "[AMX Stay] Użycie: amx_stay <nick/steamid>"); return PLUGIN_HANDLED; } new arg[32]; read_argv(1, arg, charsmax(arg)); new target = FindTarget(arg); if (!target) { client_print(id, print_console, "[AMX Stay] Nie znaleziono gracza o nicku/SteamID: %s", arg); return PLUGIN_HANDLED; } new targetSID[32]; get_user_authid(target, targetSID, charsmax(targetSID)); for (new i = 0; i < g_iBlockedCount; i++) { if (equal(g_szBlockedSIDs[i], targetSID)) { client_print(id, print_console, "[AMX Stay] Gracz z SID %s jest zablokowany.", targetSID); return PLUGIN_HANDLED; } } SaveBlockedSID(targetSID); g_bStayBlocked[target] = true; g_fMaxSpeed[target] = get_user_maxspeed(target); set_user_maxspeed(target, 0.1); new target_name[32]; get_user_name(target, target_name, charsmax(target_name)); new message[64]; formatex(message, charsmax(message), "[AMX Stay] Zatrzymano gracza %s.", target_name); client_print(id, print_console, message); return PLUGIN_HANDLED; } public cmd_amx_stay_remove(id, level, cid) { if (!(get_user_flags(id) & ADMIN_BAN)) { client_print(id, print_console, "[AMX Stay] Nie masz uprawnień do użycia tej komendy."); return PLUGIN_HANDLED; } if (read_argc() < 2) { client_print(id, print_console, "[AMX Stay] Użycie: amx_stay_remove <SID>"); return PLUGIN_HANDLED; } new arg[32]; read_argv(1, arg, charsmax(arg)); bool found = false; for (new i = 0; i < g_iBlockedCount; i++) { if (equal(g_szBlockedSIDs[i], arg)) { found = true; break; } } if (!found) { client_print(id, print_console, "[AMX Stay] SID %s nie został znaleziony w blokadzie.", arg); return PLUGIN_HANDLED; } RemoveBlockedSID(arg); client_print(id, print_console, "[AMX Stay] SID %s został usunięty z blokady.", arg); return PLUGIN_HANDLED; } public client_disconnect(id) { g_bStayBlocked[id] = false; g_fMaxSpeed[id] = 0.1; } public client_spawn(id) { if (g_bStayBlocked[id]) { set_user_maxspeed(id, 0.1); } } public on_cmd_start(id, uc_handle, seed) { if (!g_bStayBlocked[id]) { return FMRES_IGNORED; } set_user_maxspeed(id, 0.1); static uc_cmd; uc_cmd = get_uc(uc_handle, UC_Buttons); set_uc(uc_handle, UC_Buttons, uc_cmd & ~(IN_ATTACK | IN_ATTACK2 | IN_FORWARD | IN_BACK | IN_MOVELEFT | IN_MOVERIGHT | IN_JUMP | IN_USE)); return FMRES_SUPERCEDE; } FindTarget(szKey[]) { new iTarget = 0; trim(szKey); remove_quotes(szKey); if (szKey[0] == "#") { iTarget = find_player("a", szKey + 1); } else if ((iTarget = find_player("b", szKey))) { return iTarget; } else if ((iTarget = find_player("c", szKey))) { return iTarget; } return iTarget; }
Załączone pliki
Użytkownik esticire edytował ten post 17.01.2025 23:09