View Single Post
Kellan123
AlliedModders Donor
Join Date: Aug 2012
Old 07-12-2019 , 02:50   Re: How to change string into int?
Reply With Quote #7

Quote:
Originally Posted by CrazyHackGUT View Post
Space in the beginning required only for CS:GO. For normal games like CS:S or TF2, all color works without space.
Code:
#include <sourcemod>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = 
{
	name = "Spam",
	author = "Doggg, AlliedModders Donator",
	version = "1.1"
};

public void OnPluginStart()
{
	RegConsoleCmd("sm_spam", Spam);
}

public Action Spam(int client, int args)
{
	if(args > 0)
	{
		char camount[1];
		GetCmdArg(2, camount, sizeof(camount));
		
		int iamount = StringToInt(camount);
		
		if(iamount > 0)
		{
			char ccolor[1];
			GetCmdArg(1, ccolor, sizeof(ccolor));
			
			if(StrEqual(ccolor,"r"))
			{
				for(int i; i <= iamount; i++) PrintToChatAll(" \x02Spam");
			}
			else if(StrEqual(ccolor,"g"))
			{
				for(int i; i <= iamount; i++) PrintToChatAll(" \x04Spam");
			}
		}
		else
		{
			ReplyToCommand(client, "[SM] Please enter a normal number");
		}
	}
	else
	{
		ReplyToCommand(client, "[SM] spam <color> <amount of times>");
	}
}

Last edited by Kellan123; 07-12-2019 at 02:51.
Kellan123 is offline