AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with Array (https://forums.alliedmods.net/showthread.php?t=277978)

Vit_amin 01-21-2016 16:13

Problem with Array
 
I write code:
PHP Code:

                new szTest[33]
                new 
szTest2[128]
                
get_user_info(client"name"szTestcharsmax(szTest))
                new 
iTest 0
                
for (new 0<= charsmax(szTest2); i++)
                {
                    if (!
strcmp(szTest2[i], ""))
                    {
                        
iTest++
                        if (
iTest <= strlen(szTest))
                        {
                            
server_print("TEST 1")
                            
copy(szTest2[i], charsmax(szTest2), szTest[i])
                        }
                        else if (
iTest == strlen(szTest) + 1)
                        {
                            
server_print("TEST 2")
                            
copy(szTest2[i], charsmax(szTest2), ",")
                        }
                        else break
                    }
                }
                
server_print(szTest2

How output this format ? Name1, Name2, Name3, ...
Server output only Name1 or Name2 or Name3 or ...

Bugsy 01-21-2016 16:17

Re: Problem with Array
 
Explain what you are trying to do with words, not code.

Vit_amin 01-21-2016 16:21

Re: Problem with Array
 
I want that the variable szTest2 output players this format: Name1, Name2, Name3 ...
But when client respawn i output only one player name (not format list)

addons_zz 01-21-2016 16:45

Re: Problem with Array
 
Look these lines highlighted (L1397-L1410):

https://github.com/addonszz/Multi-Mod_Manager/blob/276bd6f2930625feb7a7c35d86f5a42d168e6e7f/scripting/multimod_manager.sma#L1397-L1410

Vit_amin 01-21-2016 16:48

Re: Problem with Array
 
Thank you, tried this

Vit_amin 01-21-2016 17:51

Re: Problem with Array
 
I don't understand. Write code:
PHP Code:

...
new Array:
g_aClientName
...
g_aClientName ArrayCreate(32)
...
public 
IsClientRetry(client)
{
    new 
client_name[32]
    
get_user_info(client"name"client_namecharsmax(client_name))
    
ArrayPushString(g_aClientNameclient_name)
    new 
size ArraySize(g_aClientName)
    new 
test1[32]
    
server_print("Size 1: %d"size)
    for (new 
0<= sizei++)
    {
        
server_print("Size 2: %d"size)
        
ArrayGetString(g_aClientNameitest1charsmax(test1))
        
server_print("%s"test1)
    }


Console Output:
Code:

L 01/22/2016 - 00:47:16: Invalid cellvector handle provided (6:1:1)
L 01/22/2016 - 00:47:16: [AMXX] Displaying debug trace (plugin "zombie_horde.amxx")
L 01/22/2016 - 00:47:16: [AMXX] Run time error 10: native error (native "ArrayGetString")
L 01/22/2016 - 00:47:16: [AMXX]    [0] zombie_horde.sma::IsClientRetry (line 596)
L 01/22/2016 - 00:47:16: [AMXX]    [1] zombie_horde.sma::Event_PlayerSpawn (line 564)


Vit_amin 01-21-2016 18:04

Re: Problem with Array
 
Solved
PHP Code:

for (new 0sizei++) 


Vit_amin 01-21-2016 21:55

Re: Problem with Array
 
But 1 Auestion:
When i added -> ArrayPushString(g_aClientName, szSteamID)
How check what if szSteamID add in g_aClientName ?

addons_zz 01-21-2016 22:11

Re: Problem with Array
 
ArrayFindString for AMXX 183 or superior.

Code:
new position = ArrayFindString(my_dynamic_array_pointer, my_string) if( position  == -1 )     server_print( "Not found" ) else     server_print( "Found at: %d position", position )
For the AMXX 182, consider using tries or do a loop throw the array. See also: The advantages of a trie over an array for strings storage.


All times are GMT -4. The time now is 08:48.

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