Raised This Month: $ Target: $400
 0% 

Strings and pawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
sskillz
Member
Join Date: Apr 2005
Old 02-24-2007 , 15:17   Strings and pawn
Reply With Quote #1

Hello, I just started making my plugin and its almost complete, I have a string which goes like this: "%STEAMID%STEAMID%STEAMID"

now how I get each STEAMID? and how can I kick each one from the server?
10x ahead It just stupid using string with pawn (sorry I come from per )

Also I could test if a string starts with "CHK" ;\

10x.
sskillz is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-24-2007 , 15:33   Re: Strings and pawn
Reply With Quote #2

Quote:
Originally Posted by sskillz View Post
Hello, I just started making my plugin and its almost complete, I have a string which goes like this: "%STEAMID%STEAMID%STEAMID"

now how I get each STEAMID? and how can I kick each one from the server?
10x ahead It just stupid using string with pawn (sorry I come from per )

Also I could test if a string starts with "CHK" ;\

10x.
Code:
public test(id) {     //Getting the SteamID     new steamid[32] //Must make the variable to hold 32 characters (STRING)     get_user_steamid(id,steamid,31) //GET THE INFO, store it in steamid for a len* of 31. (31 = 32 chars because it starts at 0, not 1)         //Getting a Name     new name[32]     get_user_name(id,name,31)         //Kicking the STEAMID     new target_id = cmd_target(id,steamid) //Player ID     new target_uid = get_user_userid(target_id) //The Player's actual slot ID |Only retrieved for the RAW Kick COmmand|         new command[128]     format(command,127,"kick #%d ^"You have been kicked.^"",target_uid)     server_cmd(command)         //To Add strings together here are some types:     // %s = string     // %f = float     // %i = integer         new combined[80]         //This will produce "STEAMIDSTEAMIDSTEAMID"     format(combined,79,"%s%s%s",steamid,steamid,steamid)         //This will produce "STEAMID STEAMID STEAMID"     format(combined,79,"%s %s %s",steamid,steamid,steamid)         //This will produce "STEAMID STEAMID NAME"     format(combined,79,"%s %s %s",steamid,steamid,name)             //This will produce "STEAMID STEAMID 12"     new num = 12 //This is an integer, notice its not indexed (or is not an array)     format(combined,79,"%s %s %i",steamid,steamid,num)         //This will produce "STEAMID STEAMID 24.5"     new Float:num_float = 24.5 //This is a float, a float is just a decimal number. You must start the new var with "Float:" and it must be a decimal     format(combined,79,"%s %s %f",steamid,steamid,num_float) }
__________________


Last edited by mysticssjgoku4; 02-24-2007 at 15:35.
mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-24-2007 , 19:05   Re: Strings and pawn
Reply With Quote #3

goku: No.

To split strings, like your trying to do, use this stock.

Code:
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter ) { // Function by xeroblood     new nIdx = 0, l = strlen(p_szInput)     new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))     while( (nLen < l) && (++nIdx < p_nMax) )         nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))     return nIdx }

You can use it like this:
Code:
new string[] = "STEAM%STEAM%STEAM"; new steamid[3][32]; // This will be all 3 steam ids split from the string. ExplodeString(steamid, 2, 31, string, '%'); // variable 'steamid' now contains all steamids in the first dimension (steamid[0], steamid[1], steamid[2]).

You can kick them, continuing on the code above, like this:
Code:
new i; for (i = 0; i < 2; i++)      server_cmd("kick ^"%s^" ^"You were kicked due to your steamid.^"", steamid[i]);

Let me know if you have any compile time errors.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 02-25-2007 at 09:58. Reason: Fixed ExplodeString() 4th parameter.
Zenith77 is offline
mysticssjgoku4
Veteran Member
Join Date: Jan 2005
Location: Chicago Heights, IL
Old 02-24-2007 , 20:14   Re: Strings and pawn
Reply With Quote #4

Oh I misunderstood what he was asking :S.
__________________

mysticssjgoku4 is offline
Send a message via AIM to mysticssjgoku4 Send a message via MSN to mysticssjgoku4
sskillz
Member
Join Date: Apr 2005
Old 02-25-2007 , 08:17   Re: Strings and pawn
Reply With Quote #5

Hello again,
Thank you so much!
I had that ExplodeString routine but I didn't know excatly how to use it, Now I know.

Some obious questions:
Is 32 here is max length of the steamid?
new steamid[3][32];

I didn't know kick steamID from the console works I was sure I tried it :\

Anyway thanks ill continue from here
sskillz is offline
sskillz
Member
Join Date: Apr 2005
Old 02-25-2007 , 09:54   Re: Strings and pawn
Reply With Quote #6

You forgot one of the parameters with the explode (input string).
Also that kick didn't work for me, after look in how amx_kick can kick steamIDs
I learned how to kick them here is what I did in the end:

Code:
 new steamid[32][32];
		    ExplodeString(steamid,2,31,buf,'%');
			
		    //Handle Data
			server_print("(SnapShooter) GOT PEOPLE TO KICK");
			server_print("(SnapShooter) READ(%i bytes): %s",z,buf);
			
			new i;
            for (i = 1; i <= 32; i++) { 
			    if (strlen(steamid[i]) > 5) { 
	                new reason[43] = "(SnapShooteR) Please activate SnapShooter!";			
	                new player = cmd_target(1, steamid[i], 0);	
	                new userid = get_user_userid(player);
	                server_cmd("kick #%d ^"%s^"", userid, reason)
			    } 
			}
sskillz is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-25-2007 , 09:58   Re: Strings and pawn
Reply With Quote #7

Ok, pretty decent for your level. But use get_players() for your for loop. Check in funcwiki on how to use it.

And instead of this:
Code:
 new reason[43] = "(SnapShooteR) Please activate SnapShooter!"; server_cmd("kick #%d ^"%s^"", userid, reason)

Just do this:
Code:
server_cmd("kick #%d ^"(SnapShooteR) Please activate SnapShooter!^"", userid);

No point in creating a buffer there ;-).
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred

Last edited by Zenith77; 02-25-2007 at 10:01.
Zenith77 is offline
sskillz
Member
Join Date: Apr 2005
Old 02-25-2007 , 12:36   Re: Strings and pawn
Reply With Quote #8

Yea i know i didn't have to use reason...
Where did you suggest me to use get players?
I mean I know where it needs to be but it also means if ill use get_players
I'll have to loop more times than this...
sskillz is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 02-25-2007 , 13:58   Re: Strings and pawn
Reply With Quote #9

No you won't. Use it in the loop where you kick people.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Reply


Thread Tools
Display Modes

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 00:45.


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