1
0
Fork 0
mirror of https://codeberg.org/spire/sm_whitelist.git synced 2026-06-03 18:24:06 +02:00

fix not working

This commit is contained in:
Robin Appelman 2025-09-08 21:07:50 +02:00
commit c001663954

View file

@ -38,6 +38,7 @@ public Action:DownloadWhiteListAction(client, args) {
if(args != 1) { if(args != 1) {
PrintToServer("Usage: sm_whitelist_tf %whitelistid%"); PrintToServer("Usage: sm_whitelist_tf %whitelistid%");
return Plugin_Handled;
} }
GetCmdArg(1, arg, sizeof(arg)); GetCmdArg(1, arg, sizeof(arg));
@ -86,24 +87,43 @@ public onComplete(Handle:hndl, CURLcode:code, any hDLPack) {
bool exec = ReadPackCell(hDLPack); bool exec = ReadPackCell(hDLPack);
CloseHandle(hDLPack); CloseHandle(hDLPack);
new ok = false;
if (code != CURLE_OK) {
PrintToChatAll("Error downloading whitelist %s", whiteListId);
PrintToChatAll("cURL error: %d", code);
} else {
new status_code;
curl_easy_getinfo_int(hndl, CURLINFO_RESPONSE_CODE, status_code);
if (status_code == 200) {
ok = true;
if (exec) {
execWhiteList(whiteListId);
}
} else if (status_code == 404) {
PrintToChatAll("Whitelist %s not found", whiteListId);
} else {
PrintToChatAll("Error downloading whitelist %s", whiteListId);
PrintToChatAll("HTTP error: %d", status_code);
}
}
CloseHandle(hndl); CloseHandle(hndl);
if(code != CURLE_OK) { if (!ok) {
PrintToChatAll("Error downloading whitelist %s", whiteListId);
PrintToChatAll("cURLCode error: %d", code);
} else {
decl String:targetPath[128]; decl String:targetPath[128];
if(exec) { Format(targetPath, sizeof(targetPath), "cfg/%s.txt", whiteListId);
execWhiteList(targetPath); DeleteFile(targetPath);
}
} }
return; return;
} }
public execWhiteList(String:whitelist[128]) { public execWhiteList(String:whitelist[128]) {
decl String:command[512]; decl String:command[512];
PrintToChatAll("Whitelist loaded"); Format(command, sizeof(command), "mp_tournament_whitelist cfg/%s.txt", whitelist);
Format(command, sizeof(command), "mp_tournament_whitelist %s", whitelist); PrintToChatAll("Whitelist %s loaded", whitelist);
ServerCommand(command, sizeof(command)); ServerCommand(command, sizeof(command));
command = "mp_tournament_restart"; command = "mp_tournament_restart";
ServerCommand(command, sizeof(command)); ServerCommand(command, sizeof(command));