Senior Member
|
07-19-2019
, 09:06
(L4D2) help with new complement style
|
#1
|
I am trying to join this voting system but it asks me for a new style, I have my plugin that uses #pragma newdecls required. someone could eliminate the actions. I do not have much knowledge of the type of style that he asks me, although it works. Excuse me for the English
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#pragma semicolon 1
#pragma newdecls required
#include <clientprefs>
int g_iYesCount;
int g_iNoCount;
int g_iVoters;
int g_iPlayers;
bool g_bAllVoted;
bool g_bReverseVote;
Handle g_hTimout;
int seconds;
public void OnPluginStart()
{
LoadTranslations("voto.phrases");
g_hTimout = CreateConVar("sm_timout", "30.0", "",FCVAR_NOTIFY);
RegConsoleCmd("sm_vt", sm_vt);
}
public Action sm_vt(int client, int args)
{
VoteOpen();
}
public void VoteOpen()
{
g_iYesCount = 0;
g_iNoCount = 0;
g_iVoters = 0;
g_iPlayers = 0;
g_bAllVoted = false;
int ReverseRnd = GetRandomInt(1, 2);
if (ReverseRnd == 1)
{
g_bReverseVote = true;
}
else
{
g_bReverseVote = false;
}
int i = 1;
while (i <= MaxClients)
{
if (IsClientInGame(i) && !IsFakeClient(i))
{
ShowVotePanel(i);
g_iVoters += 1;
g_iPlayers += 1;
}
i++;
}
seconds = GetConVarInt(g_hTimout);
CreateTimer(GetConVarFloat(g_hTimout) + 1.0, Timer_VoteCheck, any:0, 0);
CreateTimer(1.0, TimerInfo, any:0, 1);
return;
}
void ShowVotePanel(int client)
{
Handle panel = CreatePanel(Handle:0);
static char buffer[128];
static char buffer1[32];
static char buffer2[32];
Format(buffer, 128, "%t", "panel", client);
SetPanelTitle(panel, buffer, false);
if (g_bReverseVote)
{
Format(buffer2, 32, "%t", "Yes", client);
DrawPanelItem(panel, buffer2, 0);
Format(buffer1, 32, "%t", "No", client);
DrawPanelItem(panel, buffer1, 0);
}
else
{
Format(buffer1, 32, "%t", "No", client);
DrawPanelItem(panel, buffer1, 0);
Format(buffer2, 32, "%t", "Yes", client);
DrawPanelItem(panel, buffer2, 0);
}
SendPanelToClient(panel, client, VoteHandler, GetConVarInt(g_hTimout));
CloseHandle(panel);
return;
}
public int VoteHandler(Handle menu, MenuAction action, int client,int choice)
{
if (action == MenuAction:4)
{
int g_iVotes = g_iNoCount + g_iYesCount;
if (!g_bAllVoted)
{
EmitSoundToClient(client, "ui/alert_clink.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
PrintHintText(client, "%t %d/%d, %t %d sec\n%t (%d)\n%t (%d)", "Votes", g_iVotes, g_iPlayers, "left", seconds, "No", g_iNoCount, "Yes", g_iYesCount);
}
if (choice == 1)
{
if (g_bReverseVote)
{
g_iYesCount += 1;
g_iVoters -= 1;
}
else
{
g_iNoCount += 1;
g_iVoters -= 1;
}
}
if (choice == 2)
{
if (g_bReverseVote)
{
g_iNoCount += 1;
g_iVoters -= 1;
}
else
{
g_iYesCount += 1;
g_iVoters -= 1;
}
}
if (g_iVoters)
{
}
else
{
g_bAllVoted = true;
seconds = 0;
CountVotes();
}
}
return;
}
public Action Timer_VoteCheck(Handle timer)
{
if (!g_bAllVoted)
{
g_bAllVoted = true;
CountVotes();
}
return Action;
}
public Action TimerInfo(Handle timer)
{
int g_iVotes = g_iNoCount + g_iYesCount;
if (0 <= seconds)
{
int max = GetMaxClients();
int i = 1;
while (i <= max)
{
if (IsClientInGame(i) && !IsFakeClient(i))
{
PrintHintText(i, "%t %d/%d, %t %d sec\n%t (%d)\n%t (%d)", "Votes", g_iVotes, g_iPlayers, "left", seconds, "No", g_iNoCount, "Yes", g_iYesCount);
}
i++;
}
}
else
{
if (seconds < 0 || g_bAllVoted)
{
return Action;
}
}
seconds -= 1;
return Action;
}
public int GetVotes(int vote_Yes, int vote_No)
{
int votes = vote_No + vote_Yes;
int prcnt = RoundToNearest(1.0 * vote_Yes * 100 / votes);
return prcnt;
}
public void CountVotes()
{
int g_iVotes = g_iNoCount + g_iYesCount;
if (GetVotes(g_iYesCount, g_iNoCount) < 60)
{
PrintToChatAll("%t", "Players decided not. 60%% vote required (Received %d%% of %d votes)", GetVotes(g_iYesCount, g_iNoCount), g_iVotes);
EmitSoundToAll("ui/beep_error01.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
Effecoff();
}
else
{
PrintToChatAll("%t", "Players decided yes. (Received %d%% of %d votes)", GetVotes(g_iYesCount, g_iNoCount), g_iVotes);
EmitSoundToAll("ui/critical_event_1.wav", -2, 0, 75, 0, 1.0, 100, -1, NULL_VECTOR, NULL_VECTOR, true, 0.0);
Effecon();
}
return;
}
public void Effecon()
{
PrintToChatAll( ":3");
return;
}
public void Effecoff()
{
PrintToChatAll( ":/");
return;
}
|
|