Hey,
I made a plugin that supposed to allow players to make a vote for Headshots only in-game.
Code compiled with 1 warning, but crashing the server...
disclaimer:
i'm not pro, just a dude who plays around and sometimes make tiny cool stuff
PHP Code:
#include <sourcemod>
#include <sdkhooks>
#include <colors_csgo>
public Plugin myinfo =
{
name = "HS Mode Only Via Vote",
author = "Di3Z1E",
description = "Allowing the players to initiate a vote for Headshots Only.",
version = "1.00",
url = ""
};
bool votedone=false;
int countyes=0;
int countno=0;
public void OnPluginStart()
{
RegConsoleCmd("sm_hso", Command_HSonly, "Start Vote For Head Shot Mode Only");
}
public Action Command_HSonly(int client, int args)
{
PrintToChat(client, " \x10[המחתרת]\x01 Launched HS Mode Only Vote!")
return Plugin_Handled;
}
public Action votemenu(int client, int args)
{
char menuinfo[255];
Format(menuinfo, sizeof(menuinfo), "Activate Only Headshots mode?", client);
Menu hsonly = new Menu(votemenuhs);
hsonly.SetTitle(menuinfo);
Format(menuinfo, sizeof(menuinfo), "Yes", client);
hsonly.AddItem("yes", menuinfo);
Format(menuinfo, sizeof(menuinfo), "No", client);
hsonly.AddItem("no", menuinfo);
hsonly.ExitButton = true;
hsonly.Display(client, MENU_TIME_FOREVER);
return Plugin_Handled;
}
public int votemenuhs(Menu hsonly, MenuAction action, int client, int selection)
{
char info[32];
hsonly.GetItem(selection, info, sizeof(info));
if (strcmp(info, "yes") == 0)
{
countyes++;
}
else if (strcmp(info, "no") == 0)
{
countno++;
}
else if (action == MenuAction_End)
{
delete hsonly;
}
if (countyes>(countno+countyes)/2)
{
ServerCommand("sm_rcon mp_damage_headshot_only 1");
votedone=true;
}
else if (countno>(countno+countyes/2))
{
ServerCommand("sm_rcon mp_damage_headshot_only 0");
votedone=true;
}
}
public void OnMapStart()
{
votedone=false;
countno=0;
countyes=0;
}
edit:
set it to php instead of code