No login in time = Kick (Help +Rep)
#1

pawn Код:
forward AKICK(playerid);
public AKICK(playerid)
{
    GameTextForPlayer(playerid, "You have ~g~10~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK9", 1000, false, "i", playerid);

    if(PlayerInfo[playerid][LoggedIn] == 1)
    {
        new string[128];
        format(string,sizeof(string),"ACCOUNT: Successfully Logged In. (Level %d)", PlayerInfo[playerid][Level] );
        return SendClientMessage(playerid,green,string);
        KillTimer(playerid);
    }
    return 1;
}
forward AKICK9(playerid);
public AKICK9(playerid)
{

    GameTextForPlayer(playerid, "You have ~g~9~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK8", 1000, false, "i", playerid);

}
forward AKICK8(playerid);
public AKICK8(playerid)
{

    GameTextForPlayer(playerid, "You have ~g~8~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK7", 1000, false, "i", playerid);

}
forward AKICK7(playerid);
public AKICK7(playerid)
{

    GameTextForPlayer(playerid, "You have ~y~7~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK6", 1000, false, "i", playerid);

}
forward AKICK6(playerid);
public AKICK6(playerid)
{

    GameTextForPlayer(playerid, "You have ~y~6~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK5", 1000, false, "i", playerid);

}
forward AKICK5(playerid);
public AKICK5(playerid)
{

    GameTextForPlayer(playerid, "You have ~b~5~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK4", 1000, false, "i", playerid);

}
forward AKICK4(playerid);
public AKICK4(playerid)
{

    GameTextForPlayer(playerid, "You have ~b~4~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK3", 1000, false, "i", playerid);

}
forward AKICK3(playerid);
public AKICK3(playerid)
{

    GameTextForPlayer(playerid, "You have ~r~3~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK2", 1000, false, "i", playerid);

}
forward AKICK2(playerid);
public AKICK2(playerid)
{

    GameTextForPlayer(playerid, "You have ~r~2~w~ seconds to login!", 5000, 6);
    SetTimerEx("AKICK1", 1000, false, "i", playerid);

}
forward AKICK1(playerid);
public AKICK1(playerid)
{

    GameTextForPlayer(playerid, "You have ~r~1~w~ seconds to login!", 5000, 6);
    Kick(playerid);

}

Login CMD:

pawn Код:
CMD:login(playerid,params[])
{
    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 (strlen(params)==0) return SendClientMessage(playerid,red,"ACCOUNT: Correct usage: '/login [password]'");
    if (udb_CheckLogin(PlayerName2(playerid),params))
    {
        new file[256], tmp3[100], string[128];
        format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName2(playerid)) );
        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)
        {
            SetTimerEx("AKICK", 5000, false, "i", playerid);
            return 1;


        } else return SendClientMessage(playerid,green,"ACCOUNT: Successfully Logged In");
    }
    else {
        PlayerInfo[playerid][FailLogin]++;
        printf("LOGIN: %s has failed to login, Wrong password (%s) Attempt (%d)", PlayerName2(playerid), params, PlayerInfo[playerid][FailLogin] );
        if(PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
        {
            new string[128]; format(string, sizeof(string), "%s has been kicked (Failed Logins)", PlayerName2(playerid) );
           
            SendClientMessageToAll(grey, string);
            print(string);
            Kick(playerid);
        }
        return SendClientMessage(playerid,red,"ACCOUNT: Login failed! Incorrect Password");
    }
}
If player logins KillTimer? How Please help
Reply
#2

To kill each of those timers, I believe you would have to direct the timer to one or all of the timers you have made, Example:

pawn Код:
KillTimer(AKICK9);
Reply
#3

pawn Код:
new loginTime[MAX_PLAYERS];

forward OneSecond();
public OneSecond()
{
    new string[124];
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            loginTime[i] --;
            if(loginTime[i] == 0 && PlayerInfo[playerid][LoggedIn] == 0)
            {
                format(string,sizeof(string),"You have ~r~%d ~w~seconds to log in.",loginTime[i]);
                GameTextForPlayer(i,string,4000,4);
            }
        }
    }
    return 1;
}

public OnGameModeInit()
{
    SetTimer("OneSecond",1000,1);
    return 1;
}
Reply
#4

you can add that
Quote:

KillTimer(AKICK9);

and add the timer in onplayerconnect :S
Reply
#5

Код HTML:
[C:\Users\Alex\Documents\Samp Server\gamemodes\2.pwn(18340) : error 076: syntax error in the expression, or invalid function call]
KillTimer(AKICK9);
Reply
#6

Dude.... You gotta be kidding me. 10 timers? Oo'

You should use Tyler's code. it's better than yours
Reply
#7

It wont work.
Reply
#8

Tylers code won't work correctly it needs to be fixed...

Derp.....

pawn Код:
loginTime[i] --;
if(loginTime[i] == 0 && PlayerInfo[playerid][LoggedIn] == 0)
Do it the man way....

pawn Код:
#define IsLoggedIn(%0) PlayerInfo[%0][LoggedIn]

if(!IsLoggedIn(i))
{
    loginTime[i] --;
    if(loginTime[i] > 0)
    {
        // Count down code here
    }
    else
    {
        // Kick code here
    }
}
Reply
#9

pawn Код:
C:\Users\Alex\Documents\Samp Server\gamemodes\2.pwn(18617) : error 010: invalid function or declaration
C:\Users\Alex\Documents\Samp Server\gamemodes\2.pwn(18620) : error 010: invalid function or declaration
C:\Users\Alex\Documents\Samp Server\gamemodes\2.pwn(18624) : error 010: invalid function or declaration
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


3 Errors.
pawn Код:
if(!IsLoggedIn(i))
{
    loginTime[i] --;
    if(loginTime[i] > 0)
    {
        SendClientMessage(playerid,red,"ACCOUNT: Test1'");
    }
    else
    {
        SendClientMessage(playerid,red,"ACCOUNT: Test2'");
    }
}
Reply
#10

Any one?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)