public PlVers:__version =
{
version = 5,
filevers = "1.6.0-dev+4335",
date = "08/31/2014",
time = "09:49:33"
};
new Float:NULL_VECTOR[3];
new String:NULL_STRING[4];
public Extension:__ext_core =
{
name = "Core",
file = "core",
autoload = 0,
required = 0,
};
new MaxClients;
public Extension:__ext_sdktools =
{
name = "SDKTools",
file = "sdktools.ext",
autoload = 1,
required = 1,
};
public Extension:__ext_cprefs =
{
name = "Client Preferences",
file = "clientprefs.ext",
autoload = 1,
required = 1,
};
public Extension:__ext_sdkhooks =
{
name = "SDKHooks",
file = "sdkhooks.ext",
autoload = 1,
required = 1,
};
new bool:viktorina_available_or_not;
new skoko_voprosov_v_konfige;
new TeamCount;
new bool:two_winners;
new bool:first_winner;
new String:first[256];
new Handle:Timer_Molotov;
new Handle:g_timers[66];
new Handle:g_timers_b[66];
new bool:winner[66];
new String:right_answer[256];
new dp;
public Plugin:myinfo =
{
name = "dp",
description = "dp for answers",
author = "Mr Qwerty",
version = "1.2.0",
url = "xyu.ru"
};
public __ext_core_SetNTVOptional()
{
MarkNativeAsOptional("GetFeatureStatus");
MarkNativeAsOptional("RequireFeature");
MarkNativeAsOptional("AddCommandListener");
MarkNativeAsOptional("RemoveCommandListener");
MarkNativeAsOptional("BfWriteBool");
MarkNativeAsOptional("BfWriteByte");
MarkNativeAsOptional("BfWriteChar");
MarkNativeAsOptional("BfWriteShort");
MarkNativeAsOptional("BfWriteWord");
MarkNativeAsOptional("BfWriteNum");
MarkNativeAsOptional("BfWriteFloat");
MarkNativeAsOptional("BfWriteString");
MarkNativeAsOptional("BfWriteEntity");
MarkNativeAsOptional("BfWriteAngle");
MarkNativeAsOptional("BfWriteCoord");
MarkNativeAsOptional("BfWriteVecCoord");
MarkNativeAsOptional("BfWriteVecNormal");
MarkNativeAsOptional("BfWriteAngles");
MarkNativeAsOptional("BfReadBool");
MarkNativeAsOptional("BfReadByte");
MarkNativeAsOptional("BfReadChar");
MarkNativeAsOptional("BfReadShort");
MarkNativeAsOptional("BfReadWord");
MarkNativeAsOptional("BfReadNum");
MarkNativeAsOptional("BfReadFloat");
MarkNativeAsOptional("BfReadString");
MarkNativeAsOptional("BfReadEntity");
MarkNativeAsOptional("BfReadAngle");
MarkNativeAsOptional("BfReadCoord");
MarkNativeAsOptional("BfReadVecCoord");
MarkNativeAsOptional("BfReadVecNormal");
MarkNativeAsOptional("BfReadAngles");
MarkNativeAsOptional("BfGetNumBytesLeft");
MarkNativeAsOptional("PbReadInt");
MarkNativeAsOptional("PbReadFloat");
MarkNativeAsOptional("PbReadBool");
MarkNativeAsOptional("PbReadString");
MarkNativeAsOptional("PbReadColor");
MarkNativeAsOptional("PbReadAngle");
MarkNativeAsOptional("PbReadVector");
MarkNativeAsOptional("PbReadVector2D");
MarkNativeAsOptional("PbGetRepeatedFieldCount");
MarkNativeAsOptional("PbSetInt");
MarkNativeAsOptional("PbSetFloat");
MarkNativeAsOptional("PbSetBool");
MarkNativeAsOptional("PbSetString");
MarkNativeAsOptional("PbSetColor");
MarkNativeAsOptional("PbSetAngle");
MarkNativeAsOptional("PbSetVector");
MarkNativeAsOptional("PbSetVector2D");
MarkNativeAsOptional("PbAddInt");
MarkNativeAsOptional("PbAddFloat");
MarkNativeAsOptional("PbAddBool");
MarkNativeAsOptional("PbAddString");
MarkNativeAsOptional("PbAddColor");
MarkNativeAsOptional("PbAddAngle");
MarkNativeAsOptional("PbAddVector");
MarkNativeAsOptional("PbAddVector2D");
MarkNativeAsOptional("PbRemoveRepeatedFieldValue");
MarkNativeAsOptional("PbReadMessage");
MarkNativeAsOptional("PbReadRepeatedMessage");
MarkNativeAsOptional("PbAddMessage");
VerifyCoreVersion();
return 0;
}
Float:operator+(Float:,_:)(Float:oper1, oper2)
{
return oper1 + float(oper2);
}
PrintToChatAll(String:format[])
{
decl String:buffer[192];
new i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i))
{
SetGlobalTransTarget(i);
VFormat(buffer, 192, format, 2);
PrintToChat(i, "%s", buffer);
}
i++;
}
return 0;
}
PrintHintTextToAll(String:format[])
{
decl String:buffer[192];
new i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i))
{
SetGlobalTransTarget(i);
VFormat(buffer, 192, format, 2);
PrintHintText(i, "%s", buffer);
}
i++;
}
return 0;
}
EmitSoundToAll(String:sample[], entity, channel, level, flags, Float:volume, pitch, speakerentity, Float:origin[3], Float:dir[3], bool:updatePos, Float:soundtime)
{
new clients[MaxClients];
new total;
new i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i))
{
total++;
clients[total] = i;
}
i++;
}
if (!total)
{
return 0;
}
EmitSound(clients, total, sample, entity, channel, level, flags, volume, pitch, speakerentity, origin, dir, updatePos, soundtime);
return 0;
}
AddFileToDownloadsTable(String:filename[])
{
static table = -1;
if (table == -1)
{
table = FindStringTable("downloadables");
}
new bool:save = LockStringTables(false);
AddToStringTable(table, filename, "", -1);
LockStringTables(save);
return 0;
}
TE_SendToAll(Float:delay)
{
new total;
new clients[MaxClients];
new i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i))
{
total++;
clients[total] = i;
}
i++;
}
return TE_Send(clients, total, delay);
}
TE_SetupSparks(Float:pos[3], Float:dir[3], Magnitude, TrailLength)
{
TE_Start("Sparks");
TE_WriteVector("m_vecOrigin[0]", pos);
TE_WriteVector("m_vecDir", dir);
TE_WriteNum("m_nMagnitude", Magnitude);
TE_WriteNum("m_nTrailLength", TrailLength);
return 0;
}
TE_SetupEnergySplash(Float:pos[3], Float:dir[3], bool:Explosive)
{
TE_Start("Energy Splash");
TE_WriteVector("m_vecPos", pos);
TE_WriteVector("m_vecDir", dir);
TE_WriteNum("m_bExplosive", Explosive);
return 0;
}
public OnPluginStart()
{
HookEvent("round_start", roundStart, EventHookMode:1);
HookEvent("player_spawn", PlayerSpawn, EventHookMode:1);
HookEvent("player_death", _PD, EventHookMode:1);
AddCommandListener(HookPlayerChat, "say");
AddCommandListener(HookPlayerChat, "say_team");
return 0;
}
public OnMapStart()
{
PrecacheSound("dreamers/musicsrv/aplodismenty_short.mp3", true);
AddFileToDownloadsTable("sound/dreamers/musicsrv/aplodismenty_short.mp3");
new Handle:KvColors = CreateKeyValues("viktorina", "", "");
new String:ConfigFile[256];
BuildPath(PathType:0, ConfigFile, 256, "configs/viktorina.cfg");
if (!FileToKeyValues(KvColors, ConfigFile))
{
CloseHandle(KvColors);
LogError("[ERROR] Question_anwer can not convert file to keyvalues: %s", ConfigFile);
return 0;
}
skoko_voprosov_v_konfige = 0;
KvRewind(KvColors);
new bool:sectionExists = KvGotoFirstSubKey(KvColors, true);
if (!sectionExists)
{
CloseHandle(KvColors);
LogError("[ERROR] Question_anwer can not find first keyvalues subkey in file: %s", ConfigFile);
return 0;
}
while (sectionExists)
{
if (KvGetNum(KvColors, "enabled", 0))
{
skoko_voprosov_v_konfige = skoko_voprosov_v_konfige + 1;
}
sectionExists = KvGotoNextKey(KvColors, true);
}
CloseHandle(KvColors);
return 0;
}
public Action:roundStart(Handle:event, String:name[], bool:dontBroadcast)
{
TeamCount = GetTeamClientCount(2) + GetTeamClientCount(3);
if (TeamCount > 20)
{
two_winners = true;
first_winner = false;
}
else
{
two_winners = false;
first_winner = true;
}
CreateTimer(1.0, qwerty2, any:2, 0);
CreateTimer(0.5, clear_winners, any:2, 0);
ClearTimer(Timer_Molotov);
return Action:0;
}
public Action:PlayerSpawn(Handle:event, String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (winner[client] == true)
{
CreateTimer(2.0, luckyman_newspawn, client, 2);
}
return Action:0;
}
public Action:luckyman_newspawn(Handle:timer, any:client)
{
if (winner[client] == true)
{
if (!g_timers_b[client])
{
g_timers_b[client] = CreateTimer(0.2, Timer_EnergySplash, client, 1);
}
}
return Action:0;
}
public Action:clear_winners(Handle:timer)
{
new idx = 1;
while (idx <= MaxClients)
{
if (IsClientInGame(idx) == 1)
{
winner[idx] = 0;
}
idx++;
}
return Action:0;
}
public Action:qwerty2(Handle:timer)
{
CreateTimer(1.0, qwerty, any:2, 0);
return Action:0;
}
/* ERROR! java.lang.ArrayIndexOutOfBoundsException: -3 */
function "qwerty" (number 16)
public Action:not_allow(Handle:timer)
{
if (viktorina_available_or_not == true)
{
PrintToChatAll("\x04 \x04Никто не смог правильно ответить на вопрос :/");
PrintHintTextToAll("Никто не смог правильно ответить на вопрос :/");
viktorina_available_or_not = false;
}
return Action:0;
}
/* ERROR! java.lang.ArrayIndexOutOfBoundsException: -3 */
function "HookPlayerChat" (number 18)
ClearTimer(&Handle:timer)
{
if (timer)
{
KillTimer(timer, false);
timer = 0;
}
return 0;
}
public Action:luckyman(Handle:timer, any:client)
{
if (winner[client] == true)
{
if (!g_timers[client])
{
g_timers[client] = CreateTimer(1.0, Timer_Spark, client, 1);
CreateTimer(10.0, timer_kill, client, 2);
}
if (!g_timers_b[client])
{
g_timers_b[client] = CreateTimer(0.2, Timer_EnergySplash, client, 1);
}
}
return Action:0;
}
public Action:timer_kill(Handle:timer, any:client)
{
if (g_timers[client])
{
KillTimer(g_timers[client], false);
g_timers[client] = 0;
}
return Action:0;
}
public _PD(Handle:event, String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (g_timers[client])
{
KillTimer(g_timers[client], false);
g_timers[client] = 0;
}
if (g_timers_b[client])
{
KillTimer(g_timers_b[client], false);
g_timers_b[client] = 0;
}
return 0;
}
public Action:Timer_Spark(Handle:timer, any:client)
{
new var1;
if (!IsClientInGame(client) || !IsPlayerAlive(client))
{
return Action:4;
}
decl Float:fPos[3];
decl Float:dir[3];
GetClientAbsOrigin(client, fPos);
fPos[2] += 65;
TE_SetupSparks(fPos, dir, 8, 3);
TE_SendToAll(0.0);
TE_SetupSparks(fPos, dir, 8, 3);
TE_SendToAll(0.0);
return Action:0;
}
public Action:Timer_EnergySplash(Handle:timer, any:client)
{
new var1;
if (!IsClientInGame(client) || !IsPlayerAlive(client))
{
return Action:4;
}
decl Float:fPos[3];
decl Float:dir[3];
GetClientAbsOrigin(client, fPos);
fPos[2] += 30;
TE_SetupEnergySplash(fPos, dir, false);
TE_SendToAll(0.0);
return Action:0;
}