AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Making String from specific client strings (https://forums.alliedmods.net/showthread.php?t=207746)

Kia 02-06-2013 10:13

Making String from specific client strings
 
Hello everybody,

In my code here everybody is making a String for a HUD Message.
Code:

new pHUD[33][512]
.
.
.
for(new i = 1 ; i <= maxplayers ; i++)
        {
                if(is_user_alive(i) && get_user_team(i == 1))
                {
                      formatex(pHUD[i],512,"%s^n%s^n%i^n",Info1[i],Info2[i],Info3[i])
                      .
                      .
                      .
                }
        }

So now I want a String with includes all the strings from the terror team (1) and display them.

Code:

new gHUD[4096]
.
.
.
set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 0.1)
show_hudmessage(0, "%s",gHUD)

This is only working when all selected Strings are Terror, but this is very ugly to use :

Code:

//formatex(gHUD[0],4096,"%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n%s^n",pHUD[1],pHUD[2],pHUD[3],pHUD[4],pHUD[5],pHUD[6],pHUD[7],pHUD[8],pHUD[9],pHUD[10],pHUD[11],pHUD[12],pHUD[13],pHUD[14],pHUD[15],pHUD[16])
Anyone has an idea how to solve my problem?

fysiks 02-06-2013 21:48

Re: Making String from specific client strings
 
Loop through all players and add() only the strings of the team you want to your big string.

Kia 02-14-2013 12:07

Re: Making String from specific client strings
 
How do I do this?
This Code only shows one players String :

Code:

public GameHUD_T()
{
        for(new i = 1 ; i <= maxplayers ; i++)
        {
                if(is_user_alive(i) && get_user_team(i == 1))
                {
                        g_iUserID[i] = get_user_userid(i)
                       
                        new pName[34]
                        get_user_name(i,pName[i],33)
                       
                        gHUD_T[0] = EOS
                       
                        formatex(pHUD[g_iUserID[i]],512,"%s^n%s^n%i^n",pName[i],get_user_weapon2(i),get_user_health(i))
                        formatex(gHUD_T[0],4096,"%s^n%s^n",gHUD_T,pHUD[g_iUserID[i]])
                       
                        set_hudmessage(255, 0, 0, 0.0, 0.0, 0, 6.0, 0.1)
                        show_hudmessage(0, "%s",gHUD_T)
                }
               
        }
}


fysiks 02-15-2013 02:05

Re: Making String from specific client strings
 
Quote:

Originally Posted by Kia (Post 1894267)
How do I do this?
This Code only shows one players String :

By using the add() function as I stated before. You were much much closer in your first post. You can't index an array with a "userid".

So, in the code of your first post, you just need to add:

Code:

add(gHUD, charsmax(gHUD), pHUD[i])


All times are GMT -4. The time now is 20:33.

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