Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <ftp>
- #if !defined unformat
- #error "sscanf-ot töltsd le innen: https://github.com/maddinat0r/sscanf/releases"
- #endif
- // Ha muszáj követni az elnevezéseket..
- #define Connect CreateFTP
- #define Disconnect DestroyFTP
- #define Download DownloadFTP
- #define RCONCOMMAND:%1(%2) forward rconcmd_%1(%2);public rconcmd_%1(%2)
- new RconFTP = INVALID_FTP_ID;
- public OnFilterScriptExit() {
- if (RconFTP != INVALID_FTP_ID) Disconnect(RconFTP);
- return 1;
- }
- public OnRconCommand(cmd[]) {
- // kb. mint a zcmd féle parancskezelők csak összekókányolva
- new command[32] = "rconcmd_", i = 0;
- for (; cmd[i] && i < 32; i++) {
- if (cmd[i] == ' ') {
- if (funcidx(command) != (-1)) return CallLocalFunction(command, "s", cmd[++i]);
- break;
- }
- command[i+8] = cmd[i];
- }
- if (funcidx(command) != (-1)) return CallLocalFunction(command, "s", "\1");
- return 0;
- }
- RCONCOMMAND:connect(params[]) {
- if (RconFTP != INVALID_FTP_ID) {
- printf("Már csatlakozva vagy egy ftp-hez!");
- return 1;
- }
- new host[MAX_IPV4_LEN], port, user[24], pass[24];
- // S(alap érték) opcionális string, I(érték) opcionális integer
- if (unformat(params, "s[15]I(21)S()[24]S()[24]", host, port, user, pass)) {
- print(" connect host [port] [user] [pass]");
- return 1;
- }
- if (Connect(host, port, user, pass) == INVALID_FTP_ID) {
- print("A kapcsolódás nem sikerült!");
- }
- return 1;
- }
- RCONCOMMAND:disconnect(params[]) {
- if (RconFTP == INVALID_FTP_ID) {
- printf("Nem vagy csatlakozva ftp-hez!");
- return 1;
- }
- Disconnect(RconFTP);
- RconFTP = INVALID_FTP_ID;
- return 1;
- }
- RCONCOMMAND:download(params[]) {
- if (RconFTP == INVALID_FTP_ID) {
- printf("Nem vagy csatlakozva ftp-hez!");
- return 1;
- }
- new file[MAX_PATH_LEN], saveAs[MAX_PATH_LEN];
- if (unformat(params, "s[24]S()[24]", file, saveAs)) {
- print(" download fájlnév [mentés mint]");
- return 1;
- }
- if (strlen(saveAs) < 1) format(saveAs, MAX_PATH_LEN, file);
- if (!Download(RconFTP, file, saveAs)) {
- printf("Már folyamatban van egy letöltés");
- }
- return 1;
- }
- public OnFileDownloaded(ftpId, file[], savedAs[]) {
- printf("[ftp] %s letöltve ide: %s", file, savedAs);
- return 1;
- }
- public OnFTPFileNotFound(ftpId, file[]) {
- printf("[ftp] %s nem található!", file);
- return 1;
- }
- public OnFTPConnected(ftpId) {
- RconFTP = ftpId;
- printf("[ftp] kapcsolat létrejött", ftpId);
- return 1;
- }
- new reasonString[][] = {
- "No reason",
- "Need account for login",
- "Username okay, need password",
- "Invalid username or password",
- "Connection timed out",
- "Not logged in"
- };
- public OnFTPDisconnected(ftpId, reason) {
- printf("[ftp] kapcsolat bontva (ok: %s)", reasonString[reason]);
- RconFTP = INVALID_FTP_ID;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement