Making it kick
#1

Hey, so, recently I have noticed there are alot of tutorials on how to expand LAdmin bye LethaL, e.g. Making save score, or adding ranks to it. But I was wondering, becuase it has a /login command, a user could set there name to a admins name or well know players name, come online and spam out and be a n00b. So I thought a login/register dialog, I wasnt long before I found one: http://forum.sa-mp.com/archive/index.php/t-161491.html

So, I installed it and it worked perfectly! But, instead of OnPlayerSpawn, I put it to OnPlayerConnect, and I am soon to remove the /login and /register commands.

But, if they click on Exit, it just sends them to the class selection, so I need yout help so when they press "Exit" it kicks them. And the kick function must work on all the dialogs: Wrong Password, Login, and Register.

I tried it myself, but failed. :/

So, can you please help?

-TK100
Reply
#2

Anyone
Reply
#3

pawn Код:
if (!response) return Kick(playerid);
Voila.
Reply
#4

pawn Код:
if(!response) return Kick(playerid);
Reply
#5

OnPlayerConnect:

pawn Код:
public OnPlayerConnect(playerid)
{
    PlayerInfo[playerid][Deaths] = 0;
    PlayerInfo[playerid][Kills] = 0;
    PlayerInfo[playerid][Jailed] = 0;
    PlayerInfo[playerid][Frozen] = 0;
    PlayerInfo[playerid][Level] = 0;
    PlayerInfo[playerid][LoggedIn] = 0;
    PlayerInfo[playerid][Registered] = 0;
    PlayerInfo[playerid][God] = 0;
    PlayerInfo[playerid][GodCar] = 0;
    PlayerInfo[playerid][TimesSpawned] = 0;
    PlayerInfo[playerid][Muted] = 0;
    PlayerInfo[playerid][MuteWarnings] = 0;
    PlayerInfo[playerid][Warnings] = 0;
    PlayerInfo[playerid][Caps] = 0;
    PlayerInfo[playerid][DoorsLocked] = 0;
    PlayerInfo[playerid][pCar] = -1;
    for(new i; i<PING_MAX_EXCEEDS; i++) PlayerInfo[playerid][pPing][i] = 0;
    PlayerInfo[playerid][SpamCount] = 0;
    PlayerInfo[playerid][SpamTime] = 0;
    PlayerInfo[playerid][PingCount] = 0;
    PlayerInfo[playerid][PingTime] = 0;
    PlayerInfo[playerid][FailLogin] = 0;
    PlayerInfo[playerid][ConnectTime] = gettime();
    //------------------------------------------------------
    new PlayerName[MAX_PLAYER_NAME], string[128], str[128], file[256];
    GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
    new tmp3[50]; GetPlayerIp(playerid,tmp3,50);
    //-----------------------------------------------------
    if(ServerInfo[ConnectMessages] == 1)
    {
        new pAKA[256]; pAKA = dini_Get("ladmin/config/aka.txt",tmp3);
        if (strlen(pAKA) < 3) format(str,sizeof(str),"*** %s (%d) has joined the server", PlayerName, playerid);
        else if (!strcmp(pAKA,PlayerName,true)) format(str,sizeof(str),"*** %s (%d) has joined the server", PlayerName, playerid);
        else format(str,sizeof(str),"*** %s (%d) has joined the server (aka %s)", PlayerName, playerid, pAKA );

        for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i) && playerid != i)
        {
            if(PlayerInfo[i][Level] > 2) SendClientMessage(i,grey,str);
            else {
                format(string,sizeof(string),"*** %s (%d) has joined the server", PlayerName, playerid);
                SendClientMessage(i,grey,string);
            }
        }
    }
   
//-----------------------------------------------------

if(ServerInfo[MustLogin] == 1 && PlayerInfo[playerid][Registered] == 1 && PlayerInfo[playerid][LoggedIn] == 0)
{
    #if USE_DIALOGS == true
    new lstring[256];
    format(lstring,256,"{FFFFFF}Welcome back {80FF00}%s{FFFFFF}, please log in to your account to continue!",pName(playerid));
    ShowPlayerDialog(playerid,DIALOGID0+2,DIALOG_STYLE_INPUT,"Please Login",lstring,"Login","Kick");
    #endif
    return 1;
}

if(ServerInfo[MustRegister] == 1 && PlayerInfo[playerid][Registered] == 0)
{
    new lstring[256];
    format(lstring,256,"{FFFFFF}The account {80FF00}%s{FFFFFF} was not found on our server\n\n please register a new account!",pName(playerid));
    ShowPlayerDialog(playerid,DIALOGID0+1,DIALOG_STYLE_INPUT,"Register Account",lstring,"Register","Kick");
    return 1;
}
    //-----------------------------------------------------
    if (dUserINT(PlayerName2(playerid)).("banned") == 1)
    {
        SendClientMessage(playerid, red, "This name is banned from this server!");
        format(string,sizeof(string),"%s ID:%d was auto kicked. Reason: Name banned from server",PlayerName,playerid);
        SendClientMessageToAll(grey, string);  print(string);
        SaveToFile("KickLog",string);  Kick(playerid);
    }
    //-----------------------------------------------------
    if(ServerInfo[NameKick] == 1) {
        for(new s = 0; s < BadNameCount; s++) {
            if(!strcmp(BadNames[s],PlayerName,true)) {
                SendClientMessage(playerid,red, "Your name is on our black list, you have been kicked.");
                format(string,sizeof(string),"%s ID:%d was auto kicked. (Reason: Forbidden name)",PlayerName,playerid);
                SendClientMessageToAll(grey, string);  print(string);
                SaveToFile("KickLog",string);  Kick(playerid);
                return 1;
            }
        }
    }
    //-----------------------------------------------------
    if(ServerInfo[PartNameKick] == 1) {
        for(new s = 0; s < BadPartNameCount; s++) {
            new pos;
            while((pos = strfind(PlayerName,BadPartNames[s],true)) != -1) for(new i = pos, j = pos + strlen(BadPartNames[s]); i < j; i++)
            {
                SendClientMessage(playerid,red, "Your name is not allowed on this server, you have been kicked.");
                format(string,sizeof(string),"%s ID:%d was auto kicked. (Reason: Forbidden name)",PlayerName,playerid);
                SendClientMessageToAll(grey, string);  print(string);
                SaveToFile("KickLog",string);  Kick(playerid);
                return 1;
            }
        }
    }
    //-----------------------------------------------------
    if(ServerInfo[Locked] == 1) {
        PlayerInfo[playerid][AllowedIn] = false;
        SendClientMessage(playerid,red,"Server is Locked!  You have 20 seconds to enter the server password before you are kicked!");
        SendClientMessage(playerid,red," Type /password [password]");
        LockKickTimer[playerid] = SetTimerEx("AutoKick", 20000, 0, "i", playerid);
    }
    //-----------------------------------------------------
    if(strlen(dini_Get("ladmin/config/aka.txt", tmp3)) == 0) dini_Set("ladmin/config/aka.txt", tmp3, PlayerName);
    else
    {
        if( strfind( dini_Get("ladmin/config/aka.txt", tmp3), PlayerName, true) == -1 )
        {
            format(string,sizeof(string),"%s,%s", dini_Get("ladmin/config/aka.txt",tmp3), PlayerName);
            dini_Set("ladmin/config/aka.txt", tmp3, string);
        }
    }
    //-----------------------------------------------------
    if(!udb_Exists(PlayerName2(playerid))) SendClientMessage(playerid,orange, "ACCOUNT: Type /register [password] to create an account");
    else
    {
        PlayerInfo[playerid][Registered] = 1;
        format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName));
        new tmp2[256]; tmp2 = dini_Get(file,"ip");
        if( (!strcmp(tmp3,tmp2,true)) && (ServerInfo[AutoLogin] == 1) )
        {
            LoginPlayer(playerid);
            if(PlayerInfo[playerid][Level] > 0)
            {
                format(string,sizeof(string),"ACCOUNT: You have been automatically logged in. (Level %d)", PlayerInfo[playerid][Level] );
                SendClientMessage(playerid,green,string);
            }
            else SendClientMessage(playerid,green,"ACCOUNT: You have been automatically logged in.");
        }
        else SendClientMessage(playerid, green, "ACCOUNT: This nickname is registed,  you can now login by typing /login [password]");
    }
    return 1;
}

