Slot question
#8

pawn Код:
#include <a_samp>

main()
{
    print("\n----------------------------------");
    print("  Bare Script\n");
    print("----------------------------------\n");
}
#define RESERVED_SLOTS 1 //Amount of reserved slots
#define DIALOG_ID 10 //Dialog ID to use for ReservedDialog
#define RESERVED_PASSWORD "yarhar" //Reserver Slots Password, case sensitive
#undef MAX_PLAYERS
#define MAX_PLAYERS 500 //Set this to the amount of slots your server has
new SlotsRemaining;
new ReservedList[RESERVED_SLOTS][MAX_PLAYER_NAME]=
{
    //"Other_Names",
    "Joe_Staff"
};
forward ReservedDialog(playerid,timeremaining,NameMatch);
public ReservedDialog(playerid,timeremaining,NameMatch)
{

    //Compare Name to Reserved List
    new tmp[256];

    if(NameMatch==0)
    {
        GetPlayerName(playerid,tmp,24);
        for(new name;name<RESERVED_SLOTS;name++)if(!strcmp(tmp,ReservedList[name]))NameMatch=1;
    }

    //If timeremaining = 0 then kick
    if(timeremaining<=0)return Kick(playerid);

    //if player's id doesn't reach the reserved slots range, let continue
    if(playerid<=MAX_PLAYERS-SlotsRemaining)
    {
        if(NameMatch)SlotsRemaining--;
        return 0;
    }else{
        if(NameMatch)
        {
            format(tmp,256,"Please type in the server's reserved slot password.\nYou have %02d seconds remaining...");
            ShowPlayerDialog(playerid,DIALOG_ID,DIALOG_STYLE_MSGBOX,"Reserved Slot Password",tmp,"Submit","Cancel");
            SetTimerEx("ReservedDialog",1000,0,"dd",playerid,timeremaining-1,1);
        }else{
            format(tmp,256,"This server has %d reserved slots. You must wait until more slots are available");
            SendClientMessage(playerid,0xFFFFFF00,tmp);
            return Kick(playerid);
        }
    }
    return 0;
}
public OnGameModeInit()
{
    SlotsRemaining=RESERVED_SLOTS;
}
public OnPlayerConnect(playerid)
{
    ReservedDialog(playerid,30,0);
}
public OnPlayerDisconnect(playerid,reason)
{
    new tmp[24];
    GetPlayerName(playerid,tmp,24);
    for(new name;name<RESERVED_SLOTS;name++)if(!strcmp(tmp,ReservedList[name]))SlotsRemaining++;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid!=DIALOG_ID)return 1;
    if(!response)return Kick(playerid);
    if(strcmp(inputtext,RESERVED_PASSWORD))
    {
        SendClientMessage(playerid,0xFFFFFF00,"Incorrect Password. Please wait until more slots are available");
        Kick(playerid);
        return 0;
    }
    SlotsRemaining--;
    return 0;
}
Not tested, just something I built in the browser window.

To be honest I'm not sure if ShowPlayerDialog can even be called in OnPlayerConnect...




Edit: I think I'm going to put "Official Thread Killer" at the end of my posts from now on.
Reply


Messages In This Thread
Slot question - by SloStunter - 24.01.2012, 15:41
Re: Slot question - by TheTale - 24.01.2012, 15:43
Re: Slot question - by Dripac - 24.01.2012, 16:09
Re: Slot question - by [MM]IKKE - 24.01.2012, 16:35
Re: Slot question - by Guest9328472398472 - 24.01.2012, 21:32
Re: Slot question - by Lorenc_ - 24.01.2012, 21:38
Re: Slot question - by Gh05t_ - 24.01.2012, 21:46
Re: Slot question - by Joe Staff - 25.01.2012, 04:19
Re: Slot question - by SloStunter - 25.01.2012, 13:18
Re: Slot question - by Universal - 25.01.2012, 16:01

Forum Jump:


Users browsing this thread: 1 Guest(s)