mirror of
https://codeberg.org/spire/sm_whitelist.git
synced 2026-06-03 10:14:07 +02:00
fix not working
This commit is contained in:
parent
4ee80d8576
commit
c001663954
1 changed files with 28 additions and 8 deletions
|
|
@ -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);
|
||||||
CloseHandle(hndl);
|
|
||||||
|
|
||||||
if(code != CURLE_OK) {
|
new ok = false;
|
||||||
|
if (code != CURLE_OK) {
|
||||||
PrintToChatAll("Error downloading whitelist %s", whiteListId);
|
PrintToChatAll("Error downloading whitelist %s", whiteListId);
|
||||||
PrintToChatAll("cURLCode error: %d", code);
|
PrintToChatAll("cURL error: %d", code);
|
||||||
} else {
|
} else {
|
||||||
decl String:targetPath[128];
|
new status_code;
|
||||||
if(exec) {
|
curl_easy_getinfo_int(hndl, CURLINFO_RESPONSE_CODE, status_code);
|
||||||
execWhiteList(targetPath);
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
if (!ok) {
|
||||||
|
decl String:targetPath[128];
|
||||||
|
Format(targetPath, sizeof(targetPath), "cfg/%s.txt", whiteListId);
|
||||||
|
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));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue