Code:
char String1[128];
Handle menu = CreateMenu(MenuHandelr);
SetMenuTitle(menu, "[AutoRespawn] Main Menu");
Every time you open a handle, you have to close it or it is a memory leak.
Code:
public int MenuHandelr(Menu menu, MenuAction action, int client, int itemNum)
{
if (action != MenuAction_Select || !IsClientConnected(client))
return 1;
switch (itemNum)
{
-------------->
Code:
public int MenuHandelr(Menu menu, MenuAction action, int client, int itemNum)
{
if (action == MenuAction_End )
{
delete menu;
}
else if(action == MenuAction_Select)
{
switch (itemNum)
{
There's no reason the player will be disconnected if he pressed the menu.
And same for the vote menu, delete it in the callback.
There's also another bugs i can see in the code, but make sure to test them.
-
Code:
CreateTimer(float(sec), DisableAutoRespawn, client);
Close the timer if someone changed the ar option, or it will keep timer handle for free.
-
Code:
gi_ARVotesNeeded = RoundToFloor(float(gi_ARVoters) * 0.5);
gi_ARVoters is always 0, so the needed votes amount will be always 0.
-
Code:
if (gi_ARVotes >= gi_ARVotesNeeded)
{
EnableAutoRespawn();
}
If someone votes for ar before an ar was activated, the required votes number is always 0.
-
If player quits after he voted his vote will remain, also if player quits the game without voting and the votes before he left was 9/10 it should start.
__________________