Raised This Month: $ Target: $400
 0% 

Copy strings id


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 03-24-2011 , 14:34   Copy strings id
Reply With Quote #1

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" 

Last edited by dFF; 03-24-2011 at 14:36.
dFF is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-24-2011 , 15:04   Re: Copy strings id
Reply With Quote #2

%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] )

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 03-25-2011 , 06:10   Re: Copy strings id
Reply With Quote #3

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" 

Last edited by dFF; 03-25-2011 at 06:20.
dFF is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 03-25-2011 , 06:23   Re: Copy strings id
Reply With Quote #4

Second. You can use also EOS ( End Of String, it contains 0 also ). string[ 0 ] = EOS, more readable.
__________________
Arkshine is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 03-25-2011 , 06:25   Re: Copy strings id
Reply With Quote #5

Thanks.
dFF is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 03-25-2011 , 16:09   Re: Copy strings id
Reply With Quote #6

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.
dFF is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 03-25-2011 , 17:09   Re: Copy strings id
Reply With Quote #7

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
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 03-25-2011 at 17:14.
ConnorMcLeod is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 03-26-2011 , 09:48   Re: Copy strings id
Reply With Quote #8

Thank you Connor . I solved my problem .
dFF 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 14:35.


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