Make only specific players can join
#1

Hey, my server is currently on beta version and i want to allow players with nicknames that i already write inside a file or sql.
any example how can I do it?

so for example I create a file or sql table called 'betatesters' and if a players connect and their nicknames aren't in the list they can't join.

thanks.
Reply
#2

You can use this:
Код:
stock pName(playerid)
{
    new n[25];
    GetPlayerName(playerid,n,sizeof(n));
    return n;
}

public OnPlayerConnect(playerid)
{
    if(strcmp(pName(playerid),"Nick1") || 
    strcmp(pName(playerid),"Nick2")    ||
    strcmp(pName(playerid),"Nick3")     )
    {
        Kick(playerid);
    }
    return 1;
}
Or make a whitelist using news.
Reply
#3

Thanks,but I don't want to reupload my gamemode just to add 1 beta tester.
I want to make it more dynamic,so I only add 1 line in sql or ini file.
anyone?
Reply
#4

You can make it with files.

Код:
stock pName(playerid)
{
    new n[25];
    GetPlayerName(playerid,n,sizeof(n));
    return n;
}

CMD:whiteadd(playerid,params[])
{
    new player,string[50];
    if(sscanf(params,"u",player)) return SendClientMessage(playerid,-1,"Usage: /whiteadd [PlayerNick/PlayerID]");
    if(!IsPlayerConnected(player) || player == INVALID_PLAYER_ID) return SendClientMessage(playerid,-1,"Player is not connected);
    format(string,50,"Whitelist/%s.ini",pName(player));
    new File:LogFile = fopen(string,io_read);
    fclose(LogFile);
    return 1;
}

public OnPlayerConnect(playerid)
{
    new string[50];
    format(string,50,"Whitelist/%s.ini",pName(player));
    if(!fexist(string))
    {
        Kick(playerid);
    }
    else
    {}
    return 1;
}
This should work.
Reply
#5

/whiteadd doesn't work,it don't add file
Reply
#6

You can edit that code of course. I made it within 3 minutes so I didn't look for mistakes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)