Can make the function SetPlayerID?
#1

I want to save the IDs 0-5 to admins

so someone can mabye give me a stock to SetPlayerID?
Reply
#2

It is not possible in this version of sa-mp .
Reply
#3

Not possible, you can kick players who join with ID 0-5 but you would have no players unless 6 admins are always online.
Reply
#4

Quote:
Originally Posted by Cena44
Посмотреть сообщение
Not possible, you can kick players who join with ID 0-5 but you would have no players unless 6 admins are always online.
Yeah I thought about it.
But I need 6 People always online.
I hope they will add it in the next versions
Reply
#5

You should save Admin priveledges to player names and not player IDs, as quite obviously anyone could have these IDs and the name (If you have a register/login system) would be unique.

Best regards,
Jesse
Reply
#6

Maybe something similiar could be possible with something like this.. I coded this without testing, really quickly.. MIght work though from the jump maybe or with a little editing..

pawn Код:
/*Basically, this will connect NPC's to the server, to take up the slots.

When a player disconnects, and he was in a reserved slot, an NPC will take place again of his slot.

If you type /reserve, it will prevent anyone from connecting until the player reconnects and takes his reserved slot.
Or after "RESERVE_TIME" is over (Default: 2 mins after using /reserve*/


new bool:SettingAdminSlots=false; //Is a player slot being reserved?

#define MAX_RSLOTS 6
#define RESERVE_TIME 120000 // 2 mins - no connections until owner takes slot
#define NPCR_SCRIPT "rslotnpc" // Set this to the NPC recording file.. should be an empty one

new RSlots[MAX_RSLOTS][MAX_PLAYER_NAME] = {
    "Erin", //Replace with your own reserved names
    "Samantha",
    "2Pac_Shakur",
    "Mr.Killa",
    "James22",
    "Jedi_master"
};

public OnFilterScriptInit()
{
    SettingAdminSlots = false;
    ConnectSlotNPCS();
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(SettingAdminSlots == true && IsReservedPlayer(playerid)) //The player connected and a slot was being reserved
    {
        SendClientMessageToAll(0x008800, "The slots are now longer being reserved! Slot tooken by owner.");
        SettingAdminSlots = false;
    }
    return 1;
}

public OnPlayerCommandText(playerid, params[])
{
    if(strcmp(params, "/reserve", true))
    {
        if(SettingAdminSlots == false)
        {
            SendClientMessageToAll(0x008800, "The slots are now being reserved! No one can connect!");
            SettingAdminSlots = true;
            SetTimer("ResetAdminReserveSlots", 120000, 0);
            return 1;
        }
        else if(SettingAdminSlots == true)
        {
            SendClientMessageToAll(0x008800, "The slots are now longer being reserved!");
            SettingAdminSlots = false;
            return 1;
        }
    }
    return 1;
}

public OnIncomingConnection(playerid, ip_address[], port)
{
    //If the slot is being reserved until the player connects, prevent non-slot owner from connecting to server
    //and taking up the slot!
    if(SettingAdminSlots == true)
    {
        if(!IsReservedPlayer(playerid) && !IsPlayerNPC(playerid)) BlockIpAddress(ip_address, RESERVE_TIME); //Block connection for two minutes
    }
    return 1;
}

public OnPlayerDisconnect(playerid)
{
    //If the playerid is a reservered slot, we will refill the slot with an NPC
    if(playerid >= 0 && playerid <= 5) ConnectSlotNPCOnly(playerid);
    return 1;
}

ConnectSlotNPCS() //Reserve the first 6 slots using NPC's when the server starts (OnFilterScriptInit)
{
    ConnectNPC("RSLOT0", NPCR_SCRIPT);
    ConnectNPC("RSLOT1", NPCR_SCRIPT);
    ConnectNPC("RSLOT2", NPCR_SCRIPT);
    ConnectNPC("RSLOT3", NPCR_SCRIPT);
    ConnectNPC("RSLOT4", NPCR_SCRIPT);
    ConnectNPC("RSLOT5", NPCR_SCRIPT);
}

ConnectSlotNPCOnly(slot) //This will reserve only one specified slot by connecting an NPC.
{
    new key[10];
    format(key, sizeof(key), "RSLOT%d", slot);
    ConnectNPC(key, NPCR_SCRIPT); //Reserve the slot with an NPC
}

//OnPlayerDisconnect.. if the player is in reserved slot,
forward ResetAdminReserveSlots();
public ResetAdminReserveSlots()
{
    if(SettingAdminSlots == false) return 0;
    SendClientMessageToAll(0x008800, "The slots are now longer being reserved! The slot owner did not connect!");
    SettingAdminSlots = false;
    return 1;
}

IsReservedPlayer(playerid) //Is the player a owner of a reserved slot.
{
    new reservedplayer;
    for(new x=0; x<MAX_RSLOTS; x++)
    {
        if(strfind(pName(playerid), RSlots[x], true) != -1)
        {
            reservedplayer = 1;
            break;
        }
    }
    return reservedplayer;
}
Reply
#7

If you want to keep track of a group of people, you should store their IDs in an iterator/linked list after logging in (use foreach for this) and remove the ID when the player disconnects. Finding group players online, or looping through foreach is much faster than looping through all connected players or comparing strings...
Reply
#8

You can. Connect 5 NPCs. They will take first 5 IDs. Afterwards, you will have to find a way how you can disconnect them just right before admins connect. I can't find solution to the last thing, maybe you will have more luck

EDIT: oh I see, somone already posted this idea with the code. Sorry for not reading
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)