AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get the names of a Team in a String? (https://forums.alliedmods.net/showthread.php?t=132666)

mottzi 07-17-2010 14:51

Get the names of a Team in a String?
 
Hey AM,

can you help me abit? thats my code:

PHP Code:

new names[33][35

blabla(id)
{
    new 
players[32], pnumtempid;
    
get_players(playerspnum);
    
    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
get_user_name(idnames[tempid], 34)
    }


so how can i convert the "names" variable to a string like: "name1 name2 name2 .. name32" ?

AngeIII 07-17-2010 15:13

Re: Get the names of a Team in a String?
 
try this:
PHP Code:

new names[33][35]  

blabla(id

    new 
players[32], pnumtempid
    
get_players(playerspnum); 
     
    for( new 
ii<pnumi++ ) 
    { 
        
tempid players[i
        
get_user_name(tempidnames[i], 34
    } 



mottzi 07-17-2010 15:17

Re: Get the names of a Team in a String?
 
thats exactly the same thing xD

Quote:

Originally Posted by mottzi
so how can i convert the "names" variable to a string like: "name1 name2 name2 .. name32" ?


AngeIII 07-17-2010 15:29

Re: Get the names of a Team in a String?
 
get_user_name(tempid, names[i], 34)


this isn't same..


then if you want..

PHP Code:

public check()
{
   for(new 
ii<32;i++)
   {
     
server_print("name %d is %s",i,names[i]);
   }



wrecked_ 07-17-2010 16:31

Re: Get the names of a Team in a String?
 
It's not what he wants, but what he wants is extremely inefficient and not plausible.

Mottzi, just use an array.

Sylwester 07-17-2010 16:34

Re: Get the names of a Team in a String?
 
PHP Code:

new names[33][32]
new 
all_names[1024]

blabla(id)
{
    new 
players[32], pnumtempidpos;
    
get_players(playerspnum);

    for( new 
ii<pnumi++ )
    {
        
tempid players[i]
        
get_user_name(idnames[tempid], 31)
        
pos += formatex(all_names[pos], 1023-pos"%s "names[tempid])
    }



mottzi 07-18-2010 02:56

Re: Get the names of a Team in a String?
 
thanks, thats what i search!

PHP Code:

client_print(idprint_chatall_names

this woud work? and also when there arent 32 players?

Quote:

Originally Posted by wrecked_
It's not what he wants, but what he wants is extremely inefficient and not plausible.

Mottzi, just use an array.

but how to print every item of an array in one string?

wrecked_ 07-18-2010 03:19

Re: Get the names of a Team in a String?
 
Quote:

Originally Posted by mottzi (Post 1243080)
but how to print every item of an array in one string?

Use the example Sylwester posted.

Alucard^ 07-18-2010 08:25

Re: Get the names of a Team in a String?
 
PHP Code:

client_print(idprint_chatall_names

-->

PHP Code:

client_print(idprint_chat"%s"all_names


Sylwester 07-18-2010 09:49

Re: Get the names of a Team in a String?
 
There is no need to add "%s". In both cases, the effect will be the same.


All times are GMT -4. The time now is 07:11.

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