AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Copy strings id (https://forums.alliedmods.net/showthread.php?t=153501)

dFF 03-24-2011 14:34

Copy strings id
 
PHP Code:

#include amxmodx

new string33 ][ 32 ]

public 
plugin_init() 
{
    
register_clcmd"set""pset" )
    
register_clcmd"rem""prem" )
    
register_clcmd"rem2""prem2" )
}

public 
psetid )
{
    
copystringid ], 31"test" )
    
    
server_print"** %s | %d"stringstring )
}

public 
premid )
{
    
copystringid ], 31"" )
    
    
server_print"*** %s | %d"stringstring )
}

public 
prem2id )
{
    
stringid ][ ] = '^0'
    
//string[ id ] = "^0"
    
    
server_print"**** %s | %d"stringstring )


Command I used

set and rem2 and the result:
Code:

** ****
Why ? Why not show me the text and the value ?

Another question, How is the best method to reset the strings value ?


PHP Code:

copystringid ], 31"" )

or

stringid ][ ] = '^0'

or

stringid ] = "^0" 


ConnorMcLeod 03-24-2011 15:04

Re: Copy strings id
 
%s should match with string[id] and not string

PHP Code:

#include amxmodx

new string33 ][ 32 ]

public 
plugin_init() 
{
    
register_clcmd"set""pset" )
    
register_clcmd"rem""prem" )
    
register_clcmd"rem2""prem2" )
}

public 
psetid )
{
    
copystringid ], charsmax(string[]), "test" )
    
    
server_print"**** %s"string[id] )
}

public 
premid )
{
    
copystringid ], charsmax(string[]), "" )
    
    
server_print"**** %s"string[id] )
}

public 
prem2id )
{
    
stringid ][ ] = '^0'
    
    
server_print"**** %s"string[id] )



dFF 03-25-2011 06:10

Re: Copy strings id
 
Ohh, My mistake. Thanks for reply.


Another question, How is the best method to reset the strings ( set to zero value or "" ) ?

PHP Code:

copystringid ], charsmaxstring[ ] ), "" )

or

stringid ][ ] = '^0'

or

stringid ] = "^0" 


Arkshine 03-25-2011 06:23

Re: Copy strings id
 
Second. You can use also EOS ( End Of String, it contains 0 also ). string[ 0 ] = EOS, more readable.

dFF 03-25-2011 06:25

Re: Copy strings id
 
Thanks.

dFF 03-25-2011 16:09

Re: Copy strings id
 
Sorry for double post, but I need help again.

How to use string for 3d array, like:

PHP Code:

g_Test33 ][ 32 ][ ]

//reset:

g_Testid ][ ] = EOS
g_Test
id ][ ] = EOS

//copy:
copyg_Testid ][ ], charsmaxg_Test[ ] ), "test" )
copyg_Testid ][ ], charsmaxg_Test[ ] ), g_Testid ][ ] ) 

It is ok ?

Sorry I have some problem with my PC and I can not test on server.

ConnorMcLeod 03-25-2011 17:09

Re: Copy strings id
 
Wouldn't it be more readable to use 2 vars ?

new string1[33][32]
new string2[33][32]

?


Else i would do :

new string[33][2][32]
and not
new string[33][32][2]

Then :
get_user_name(id, string[id][0], charsmax(string[][])
get_user_authid(id, string[id][1], charsmax(string[][])


string[id][0][0] = 0
string[id][0][1] = 0



Else you can also considerate to create a structure, depending on what you are doing.

Not sure following code is fine, i usually correct such code when i try to compile :

enum _:m_Datas {
m_szName[32],
m_szAuthid[32]
}

new g_mPlayersDatas[33][m_Datas] // note that it is same result as new string[33][2][32] i do before

get_user_name(id, g_mPlayersDatas[id][m_szName], charsmax(g_mPlayersDatas[][m_szName]))
get_user_authid(id, g_mPlayersDatas[id][m_szAuthid], charsmax(g_mPlayersDatas[][m_szAuthid]))

g_mPlayersDatas[id][m_szName][0] = 0
g_mPlayersDatas[id][m_szAuthid][0] = 0

dFF 03-26-2011 09:48

Re: Copy strings id
 
Thank you Connor :mrgreen:. I solved my problem :wink:.


All times are GMT -4. The time now is 14:35.

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