13.07.2012, 23:32
(
Последний раз редактировалось Lorkm; 14.07.2012 в 00:14.
)
їComo puedo hacer que cuando un NPC crashee acceda inmediatamente?
їPor que crashean los npcs?
їPor que crashean los npcs?
if(IsPlayerNPC(playerid)) return 1;
public OnGameModeInit()
{
ConnectNPC("BotName", "BotFile");
SetTimer("Server", 1000, 1);
return 1;
}
forward Server();
public Server()
{
new i = GetPlayerIDFromName("BotName");
if(!IsPlayerConnected(i)) ConnectNPC("BotName", "BotFile");
}
stock GetPlayerIDFromName(const playername[], partofname=0)
{
new i;
new playername1[64];
for (i=0;i<MAX_PLAYERS;i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i,playername1,sizeof(playername1));
if (strcmp(playername1,playername,true)==0)
{
return i;
}
}
}
new correctsigns_userid=-1;
new tmpuname[128];
new hasmultiple=-1;
if(partofname)
{
for (i=0;i<MAX_PLAYERS;i++)
{
if (IsPlayerConnected(i))
{
GetPlayerName(i,tmpuname,sizeof(tmpuname));
if(!strfind(tmpuname,playername1[partofname],true, 0))
{
hasmultiple++;
correctsigns_userid=i;
}
if (hasmultiple>0)
{
return -2;
}
}
}
}
return correctsigns_userid;
}
public OnPlayerDisconnect(playerid, reason)
{
if( !reason && IsPlayerNPC(playerid) )
{
ConnectNPC("Bot", "recScript");
}
return 1;
}