Raised This Month: $ Target: $400
 0% 

Cut String


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
4JOKE
Member
Join Date: Jan 2008
Old 12-20-2008 , 10:31   Cut String
Reply With Quote #1

I need help with cutting strings.
I.E. : "This is my string" (without quotes)

And I need it to cut as here:
"this" " is my string"

I tryed it with strbreak, split or parse and it didn't functioned, because I still get:
"this" "is my string:

Does someone know how to solve my problem?

Thnx.
4JOKE is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 12-20-2008 , 11:22   Re: Cut String
Reply With Quote #2

strbreak is what you need.
http://www.amxmodx.org/funcwiki.php?...strb&go=search

All you have to do is add an extra space to the second part of the string.

This should work :
PHP Code:
new szFirst[16], szRest[64]
strbreak "This is my string"szFirstcharsmax(szFirst), szRest[1], charsmax(szRest)-
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
4JOKE
Member
Join Date: Jan 2008
Old 12-20-2008 , 11:45   Re: Cut String
Reply With Quote #3

Thnx, but your solution is not what I need.
There is no other way how to split string exatly as it is ? With spaces ?

Because I wanted to make scrolling text by show_hudmessage, so I need cut first char of string and put it to end.
I wanted to do it by strbreak() and format() but as I said I have problem with spaces when use strbreak().
4JOKE is offline
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 12-20-2008 , 13:31   Re: Cut String
Reply With Quote #4

PHP Code:
stock first_char_to_last_char( const input[], output[] )
{    
    
formatoutputstrleninput ), "%s%s"input[1], input[0] );

example:
PHP Code:
new const string[64] = "abcdefghijklmnopqrstuvwxyz";
    
new 
temp[64];
first_char_to_last_charstringtemp );

// now temp[] stores this: "bcdefghijklmnopqrstuvwxyza" 
__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 12-20-2008 , 13:34   Re: Cut String
Reply With Quote #5

Quote:
Originally Posted by SchlumPF* View Post
PHP Code:
stock first_char_to_last_char( const input[], output[] )
{    
    
formatoutputstrleninput ), "%s%s"input[1], input[0] );

PHP Code:
stock first_char_to_last_char( const input[], output[] )
{    
    
formatoutputstrleninput ), "%s%c"input[1], input[0] );

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 12-20-2008 , 13:41   Re: Cut String
Reply With Quote #6

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
stock first_char_to_last_char( const input[], output[] )
{    
    
formatoutputstrleninput ), "%s%c"input[1], input[0] );

PHP Code:
stock move_chars( const input[], char_numoutput[] )
{    
    
formatexoutputstrleninput ), "%s%s"input[charnum], input );

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`
SchlumPF*
Veteran Member
Join Date: Mar 2007
Old 12-20-2008 , 13:50   Re: Cut String
Reply With Quote #7

Quote:
Originally Posted by Exolent[jNr] View Post
PHP Code:
stock first_char_to_last_char( const input[], output[] )
{    
    
formatoutputstrleninput ), "%s%c"input[1], input[0] );

didnt know that pawn is able to print single chars by %c :/ never daw that one before

PHP Code:
stock first_char_to_last_char( const input[], output[], len )
{    
    
formatoutputlen"%s%c"input[1], input[0] );

__________________
SchlumPF* is offline
Send a message via ICQ to SchlumPF*
4JOKE
Member
Join Date: Jan 2008
Old 12-20-2008 , 14:52   Re: Cut String
Reply With Quote #8

I didn't know it too

Thnx very much to all ! Problem solved
4JOKE 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 09:18.


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