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

help me for strcontains thanks~


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xuxinsheng1
Junior Member
Join Date: May 2013
Old 08-08-2013 , 00:14   help me for strcontains thanks~
Reply With Quote #1

Code:
#undef REQUIRE_PLUGIN
#include <sdktools>
#include <adminmenu>
#include <sourcemod>
#include <string>

new g_hostname;
new c_hostname;

public OnPluginStart()
{
	HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
	c_hostname = CreateConVar("hostname", "XXXXX #1 jail break", "hostname Plugin");
	
}

public Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
	decl String:hostname_name[128];
	g_hostname = GetConVarString(c_hostname, hostname_name, sizeof(hostname_name))
	
	if(StrContains("g_hostname", "XXX #1", false) == 0)
	{
		//to open jail break
	}
	
	if(StrContains("g_hostname", "XXX #2", false) == 0)
	{
		// to open death match
	}
}
I want to use plugin to in different hostname can make different action
such as in hostname "XXX #1 jail break" open jailbreak plugin
in hostname "XXX #2 death match" open death match plugin

but in compiler:
line 25 warning 213:tag mismatch
Code:
c_hostname = CreateConVar("hostname", "XXXXX #1 jail break", "hostname Plugin");
line 32 warning 213:tag mismatch
Code:
g_hostname = GetConVarString(c_hostname, hostname_name, sizeof(hostname_name))
line 34 warning 204:symbol is assigned a value that is never used:"g_hostname"
Code:
if(StrContains("g_hostname", "XXX #1", false) == 0)
I used three day to fix it but it still warning and plugin have no any action
help I need help thanks!

Last edited by xuxinsheng1; 08-08-2013 at 00:49. Reason: add code head
xuxinsheng1 is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 08-08-2013 , 00:56   Re: help me for strcontains thanks~
Reply With Quote #2

Do != -1 instead of == 0

"-1 on failure (no match found). Any other value indicates a position in the string where the match starts."

Last edited by blaacky; 08-08-2013 at 00:57.
blaacky is offline
TheGodKing
BANNED
Join Date: Dec 2012
Location: PrintToChatAll("Aus
Old 08-08-2013 , 02:50   Re: help me for strcontains thanks~
Reply With Quote #3

PHP Code:
new Handle:c_hostname INVALID_HANDLE
TheGodKing is offline
xuxinsheng1
Junior Member
Join Date: May 2013
Old 08-08-2013 , 06:06   Re: help me for strcontains thanks~
Reply With Quote #4

Quote:
Originally Posted by TheGodKing View Post
PHP Code:
new Handle:c_hostname INVALID_HANDLE
Quote:
Originally Posted by blaacky View Post
Do != -1 instead of == 0

"-1 on failure (no match found). Any other value indicates a position in the string where the match starts."
now it warning :
line 34 warning 204:symbol is assigned a value that is never used:"g_hostname"
PHP Code:
if(StrContains("g_hostname""XXX #1"false) != -1
can I ignore ?

news:now i test the plugin.no any action still. help QAQ

Last edited by xuxinsheng1; 08-08-2013 at 06:12. Reason: no any action
xuxinsheng1 is offline
blaacky
Senior Member
Join Date: Oct 2012
Old 08-08-2013 , 06:18   Re: help me for strcontains thanks~
Reply With Quote #5

Seems I didn't pay attention to the whole if statement there hehe

When you compared the string, you were checking if the literal string "g_hostname" contained the character sequence "XXX #1" and "XXX #2". It should be without quotes, and you should have used the hostname_name string variable to compare with instead.

PHP Code:
new Handle:c_hostname;

public 
OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
    
c_hostname CreateConVar("hostname""XXXXX #1 jail break""hostname Plugin");
    
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:hostname_name[128];
    
GetConVarString(c_hostnamehostname_namesizeof(hostname_name));
    
    if(
StrContains(hostname_name"XXX #1"false) != -1)
    {
        
//to open jail break
    
}
    
    if(
StrContains(hostname_name"XXX #2"false) != -1)
    {
        
// to open death match
    
}

blaacky is offline
xuxinsheng1
Junior Member
Join Date: May 2013
Old 08-09-2013 , 05:13   Re: help me for strcontains thanks~
Reply With Quote #6

Quote:
Originally Posted by blaacky View Post
Seems I didn't pay attention to the whole if statement there hehe

When you compared the string, you were checking if the literal string "g_hostname" contained the character sequence "XXX #1" and "XXX #2". It should be without quotes, and you should have used the hostname_name string variable to compare with instead.

PHP Code:
new Handle:c_hostname;

public 
OnPluginStart()
{
    
HookEvent("round_start"Event_RoundStartEventHookMode_PostNoCopy);
    
c_hostname CreateConVar("hostname""XXXXX #1 jail break""hostname Plugin");
    
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
decl String:hostname_name[128];
    
GetConVarString(c_hostnamehostname_namesizeof(hostname_name));
    
    if(
StrContains(hostname_name"XXX #1"false) != -1)
    {
        
//to open jail break
    
}
    
    if(
StrContains(hostname_name"XXX #2"false) != -1)
    {
        
// to open death match
    
}

thanks thanks very thanks I fixed it thanks!!!!!!!!!!!!!!!!
xuxinsheng1 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 01:57.


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