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

Using Variable in StrContains ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kasikadam
Member
Join Date: Jun 2016
Old 10-06-2017 , 01:33   Using Variable in StrContains ?
Reply With Quote #1

I would like to use a variable in strcontains like;
Code:
public Action blablalbla(int iClient, char sCommand[512])
{
	int time <= 0
    if (StrContains(sCommand, "%d", time) != -1)
	{
		PrintToConsole(iClient, "Blalblabla");
		return Plugin_Handled;
	}

Last edited by kasikadam; 10-06-2017 at 01:34.
kasikadam is offline
Bobakanoosh
Senior Member
Join Date: Sep 2015
Location: United States
Old 10-06-2017 , 01:50   Re: Using Variable in StrContains ?
Reply With Quote #2

You cant use strContains like that. It's defined as:

Code:
int StrContains(const char[] str, const char[] substr, bool caseSensitive)
str is the string your checking,
substr is the string you're looking for in str,
caseSensitive is true or false, and just decides if it needs to be case sensitive or not.

If you want to check for time as the substring, you'll need to make a string and format it as so. To do so:
Code:
char sTime[128]
Format(sTime, sizeof(sTime), "%d", time)
Then, do:

Code:
if(StrContains(sCommand, sTime) != -1)
Wasn't quite sure what you were asking but hopefully this answers it.

Last edited by Bobakanoosh; 10-06-2017 at 01:50.
Bobakanoosh is offline
kasikadam
Member
Join Date: Jun 2016
Old 10-06-2017 , 02:03   Re: Using Variable in StrContains ?
Reply With Quote #3

Quote:
Originally Posted by Bobakanoosh View Post
You cant use strContains like that. It's defined as:

Code:
int StrContains(const char[] str, const char[] substr, bool caseSensitive)
str is the string your checking,
substr is the string you're looking for in str,
caseSensitive is true or false, and just decides if it needs to be case sensitive or not.

If you want to check for time as the substring, you'll need to make a string and format it as so. To do so:
Code:
char sTime[128]
Format(sTime, sizeof(sTime), "%d", time)
Then, do:

Code:
if(StrContains(sCommand, sTime) != -1)
Wasn't quite sure what you were asking but hopefully this answers it.
I think that will do the work thanks!
kasikadam is offline
Reply



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 06:35.


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