Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #if !defined _INC_FileFunctions
- #tryinclude FileFunctions
- #if !defined _INC_FileFunctions
- #error You need have File Function Plugin Include To Use GetConsoleVarAs Fixer
- #endif
- #endif
- #define MAX_RCONS_IN_A_SEC 3 // <- to handle pass and ip of rcon per second [ 3 by default ]
- #if !defined GlobalUse
- #define GlobalUse false
- #endif
- new J_LastRPass[MAX_RCONS_IN_A_SEC][75], J_LastRIP[MAX_RCONS_IN_A_SEC][20];
- public OnRconLoginAttempt(ip[], password[], success)
- {
- if(IsIPConnected(ip))
- {
- new r_pass = GetRPass(password);
- new r_ip = GetRIP(ip);
- SetTimerEx("J_MoveTheFile", 100, 0, "dd",r_pass,r_ip);
- }
- }
- IsIPConnected(const ip11[])
- {
- new ip[20];
- for(new i = 0; i < MAX_PLAYERS; i++)
- {
- if(!IsPlayerConnected(i)) continue;
- GetPlayerIp(i, ip, sizeof ip);
- if(!strcmp(ip11, ip, true))
- {
- return 1;
- }
- }
- return 0;
- }
- GetRPass(const password[])
- {
- for(new i = 0; i < MAX_RCONS_IN_A_SEC; i++)
- {
- if(!strlen(J_LastRPass[i]))
- {
- format(J_LastRPass[i], sizeof J_LastRPass[], password);
- return i;
- }
- }
- return -1;
- }
- GetRIP(const ip_zz[])
- {
- for(new i = 0; i < MAX_RCONS_IN_A_SEC; i++)
- {
- if(!strlen(J_LastRIP[i]))
- {
- format(J_LastRIP[i], sizeof J_LastRIP[], ip_zz);
- return i;
- }
- }
- return -1;
- }
- forward J_MoveTheFile(Pass_ID, IP_ID);
- public J_MoveTheFile(Pass_ID, IP_ID)
- {
- new File:handle = fileOpen("server_log.txt", io_Read);
- if(handle)
- {
- fileSeek(File: handle, -1800, seek_End);
- new buf[250], Handle[1850];
- while(fileRead(handle, buf))
- {
- strcat(Handle, buf);
- }
- while(strfind(Handle, "RCON (In-Game)", true, 0) != -1)
- {
- new where = strfind(Handle, "RCON (In-Game)", true, where);
- if(where != -1)
- strdel(Handle, 0, where+2);
- else
- strdel(Handle, strfind(Handle, "login.", true, where)+6, strlen(Handle));
- }
- new where;
- if(strfind(Handle,"\n", true))
- {
- strdel(Handle, strlen(Handle)-2, strlen(Handle));
- }
- new Rsuccess;
- if(strfind(Handle, "has logged in", false, 0) != -1)
- {
- Rsuccess = 1;
- }
- else
- {
- Rsuccess = 0;
- }
- where = strfind(Handle,"#", true, 0);
- if(where != -1)
- {
- strdel(Handle, 0, where+1);
- strdel(Handle, strfind(Handle, " ", true, 0), strlen(Handle));
- }
- #if !GlobalUse
- CallLocalFunction("OnRconLogin", "dssd", strval(Handle), J_LastRIP[IP_ID], J_LastRPass[Pass_ID], Rsuccess);
- #else
- CallRemoteFunction("OnRconLogin", "dssd", strval(Handle), J_LastRIP[IP_ID], J_LastRPass[Pass_ID], Rsuccess);
- #endif
- fileClose(handle);
- J_LastRIP[IP_ID] = "\0";
- J_LastRPass[Pass_ID] = "\0";
- }
- }
- forward public OnRconLogin(playerid, RIp[], RPassword[], RSuccess);
- #if defined _ALS_OnRconLoginAttempt
- #undef OnRconLoginAttempt
- #endif
- #define _ALS_OnRconLoginAttempt
- #define OnRconLoginAttempt OnRconLoginAttemptEx
- forward OnRconLoginAttemptEx(ip[], password[], success);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement