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

How to change string into int?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Doggg
Member
Join Date: Jun 2018
Old 07-11-2019 , 07:41   How to change string into int?
Reply With Quote #1

Hey I am to get better in sourcepawn (as you may see) but i feel like I am doing terrible job. The source api not really helping because i need to know how to actually use these functions so I have no other chooise then to ask you.
I wanted to create a plugin that will spam "spam" in the chat. and added a color choose to the client.
for exaple he will write /spam r 5, this will print 5 times in red spam. (I am really trying to get better so i guess i need to practice in these nonesence plugins, If someone challange me to write a plugin for begginers ofc, i started learning only 3 days ago.. i will be more then happy to try) anyway, How bad is it?
Code:
public void OnPluginStart()
{
 RegConsoleCmd("sm_spam", SPAM); 
}

public Action SPAM (int client, int args)

{
if(args > 2)
{
ReplyToCommand(client, "[SM] spam <color> <amount of times>");
}	

char colorchoose[3]; 
GetCmdArg(1, colorchoose, sizeof(colorchoose));
char Camount[4]; 
GetCmdArg(2, Camount, sizeof(Camount));
int iamount = StringToInt(Camount, 10); 

if(iamount = 0)
{
ReplyToCommand(client, "[SM] Please enter a normal number");
}


if(StrEqual(colorchoose,"r"))
{
for (int i = 0; i < iamount; i++)
{
PrintToChatAll("\x03Spam");
}
}

else if(StrEqual(colorchoose,"g"))
{

for (int i = 0; i < iamount; i++)
{
PrintToChatAll("\x04Spam");
}

}

Last edited by Doggg; 07-11-2019 at 07:42.
Doggg 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 03:00.


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