Auto-IP Login[REP+]
#1

I want to add Auto-IP Login to this Admin Script http://pastebin.com/ni6CpjUH
Please Help
Reply
#2

No one?
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=187229
Reply
#4

WoW thanks for nothing... -.-
Reply
#5

Wrong section , no answers
Reply
#6

Jheeze, it's easy;
pawn Код:
public OnPlayerConnect(playerid)
{
    new plrIP[16];
    GetPlayerIp(playerid, plrIP, sizeof(plrIP));
    if(!strcmp(plrIP, "127.0.0.1"))
    SendClientMessage(playerid, 0xFFFFFFFF, "Welcome to your server .Campionull.");
    return 1;
}
Reply
#7

New Features :
  • Auto Login
  • Player dont need to login after register
CODE :
pawn Код:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <dini>

#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

#define GREY 0xAFAFAFAA
#define GREEN 0x33AA33AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define LIGHTBLUE 0x33CCFFAA
#define ORANGE 0xFF9900AA
enum gPInfo
{
    Logged,
    Regged,
    Level,
    IP[20]
};
new PInfo[MAX_PLAYERS][gPInfo];
#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("    Admin Script Tutorial By Cale");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
    // Don't use these lines if it's a filterscript
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}


public OnPlayerConnect(playerid)
{
    PInfo[playerid][Logged] = 0;
    PInfo[playerid][Regged] = 0;
    PInfo[playerid][Level] = 0;
    new n[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid,n,sizeof(n));
    format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
    if(dini_Exists(file))
    {
        new ip[20];
        GetPlayerIp(playerid,PInfo[playerid][IP],20);
        format(ip,20,"%s",dini_Get(file,"IP"));
        if(strcmp(ip,PInfo[playerid][IP],false)==0)
        {
            dini_IntSet(file,"Logged",1);
            PInfo[playerid][Logged] = 1;
            PInfo[playerid][Level] = dini_Int(file,"Level");
            SendClientMessage(playerid,YELLOW,"You have now logged in automatically!");
        }
        else
        {
            SendClientMessage(playerid,LIGHTBLUE,"You are registered, Please /login!");
            PInfo[playerid][Regged] = 1;
            PInfo[playerid][Logged] = 0;
        }
        return 1;
    }
    if(!dini_Exists(file))
    {
        SendClientMessage(playerid,LIGHTBLUE,"You are not registered, Please /register!");
        PInfo[playerid][Regged] = 0;
        PInfo[playerid][Logged] = 0;
        return 1;
    }
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new n[MAX_PLAYER_NAME], file[256];
    GetPlayerName(playerid,n,sizeof(n));
    format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
    PInfo[playerid][Logged] = 0;
    dini_IntSet(file,"Logged",0);
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], idx;
    cmd = strtok(cmdtext, idx);
    dcmd(register,8,cmdtext);
    dcmd(login,5,cmdtext);
    dcmd(setlevel,8,cmdtext);
    dcmd(kick,4,cmdtext);
    dcmd(ban,3,cmdtext);
    return 0;
}
//========================= >>> REGISTER <<< =================================//
dcmd_register(playerid,params[])
{
    new file[256],n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
    if(dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are already registered!");
    if(PInfo[playerid][Regged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already registered!");
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,ORANGE,"You are already registered, and logged in!");
    if(strlen(params))
    {
        if(!dini_Exists(file))
        {
            GetPlayerIp(playerid,PInfo[playerid][IP],20);
            dini_Create(file);
            dini_Set(file,"Password",params);
            dini_IntSet(file,"Regged",1);
            dini_IntSet(file,"Logged",0);
            dini_IntSet(file,"Level",0);
            dini_Set(file,"IP",PInfo[playerid][IP]);
            //SendClientMessage(playerid,LIGHTBLUE,"Congratulations, you have just registered, please /login");
            PInfo[playerid][Regged] = 1;
            dini_IntSet(file,"Logged",1);
            PInfo[playerid][Logged] = 1;
            PInfo[playerid][Level] = dini_Int(file,"Level");
            SendClientMessage(playerid,YELLOW,"You have now logged in automatically!");
            return 1;
        }
    }
    else
    {
        SendClientMessage(playerid,GREY,"USAGE: /register <Password>");
        return 1;
    }
    return 1;
}
//===========================>>> LOGIN <<<======================================
dcmd_login(playerid,params[])
{
    new file[256],n[MAX_PLAYER_NAME];
    GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);
    if(!dini_Exists(file)) return SendClientMessage(playerid,YELLOW,"You are not registered! Please /register");
    if(PInfo[playerid][Logged] == 1) return SendClientMessage(playerid,LIGHTBLUE,"You are already logged in!");
    if(PInfo[playerid][Regged] == 0) return SendClientMessage(playerid,ORANGE,"You are not registered! Please /register");
    if(strlen(params))
    {
        new pass[256];
        pass = dini_Get(file,"Password");
        if(dini_Exists(file))
        {
            if(strcmp(params,pass,false) != 0)
            {
                SendClientMessage(playerid,YELLOW,"Wrong Password!");
            }
            else
            {
                dini_IntSet(file,"Logged",1);
                PInfo[playerid][Logged] = 1;
                PInfo[playerid][Level] = dini_Int(file,"Level");
                SendClientMessage(playerid,YELLOW,"You have now logged in!");
                GetPlayerIp(playerid,PInfo[playerid][IP],20);
                return 1;
            }
        }
    }
    else
    {
        SendClientMessage(playerid,GREY,"USAGE: /login <Password>");
        return 1;
    }
    return 1;
}
/*==============================================================================
=============================ADMIN COMMANDS!====================================
================================================================================*/

dcmd_setlevel(playerid,params[])
{
    new level,id,file[256],n[MAX_PLAYER_NAME];//creating the new variabls
    new tmp[256], tmp2[256], Index,str[50];// creating the new variables
    tmp = strtok(params,Index), tmp2 = strtok(params,Index),id = strval(tmp),level = strval(tmp2);// setting them to strtok so we can use them as parameters of our command
    GetPlayerName(id,n,MAX_PLAYER_NAME);//getting the players name
    format(file,sizeof(file),"MyAdmin/Users/%s.txt",n);//formatting the file
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,GREY,"You are not an RCON admin!");//if the player is not rcon admin
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /setlevel <ID> <Level>");// if the string is empty
    if(!IsPlayerConnected(id))return SendClientMessage(playerid,GREY,"You have entered an incorrect ID"); //if the id is not connected
    PInfo[id][Level] = level;//sets the level of the player
    dini_IntSet(file,"Level",level);//saves the new level to the file
    format(str,sizeof(str),"You have set %s's level to %d",n,level);//creates the string
    SendClientMessage(playerid,LIGHTBLUE,str);
    return 1;
}
dcmd_kick(playerid,params[])
{
    new id,n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
    new tmp[256], Index, str[49];
    tmp = strtok(params,Index), id = strval(tmp);
    GetPlayerName(id,on,sizeof(on));
    GetPlayerName(playerid,n,sizeof(n));
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /kick <ID> ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(str,sizeof(str),"%s has kicked %s",n,on);
    SendClientMessageToAll(LIGHTBLUE,str);
    Kick(id);
    return 1;
}
dcmd_ban(playerid,params[])
{
    new id, n[MAX_PLAYER_NAME],on[MAX_PLAYER_NAME];
    new tmp[256], Index, str[49];
    tmp = strtok(params,Index), id = strval(tmp);
    GetPlayerName(id,on,sizeof(on));
    GetPlayerName(playerid,n,sizeof(n));
    if(PInfo[playerid][Level] < 3) return SendClientMessage(playerid,ORANGE,"You need to be level 3 to use this command!");
    if(!strlen(params)) return SendClientMessage(playerid,GREY,"USAGE: /ban <ID> ");
    if(!IsPlayerConnected(id)) return SendClientMessage(playerid,GREY,"Invalid ID");
    format(str,sizeof(str),"%s has banned %s",n,on);
    SendClientMessageToAll(ORANGE,str);
    Ban(id);
    return 1;
}

strtok(const string[], &index)
{
    new length = strlen(string);
    while ((index < length) && (string[index] <= ' '))
    {
        index++;
    }
    new offset = index;
    new result[20];
    while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }
    result[index - offset] = EOS;
    return result;
}
Reply
#8

Whats the point? I just pasted a pretty basic one.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)