Someone
Участник
- Сообщения
- 1,933
- Реакции
- 1,653
Отсчет ?Люди есть у кого нить пример как сделать таймер в чате? Просто надо к другом плагину прикрутить .
Отсчет ?Люди есть у кого нить пример как сделать таймер в чате? Просто надо к другом плагину прикрутить .
ДаОтсчет ?
public void OnPluginStart()
{
RegConsoleCmd("sm_timer", CMD_TIMER);
}
public Action CMD_TIMER(int iClient, int iArgs)
{
CreateTimer(1.0, TIMER, _, TIMER_REPEAT);
return Plugin_Handled;
}
public Action TIMER(Handle hTimer)
{
static int iTimer = 5;
if(--iTimer == 0)
{
PrintToChatAll("Время вышло.");
return Plugin_Stop;
}
PrintToChatAll("Осталось %d секунд.", iTimer);
return Plugin_Continue;
}
А вот если в этом блоке:Обычно я так делаю:
PHP:g_iTimer; public void OnPluginStart() { RegConsoleCmd("sm_timer", CMD_TIMER); } public Action CMD_TIMER(int iClient, int iArgs) { g_iTimer = 30; CreateTimer(1.0, TIMER, _, TIMER_REPEAT); return Plugin_Handled; } public Action TIMER(Handle hTimer) { if(--g_iTimer == 0) { PrintToChatAll("Время вышло."); return Plugin_Stop; } PrintToChatAll("Осталось %d секунд.", g_iTimer); return Plugin_Continue; }
public Action:Timer_StopContest(Handle:timer, any:userid)
{
new client = CID(userid);
if ( !client ) return Plugin_Handled;
PrintToChat(client, "Время на ответ вышло");
g_timer[client] = INVALID_HANDLE;
return Plugin_Handled;
}
А вот если в этом блоке:
C-подобный:public Action:Timer_StopContest(Handle:timer, any:userid) { new client = CID(userid); if ( !client ) return Plugin_Handled; PrintToChat(client, "Время на ответ вышло"); g_timer[client] = INVALID_HANDLE; return Plugin_Handled; }
Не по глазам было)
--- Добавлено позже ---
Я не так давно в сурс мод пришел, могу ошибаться, но как я понимаю это сохраняет ид игрока или что то такое.
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma tabsize 0
#pragma newdecls required
#define PLUGIN_VERSION "1.2"
int flash_client;
public Plugin myinfo =
{
version = PLUGIN_VERSION,
};
public void OnPluginStart()
{
HookEvent("flashbang_detonate", flashbang_detonate);
HookEvent("player_blind", player_blind);
}
public void flashbang_detonate(Event event, const char[] name, bool silent)
{
flash_client = GetClientOfUserId(GetEventInt(event, "userid"));
}
public void player_blind(Event event, const char[] name, bool silent)
{
CreateTimer(0.01, TIMER_player_blind, GetEventInt(event, "userid"));
}
public Action TIMER_player_blind(Handle timer, any client)
{
if (flash_client == client && IsClientInGame(client) && !IsPlayerAlive(client) && GetClientTeam(client) == 1)
{
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 0.0);
SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.0);
ClientCommand(client, "dsp_player 0.0");
}
return Plugin_Stop;
}
L 06/07/2017 - 15:51:51: [SM] Native "IsClientInGame" reported: Client index 19 is invalid
L 06/07/2017 - 15:51:51: [SM] Displaying call stack trace for plugin "no_spec_flash.smx":
L 06/07/2017 - 15:51:51: [SM] [0] Line 35, D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp::TIMER_player_blind()
L 06/07/2017 - 16:07:19: Error log file session closed.
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#pragma tabsize 0
#pragma newdecls required
#define PLUGIN_VERSION "1.2"
// int flash_client;
Handle g_hFlashers;
public Plugin myinfo =
{
version = PLUGIN_VERSION,
};
public void OnPluginStart()
{
HookEvent("flashbang_detonate", flashbang_detonate);
HookEvent("player_blind", player_blind);
g_hFlashers = CreateArray(ByteCountToCells(4));
}
public void flashbang_detonate(Event event, const char[] name, bool silent)
{
PushArrayCell(g_hFlashers, GetClientOfUserId(GetEventInt(event, "userid")));
}
public void player_blind(Event event, const char[] name, bool silent)
{
RequestFrame(OnBlindedPlayer, GetEventInt(event, "userid"));
}
public void OnBlindedPlayer(int client)
{
client = GetClientOfUserId (client);
if (iClient && FindValueInArray(g_hFlashers, client) != -1 && IsClientInGame(client) && GetClientTeam(client) < 2)
{
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 0.0);
SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.0);
ClientCommand(client, "dsp_player 0.0");
}
}
@HESOYAM,с мобилки набросал.
PHP:#pragma semicolon 1 #include <sourcemod> #include <sdktools> #pragma tabsize 0 #pragma newdecls required #define PLUGIN_VERSION "1.2" // int flash_client; Handle g_hFlashers; public Plugin myinfo = { version = PLUGIN_VERSION, }; public void OnPluginStart() { HookEvent("flashbang_detonate", flashbang_detonate); HookEvent("player_blind", player_blind); g_hFlashers = CreateArray(ByteCountToCells(4)); } public void flashbang_detonate(Event event, const char[] name, bool silent) { PushArrayCell(g_hFlashers, GetClientOfUserId(GetEventInt(event, "userid"))); } public void player_blind(Event event, const char[] name, bool silent) { RequestFrame(OnBlindedPlayer, GetEventInt(event, "userid")); } public void OnBlindedPlayer(int client) { client = GetClientOfUserId (client); if (iClient && FindValueInArray(g_hFlashers, client) != -1 && IsClientInGame(client) && GetClientTeam(client) < 2) { SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 0.0); SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.0); ClientCommand(client, "dsp_player 0.0"); } }
//// noteamflash.sp
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(6) : warnin
g 207: unknown #pragma
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(6) : error
038: extra characters on line
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(11) : error
010: invalid function or declaration
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(13) : error
001: expected token: ";", but found "-identifier-"
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(16) : error
010: invalid function or declaration
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(18) : error
001: expected token: ";", but found "-identifier-"
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(25) : error
021: symbol already defined: "void"
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(25) : error
017: undefined symbol "event"
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(25) : error
029: invalid expression, assumed zero
// D:\Games\Server\cstrike\addons\sourcemod\scripting\noteamflash.sp(25) : fatal
error 127: too many error messages on one line
//
// Compilation aborted.
// 9 Errors.
if((GetClientTeam(client) == CS_TEAM_CT)&&(GetTeamClientCount(CS_TEAM_CT)==1)&&(GetTeamClientCount(CS_TEAM_T)>=1))
{
ChangeClientTeam(client, team);
if((GetTeamClientCount(CS_TEAM_CT))==0)
{
int randomClient;
if (GetArraySize(g_aGuardQueue))
{
randomClient = GetArrayCell(g_aGuardQueue, 0);
RemovePlayerFromGuardQueue(randomClient);
CGOPrintToChatAll("%t %t", "ratio_tag", "ratio_find", randomClient);
}
else if (gc_bBalanceTerror.BoolValue)
{
randomClient = GetRandomClientFromTeam(CS_TEAM_T);
CGOPrintToChatAll("%t %t", "ratio_tag", "ratio_random", randomClient);
}
else
{
return;
}
if (!IsValidClient(randomClient, true, true))
{
CGOPrintToChatAll("%t %t", "ratio_tag", "ratio_novalid");
}
SetClientPendingTeam(randomClient, CS_TEAM_CT);
SetClientListeningFlags(randomClient, VOICE_NORMAL); // unmute if sm_hosties or admin has muted prisoners on round start
MinusDeath(randomClient);
}
}
А можете пальцем ткнуть?@Forever Alone, лишние скобки у вызова функции получения кол-ва людей.
Исправил,но мут всё равно не убирает.@Forever Alone, выделил жирным, и подчеркнул.
if((GetTeamClientCount(CS_TEAM_CT))==0)
Добавь дебаг информационные сообщения и сам посмотриИсправил,но мут всё равно не убирает.
if (GetArraySize(g_aGuardQueue))
{
PrintToChatAll("условие 1.1")
randomClient = GetArrayCell(g_aGuardQueue, 0);
PrintToChatAll("randomclient это игрок с ником %N", randomClient)
RemovePlayerFromGuardQueue(randomClient);
CGOPrintToChatAll("%t %t", "ratio_tag", "ratio_find", randomClient);
}
else if (gc_bBalanceTerror.BoolValue)
PrintToChatAll("условие 1.2")
{
Хорошо,а так нет ошибок примерно в коде?Добавь дебаг информационные сообщения и сам посмотри
Например
C-подобный:if (GetArraySize(g_aGuardQueue)) { PrintToChatAll("условие 1.1") randomClient = GetArrayCell(g_aGuardQueue, 0); PrintToChatAll("randomclient это игрок с ником %N", randomClient) RemovePlayerFromGuardQueue(randomClient); CGOPrintToChatAll("%t %t", "ratio_tag", "ratio_find", randomClient); } else if (gc_bBalanceTerror.BoolValue) PrintToChatAll("условие 1.2") {
Тебе надо все сделать в дебаг форме и самому анализировать информациюХорошо,а так нет ошибок примерно в коде?
--- Добавлено позже ---
randomclient это игрок с ником {BLABLABLA}
Но всё равно игрок в муте,хотя всё верно пишет.
#pragma semicolon 1
#pragma newdecls required
#include <sdktools>
// int flash_client;
Handle g_hFlashers;
public Plugin myinfo =
{
version = "1.2"
};
public void OnPluginStart()
{
HookEvent("flashbang_detonate", flashbang_detonate);
HookEvent("player_blind", player_blind);
g_hFlashers = CreateArray(ByteCountToCells(4));
}
public void flashbang_detonate(Event event, const char[] name, bool silent)
{
PushArrayCell(g_hFlashers, GetClientOfUserId(event.GetInt("userid"))); // для чего нам вообще информация о том, кто бросил гранату?
}
public void player_blind(Event event, const char[] name, bool silent)
{
RequestFrame(OnBlindedPlayer, event.GetInt("userid"));
}
public void OnBlindedPlayer(int client)
{
client = GetClientOfUserId(client);
if (iClient && FindValueInArray(g_hFlashers, client) != -1 && IsClientInGame(client) && GetClientTeam(client) < 2) // откуда взялся iClient и для чего нам информация о бросившем гранату?
{
SetEntPropFloat(client, Prop_Send, "m_flFlashDuration", 0.0);
SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.0);
ClientCommand(client, "dsp_player 0.0");
}
}