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

[TF2] Having problem with StrContains


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-28-2014 , 10:44   [TF2] Having problem with StrContains
Reply With Quote #1

So i have tried something like this
Code:
    if(StrContains(strName, "M-Crit") == 0)
    {
//        PrintToChatAll("addcond crit trigger.");
        TF2_AddCondition(client, TFCond_Buffed, TFCondDuration_Infinite);
    }
    else if(StrContains(strName, "Para") == 0)
    {
        PrintToChatAll("addcond trigger parachute.");
        CreateTimer(0.1, Timer_Parachute, client, TIMER_REPEAT)
    }
    else if(StrContains(strName, "DefBuff") == 0)
    {
//        PrintToChatAll("addcond crit trigger.");
        TF2_AddCondition(client, TFCond_DefenseBuffed, TFCondDuration_Infinite);
    }
And the problem is every time second one is choosen even if the bot name doesn't contain Para word
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-28-2014 , 10:57   Re: [TF2] Having problem with StrContains
Reply With Quote #2

Try this.

PHP Code:
    if(StrContains(strName"M-Crit"false) != -1)
    {
//        PrintToChatAll("addcond crit trigger.");
        
TF2_AddCondition(clientTFCond_BuffedTFCondDuration_Infinite);
    }
    if(
StrContains(strName"Para"false) != -1)
    {
        
PrintToChatAll("addcond trigger parachute.");
        
CreateTimer(0.1Timer_ParachuteclientTIMER_REPEAT)
    }
    if(
StrContains(strName"DefBuff"false) != -1)
    {
//        PrintToChatAll("addcond crit trigger.");
        
TF2_AddCondition(clientTFCond_DefenseBuffedTFCondDuration_Infinite);
    } 

Last edited by thecount; 12-28-2014 at 10:57.
thecount is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-28-2014 , 12:59   Re: [TF2] Having problem with StrContains
Reply With Quote #3

thecount already provides the code that addressed this, but StrContains returns the position that the string is in or -1 if it doesn't contain that string.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-28-2014 , 13:14   Re: [TF2] Having problem with StrContains
Reply With Quote #4

Quote:
Originally Posted by thecount View Post
Try this.

PHP Code:
    if(StrContains(strName"M-Crit"false) != -1)
    {
//        PrintToChatAll("addcond crit trigger.");
        
TF2_AddCondition(clientTFCond_BuffedTFCondDuration_Infinite);
    }
    if(
StrContains(strName"Para"false) != -1)
    {
        
PrintToChatAll("addcond trigger parachute.");
        
CreateTimer(0.1Timer_ParachuteclientTIMER_REPEAT)
    }
    if(
StrContains(strName"DefBuff"false) != -1)
    {
//        PrintToChatAll("addcond crit trigger.");
        
TF2_AddCondition(clientTFCond_DefenseBuffedTFCondDuration_Infinite);
    } 
I have tried it but it didn't worked
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player
Michalplyoutube is offline
thecount
Veteran Member
Join Date: Jul 2013
Old 12-28-2014 , 13:32   Re: [TF2] Having problem with StrContains
Reply With Quote #5

Maybe it's not a problem with StrContains then. You could possibly be using the wrong string or something.
thecount is offline
Michalplyoutube
Veteran Member
Join Date: Jan 2013
Location: Tank Carrier in Mannhatt
Old 12-28-2014 , 13:50   Re: [TF2] Having problem with StrContains
Reply With Quote #6

Quote:
Originally Posted by thecount View Post
Maybe it's not a problem with StrContains then. You could possibly be using the wrong string or something.
Maybe the bot name is changed after spawn not on spawn?

if i will change mission to other lets say the bots will keep their old names so they will have old addcond but the name is diffrent from addcond

bots are confusing
__________________
The plugin developer of TF2BWR Reborn
And a TF2 Player

Last edited by Michalplyoutube; 12-28-2014 at 13:56.
Michalplyoutube is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-28-2014 , 14:15   Re: [TF2] Having problem with StrContains
Reply With Quote #7

Quote:
Originally Posted by Michalplyoutube View Post
Maybe the bot name is changed after spawn not on spawn?

if i will change mission to other lets say the bots will keep their old names so they will have old addcond but the name is diffrent from addcond

bots are confusing
Try debugging the bot's name at runtime.
__________________
WildCard65 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 14:10.


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