Raised This Month: $ Target: $400
 0% 

Comparing strings


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-03-2009 , 19:07   Comparing strings
Reply With Quote #1

Dunno if this goes here.

Let's say...

steamid1 = 0:0:28033812
steamid2 = 0:0:28033


if(containi(steamid1, steamid2[i]) != -1) { blah }

When this happens 0:0:28033812 is also affected since it has 0:0:28033 inside of it.

What would be the best solution for this? Should I be even using containi?
P4rD0nM3 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 02-03-2009 , 19:07   Re: Comparing strings
Reply With Quote #2

equal()
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-03-2009 , 19:28   Re: Comparing strings
Reply With Quote #3

But using equal() would only allow that specific SteamID.

I was wondering if you can have 0:0:28033XX SteamID's be allowed and if it goes out of that range then they won't be affected. This way all the cafe terminals will have an admin account and if someone out there connects then they won't get admin.
P4rD0nM3 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-03-2009 , 19:44   Re: Comparing strings
Reply With Quote #4

Try with str_to_num starting after the last colon.

Then check if that number is within your desired numbers.

Ex.
Code:
new string[] = "steam:2300" //just a random id
new num = str_to_num( string[6] );
if( num > 2300 && num < 2400 )
    //do stuff here
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-03-2009 , 19:56   Re: Comparing strings
Reply With Quote #5

Hey Emp, would that include 0:0

All it says is

str_to_num - Returns a string converted to a number

When you do...

new num = str_to_num( string[10] )

Does that mean it'll count to 10 and strip the rest? Like for STEAM:0:0:1234567890 it'll strip STEAM:0:0: and then 1234567890 will be in num?

Last edited by P4rD0nM3; 02-03-2009 at 20:03.
P4rD0nM3 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-03-2009 , 19:58   Re: Comparing strings
Reply With Quote #6

If you are using steamids as the string (STEAM_0:0:XXXX)
Then the last colon is the 10th character, so you would do
Code:
str_to_num( string_name[10] )
For more information on this method, check out String Slicing.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-03-2009 , 20:10   Re: Comparing strings
Reply With Quote #7

What if I have STEAM_0:0:123 and STEAM_0:0:234 and my own SteamID which is STEAM_0:0:28033.

Like.

Code:
new const adminIDs[][] = {   "steam_0:0:123", // range   "steam_0:0:234", // range   "steam_0:0:28033" // mine }

str_to_num only strips the front one? What if I want to strip the back one too or simply the ones at the back like steam_0:0:1231131?

Last edited by P4rD0nM3; 02-03-2009 at 20:14.
P4rD0nM3 is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 02-03-2009 , 20:14   Re: Comparing strings
Reply With Quote #8

You'll have to separate it into two ranges or something.

Code:
if within first range
   func()
else if within second range
   func()
else if equal to random steam id
   func()
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
P4rD0nM3
Veteran Member
Join Date: Feb 2006
Old 02-03-2009 , 20:26   Re: Comparing strings
Reply With Quote #9

Damn, all that just to get admin and ban someone...screw these people they should just call the manager. Haha, thanks though! At least I could do it for my ID.
P4rD0nM3 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:38.


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