//==============================================================================

forward AutoKick(playerid);
public AutoKick(playerid)
{
    if( IsPlayerConnected(playerid) && ServerInfo[Locked] == 1 && PlayerInfo[playerid][AllowedIn] == false) {
        new string[128];
        SendClientMessage(playerid,grey,"You have been automatically kicked. Reason: Server Locked");
        format(string,sizeof(string),"%s ID:%d has been automatically kicked. Reason: Server Locked",PlayerName2(playerid),playerid);
        SaveToFile("KickLog",string);  Kick(playerid);
        SendClientMessageToAll(grey, string); print(string);
    }
    return 1;
}
pawn Код:
//Login Dialog

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
 {
 new string[256];
 //////////////
 if(dialogid == DIALOGID0+1)
 {
    if(response)
    {
        if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"ACCOUNT: You are already registered and logged in.");
        if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,red,"ACCOUNT: This account already exists, please use '/login [password]'.");
        if (strlen(inputtext) < 4 || strlen(inputtext) > 20) return SendClientMessage(playerid,red,"ACCOUNT: Password length must be greater than three characters");
        if (udb_Create(PlayerName2(playerid),inputtext))
        {
         new file[256],rname[MAX_PLAYER_NAME], tmp3[100];
         new strdate[20], year,month,day;
         getdate(year, month, day);
         GetPlayerName(playerid,rname,sizeof(rname));
         format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(rname));
         GetPlayerIp(playerid,tmp3,100);
         dini_Set(file,"ip",tmp3);
         // dini_Set(file,"password",params);
         dUserSetINT(PlayerName2(playerid)).("registered",1 );
         format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
         dini_Set(file,"RegisteredDate",strdate);
         dUserSetINT(PlayerName2(playerid)).("loggedin",1);
         dUserSetINT(PlayerName2(playerid)).("banned",0);
         dUserSetINT(PlayerName2(playerid)).("level",0);
         dUserSetINT(PlayerName2(playerid)).("LastOn",0);
         dUserSetINT(PlayerName2(playerid)).("money",0);
         dUserSetINT(PlayerName2(playerid)).("kills",0);
         dUserSetINT(PlayerName2(playerid)).("deaths",0);
         PlayerInfo[playerid][LoggedIn] = 1;
         PlayerInfo[playerid][Registered] = 1;
         SendClientMessage(playerid, green, "ACCOUNT: You are now registered, and have been automaticaly logged in");
         PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
         return 1;
        }
    if(!response) return Kick(playerid);
}
return 1;
}
if(dialogid == DIALOGID0+2)
{
    if(response)
    {
        if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"ACCOUNT: You are already logged in.");
        if (!udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,red,"ACCOUNT: Account doesn't exist, please use '/register [password]'.");
        if (udb_CheckLogin(PlayerName2(playerid),inputtext))
        {
            new file[256], tmp3[100], lname[MAX_PLAYER_NAME];
            GetPlayerName(playerid,lname,sizeof(lname));
            format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(lname));
             GetPlayerIp(playerid,tmp3,100);
             dini_Set(file,"ip",tmp3);
             LoginPlayer(playerid);
             PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
             if(PlayerInfo[playerid][Level] > 0) {
             format(string,sizeof(string),"ACCOUNT: Successfully Logged In. (Level %d)", PlayerInfo[playerid][Level] );
             return SendClientMessage(playerid,green,string);
        } else return SendClientMessage(playerid,green,"ACCOUNT: Successfully Logged In");
}
    return ShowPlayerDialog(playerid, DIALOGID0+2, DIALOG_STYLE_INPUT,"Password", "WRONG Password, Try Again", "OK", "Cancel");
}
    if(!response) return Kick(playerid);
}
     return 1;
}
Still not working, also, I am registered, and its saying im not.
Reply
#6

Well?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)