Raised This Month: $51 Target: $400
 12% 

[CS:GO] Server crashes if I "spam" a command


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
awyx
Member
Join Date: Mar 2019
Old 02-08-2020 , 21:29   [CS:GO] Server crashes if I "spam" a command
Reply With Quote #1

So i've did a simple plugin which you can choose what hitmarker you want.
But if you use it too many times it crashes the sv ( only sometimes (with more than 1 player))
Any ideas?

Code:
Code:
#pragma semicolon 1
#include <sourcemod>
#include <sdktools>
#include <clientprefs>

public Plugin myinfo = 
{
	name = "Hitmarker menu",
	author = "roby & zauni",
	description = "",
	version = "",
	url = ""
};

#define TAG "\x01[\x10ERA\x01]"

int hm = 1; // hitmarker, default (1) = erawings,    2 = evil 
int sv_clients[MAXPLAYERS + 1]; // client array (each client will have X hitmarker, default = 1)
Handle hitmarkerCookie;

public OnPluginStart()
{
	RegConsoleCmd("sm_hitmarker",  MenuHM);
	RegConsoleCmd("sm_hitmarkers", MenuHM);
	RegConsoleCmd("sm_hitmark",    MenuHM);
	
	HookEvent("player_death",      EnDamage);
	
	hitmarkerCookie = RegClientCookie("hitmarker", "Hitmarker Choice", CookieAccess_Protected);
}

public void OnClientCookiesCached(int client) 
{
	if (IsFakeClient(client))
		return;
		
	if(IsClientConnected(client))
	{
		char buffer[32];
		
		GetClientCookie(client, hitmarkerCookie, buffer, sizeof(buffer));
		
		if (StrEqual(buffer, "0"))	sv_clients[client] = 0;
		if (StrEqual(buffer, "1"))	sv_clients[client] = 1;
		if (StrEqual(buffer, "2"))	sv_clients[client] = 2;
		if (StrEqual(buffer, "3"))	sv_clients[client] = 3;
		if (StrEqual(buffer, "4"))	sv_clients[client] = 4;
		if (StrEqual(buffer, "5"))	sv_clients[client] = 5;
		if (StrEqual(buffer, "6"))	sv_clients[client] = 6;
	}
}


public Action MenuHM(int client, int args)
{
	Menu menu = new Menu(MenuHM_CB);
	menu.SetTitle("Choose your hitmarker!");
	menu.AddItem("1", "E");
	menu.AddItem("2", "E");
	menu.AddItem("3", "C");
	menu.AddItem("4", "C");
	menu.AddItem("5", "K");
	menu.AddItem("6", "K");
	menu.Display(client, MENU_TIME_FOREVER);
	return Plugin_Handled;
}

public int MenuHM_CB(Menu menu, MenuAction action, int param1, int param2)
{
	switch (action) 
	{
		case MenuAction_Select:
		{
			char item[32], hm_name[16];
			menu.GetItem(param2, item, sizeof(item), _, hm_name, sizeof(hm_name));
			
			hm = StringToInt(item);
			sv_clients[param1] = hm;
			
			PrintToChat(param1, "%s \x04You chose \x0F%s\x04 hitmarker.", TAG, hm_name);
			
			SetClientCookie(param1, hitmarkerCookie, item);
		}
		
		case MenuAction_End: 	{ 	sv_clients[param1] = 1;    	delete menu; } 
		case MenuAction_Cancel: { 	sv_clients[param1] = 1; 	delete menu; } 
	}
}
__________________
Segmentation fault (core dumped)
https://steamcommunity.com/id/sleepiest/
roby#0577

Last edited by awyx; 07-27-2020 at 10:29.
awyx is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode