AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   String Operations (https://forums.alliedmods.net/showthread.php?t=140181)

S34Qu4K3 10-09-2010 13:31

String Operations
 
Hi, i need help again :(

I have my string array: szText[192]
I put some words in the array using:
PHP Code:

public RegisterText(id)
{
    
client_cmd(id"messagemode Register_Text")
    
    
client_print(idprint_center"Write String")
    
set_hudmessage(255000.00.000.14.00.010.01, -1)
    
ShowSyncHudMsg(idg_MsgSync2"^n^n^n  Write String")
    
    return 
PLUGIN_CONTINUE;
}

public 
Text_register(id)
{
    
read_argsszText191 )
    
remove_quotesszText )
    
trim szText )
        
    
    
copyText[id], charsmaxText ), szText )
    
    
client_printidprint_chat"Tu string es: %s"Text[id] )
    
RegisterPassword(id)
    return 
PLUGIN_CONTINUE;
    


Now i want to put each 2 words of the string in a independent array but i donīt have any idea to do this :(

I want to do something like that

He --> Array1
ll ---> Array2
o^0 --->Array3

Exolent[jNr] 10-09-2010 13:49

Re: String Operations
 
Code:
new szPieces[ 10 ][ 3 ]; // 10 max pieces with length of 2 // szInput is the string you are finding pieces of new i, iPos; while( i < sizeof( szPieces ) && szInput[ iPos ] ) {     iPos+= copy( szPieces[ i++ ], charsmax( szPieces ), szInput ); }

S34Qu4K3 10-09-2010 13:56

Re: String Operations
 
Thanks Exolent
More questions:(:
if i want to operate with the first array Itīs well that i use:
PHP Code:

szPieces[0][3

??
How can i convert all the words using the ASCII alphabet to a number ej: A= 97, B=98 etc
I want this to make this operation with each array

_---------|a b |
(97, 98 )x |___| = (97 x a + 98 x c, 98 x b + 98 x d)
_---------|c d |



Thank you and sorry for all my doubts

Exolent[jNr] 10-09-2010 13:59

Re: String Operations
 
Quote:

Originally Posted by S34Qu4K3 (Post 1320359)
Thanks Exolent
More questions:(:
if i want to operate with the first array Itīs well that i use:
PHP Code:

szPieces[0][3

??
How can i convert all the words using the ASCII alphabet to a number ej: A= 97, B=98 etc

Thank you and sorry for all my doubts

Using that code, here is what you would get:
Code:
// szInput = "Testing" szPieces[ 0 ][ 0 ] = 'T' szPieces[ 0 ][ 1 ] = 'e' szPieces[ 1 ][ 0 ] = 's' szPieces[ 1 ][ 1 ] = 't' szPieces[ 2 ][ 0 ] = 'i' szPieces[ 2 ][ 1 ] = 'n' szPieces[ 3 ][ 0 ] = 'g' szPieces[ 4 ][ 1 ] = '^0' or 0

Characters in Pawn are also integers.

Try this:
Code:
server_print( "'a' = %i", 'a' )
It will output:
Code:

'a' = 97
Also, a=97, b=98, and A=65, B=66.


All times are GMT -4. The time now is 10:18.

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