06.07.2014, 14:28
I want to save the IDs 0-5 to admins
so someone can mabye give me a stock to SetPlayerID?
so someone can mabye give me a stock to SetPlayerID?
/*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;
}