public PlVers:__version =
{
version = 5,
filevers = "1.4.7",
date = "04/05/2013",
time = "05:00:25"
};
new Float:NULL_VECTOR[3];
new String:NULL_STRING[4];
public Extension:__ext_core =
{
name = "Core",
file = "core",
autoload = 0,
required = 0,
};
new MaxClients;
new String:g_sListPath[256];
new Handle:g_hTrie;
public Plugin:myinfo =
{
name = "Reset Score",
description = "Type !rs / !rdk / restartscore / !resetscore to reset your score.",
author = "GoDtm666",
version = "1.0.0",
url = "www.MyArena.ru"
};
public __ext_core_SetNTVOptional()
{
MarkNativeAsOptional("GetFeatureStatus");
MarkNativeAsOptional("RequireFeature");
MarkNativeAsOptional("AddCommandListener");
MarkNativeAsOptional("RemoveCommandListener");
VerifyCoreVersion();
return 0;
}
Handle:StartMessageOne(String:msgname[], client, flags)
{
new players[1];
players[0] = client;
return StartMessage(msgname, players, 1, flags);
}
public OnPluginStart()
{
g_hTrie = CreateTrie();
BuildPath(PathType:0, g_sListPath, 256, "configs/resetscore.ini");
RegConsoleCmd("say", Cmd_SayChat, "", 0);
RegConsoleCmd("say_team", Cmd_SayChat, "", 0);
RegAdminCmd("sm_resetscore_triger_add", Cmd_TriggerAdd, 4096, "Добавить новый триггер.", "", 0);
RegAdminCmd("sm_resetscore_triger_add_file", Cmd_TriggerAddFile, 4096, "Добавить новый триггер и сохранить в файл.", "", 0);
LoadTranslations("resetscore.phrases");
return 0;
}
public Action:Cmd_SayChat(client, args)
{
new var1;
if (client && IsClientInGame(client))
{
decl String:sBuffer[128];
decl iBuffer;
GetCmdArgString(sBuffer, 128);
StripQuotes(sBuffer);
if (GetTrieValue(g_hTrie, sBuffer, iBuffer))
{
new var2;
if (!GetClientFrags(client) && !GetClientDeaths(client))
{
PrintToChat(client, "\x01\x04[RS]\x01 %t", "PrintResetAlready");
}
SetEntProp(client, PropType:1, "m_iFrags", any:0, 4, 0);
SetEntProp(client, PropType:1, "m_iDeaths", any:0, 4, 0);
PrintToChat(client, "\x01\x04[RS]\x01 %t", "PrintReset");
if (GetClientName(client, sBuffer, 128))
{
decl Handle:hBuffer;
Format(sBuffer, 128, "\x01\x04[RS]\x01 %t", "PrintResetAll", "\x03", sBuffer, "\x01");
iBuffer = 1;
while (iBuffer <= MaxClients)
{
new var3;
if (iBuffer != client && IsClientInGame(iBuffer))
{
hBuffer = StartMessageOne("SayText2", iBuffer, 132);
BfWriteByte(hBuffer, client);
BfWriteByte(hBuffer, 1);
BfWriteString(hBuffer, sBuffer);
EndMessage();
}
iBuffer++;
}
}
}
}
return Action:0;
}
public Action:Cmd_TriggerAdd(client, args)
{
if (args)
{
decl String:sBuffer[64];
GetCmdArgString(sBuffer, 64);
StripQuotes(sBuffer);
if (SetTrieValue(g_hTrie, sBuffer, any:1, true))
{
ReplyToCommand(client, "\x01\x04[RS]\x01 %t", "PrintAddTrigger", sBuffer);
}
}
return Action:3;
}
public Action:Cmd_TriggerAddFile(client, args)
{
if (args)
{
decl String:sBuffer[64];
decl Handle:hFile;
GetCmdArgString(sBuffer, 64);
StripQuotes(sBuffer);
hFile = OpenFile(g_sListPath, "at");
if (hFile)
{
if (SetTrieValue(g_hTrie, sBuffer, any:1, true))
{
WriteFileLine(hFile, sBuffer);
ReplyToCommand(client, "\x01\x04[RS]\x01 %t", "PrintAddTrigger", sBuffer);
}
CloseHandle(hFile);
}
}
return Action:3;
}
public OnClientPutInServer(client)
{
CreateTimer(20.0, TimerAnnounce, GetClientUserId(client), 0);
return 0;
}
public Action:TimerAnnounce(Handle:timer, any:userid)
{
new client = GetClientOfUserId(userid);
new var1;
if (client && IsClientConnected(client) && IsClientInGame(client))
{
PrintToChat(client, "\x01\x04[RS]\x01 %t", "PrintAnnounce");
}
return Action:4;
}
public OnMapStart()
{
new Handle:hFile = OpenFile(g_sListPath, "r");
ClearTrie(g_hTrie);
if (hFile)
{
new String:sBuffer[256];
new iPos;
while (!IsEndOfFile(hFile))
{
if (ReadFileLine(hFile, sBuffer, 256))
{
iPos = StrContains(sBuffer, "//", true);
if (iPos != -1)
{
sBuffer[iPos] = MissingTAG:0;
}
iPos = StrContains(sBuffer, "#", true);
if (iPos != -1)
{
sBuffer[iPos] = MissingTAG:0;
}
iPos = StrContains(sBuffer, ";", true);
if (iPos != -1)
{
sBuffer[iPos] = MissingTAG:0;
}
TrimString(sBuffer);
if (sBuffer[0])
{
SetTrieValue(g_hTrie, sBuffer, any:1, true);
}
}
}
CloseHandle(hFile);
}
if (!GetTrieSize(g_hTrie))
{
SetTrieValue(g_hTrie, "!rs", any:1, true);
SetTrieValue(g_hTrie, "!resetscore", any:1, true);
SetTrieValue(g_hTrie, "!restartscore", any:1, true);
SetTrieValue(g_hTrie, "!rdk", any:1, true);
SetTrieValue(g_hTrie, "!кы", any:1, true);
SetTrieValue(g_hTrie, "!рс", any:1, true);
SetTrieValue(g_hTrie, "!рдк", any:1, true);
SetTrieValue(g_hTrie, "!квл", any:1, true);
SetTrieValue(g_hTrie, "!Кы", any:1, true);
SetTrieValue(g_hTrie, "!Рс", any:1, true);
SetTrieValue(g_hTrie, "!Рдк", any:1, true);
SetTrieValue(g_hTrie, "!Квл", any:1, true);
}
return 0;
}