Raised This Month: $ Target: $400
 0% 

Making String from specific client strings


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 02-06-2013 , 10:13   Making String from specific client strings
Reply With Quote #1

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?
__________________
Kia is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-06-2013 , 21:48   Re: Making String from specific client strings
Reply With Quote #2

Loop through all players and add() only the strings of the team you want to your big string.
__________________
fysiks is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 02-14-2013 , 12:07   Re: Making String from specific client strings
Reply With Quote #3

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)
		}
		
	}
}
__________________

Last edited by Kia; 02-14-2013 at 13:22.
Kia is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-15-2013 , 02:05   Re: Making String from specific client strings
Reply With Quote #4

Quote:
Originally Posted by Kia View Post
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])
__________________
fysiks 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 20:33.


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