Virgula menu HP / AMMOPACKS

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
User avatar
kerasseN
Membru, skill 0
Membru, skill 0
Posts: 53
Joined: 04 Feb 2020, 00:00
Detinator Steam: Nu
Fond eXtream: 0
Has thanked: 1 time

02 Feb 2021, 15:54

Code: Select all

public ShowHUD(taskid)
{
	static id
	id = ID_SHOWHUD;
	
	// Player died?
	if (!g_isalive[id])
	{
		// Get spectating target
		id = pev(id, PEV_SPEC_TARGET)
		
		// Target not alive
		if (!g_isalive[id]) return;
	}
	
	// Format classname
	static class[32], red, green, blue
	
	if (g_zombie[id]) // zombies
	{
		red = 255
		green = 0
		blue = 0
		
		if (g_nemesis[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_NEMESIS")
		else if (g_assassin[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_ASSASSIN")
		else
			copy(class, charsmax(class), g_zombie_classname[id])
	}
	else // humans
	{
		red = 255
		green = 0
		blue = 0
		
		if (g_survivor[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SURVIVOR")
		else if (g_sniper[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SNIPER")
		else
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_HUMAN")
	}
	
	// Spectating someone else?
	if (id != ID_SHOWHUD)
	{
		// Show name, mode, health, class and ammo packs
		set_hudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
		ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "[ %L %s | Mode: %s ]^n[ HP: %d | %L %s | %L %d | %L %d ]", ID_SHOWHUD, "SPECTATING", g_playername[id], g_mode_names[g_currentmode], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
	}
	else
	{
		// Show health, class and ammo packs
		switch(get_pcvar_num(cvar_huddisplaytype))
		{
			case 1:
			{
				set_hudmessage(red, green, blue, 0.02, 0.9, 0, 0.1, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "[ %L: %d | %L %s | %L %d | %L: %d ]", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
			}

			case 2:
			{
				set_dhudmessage(random_num(0, 0), random_num(255, 0), random_num(0, 0), -1.0, -0.06, 0, 6.0, 1.1, 0.0, 0.0)
				show_dhudmessage(ID_SHOWHUD, "%L: %d | %L %s | %L %d | %L: %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
			}
		}
	}
}
am incercat sa fac singur, dar e %s pentru alti ,iar la mine e %d .. nu prea am idee..
RoyalServer
lexz
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 918
Joined: 02 Nov 2020, 01:57
Detinator Steam: Da
Fond eXtream: 0
Discord: lexzor#0630
Has thanked: 71 times
Been thanked: 136 times

02 Feb 2021, 16:59

?? care e problema? ne-ai dat o bucata de cod careia nu-i putem da compile sa vedem erorile, nu ai spus exact care e problema, nu ai precizat daca variabilele de acolo sunt de tip string sau integer :-s
User avatar
kerasseN
Membru, skill 0
Membru, skill 0
Posts: 53
Joined: 04 Feb 2020, 00:00
Detinator Steam: Nu
Fond eXtream: 0
Has thanked: 1 time

02 Feb 2021, 17:04

bro, nu trebuie sa dai complie la nimic, eu vreau sa pun virgula dupa mii , zeci de mii, sute de mii etc... am folosit

Code: Select all

public AddCommas( iNum , szOutput[] , iLen )
{
    new szTmp[ 15 ] , iOutputPos , iNumPos , iNumLen;
    
    if ( iNum < 0 )
    {
        szOutput[ iOutputPos++ ] = '-';
        iNum = abs( iNum );
    }
    
    iNumLen = num_to_str( iNum , szTmp , charsmax( szTmp ) );

    if ( iNumLen <= 3 )
    {
        iOutputPos += copy( szOutput[ iOutputPos ] , iLen , szTmp );
    }
    else
    {
        while ( ( iNumPos < iNumLen ) && ( iOutputPos < iLen ) ) 
        {
            szOutput[ iOutputPos++ ] = szTmp[ iNumPos++ ];
        
            if( ( iNumLen - iNumPos ) && !( ( iNumLen - iNumPos ) % 3 ) ) 
                szOutput[ iOutputPos++ ] = ',';
        }
        
        szOutput[ iOutputPos ] = EOS;
    }
    
    return iOutputPos;
}

dar problema e ca eu am fix pe dos fata de cum au altii prescurtarea %s la mine e -> %d

Vezi ?

Code: Select all

show_dhudmessage(ID_SHOWHUD, "%L: %d | %L %s | %L %d | %L: %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
lexz
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 918
Joined: 02 Nov 2020, 01:57
Detinator Steam: Da
Fond eXtream: 0
Discord: lexzor#0630
Has thanked: 71 times
Been thanked: 136 times

02 Feb 2021, 17:34

daca ai %s inseamna ca e de tip string si tu vrei %d deci integer, foloseste str_to_num pentru variabilele string si dupa le poti afisa cu %d
User avatar
kerasseN
Membru, skill 0
Membru, skill 0
Posts: 53
Joined: 04 Feb 2020, 00:00
Detinator Steam: Nu
Fond eXtream: 0
Has thanked: 1 time

02 Feb 2021, 19:23

nu reusesc, imi poti da tu direct? :(


Eu am facut asa

Code: Select all

public ShowHUD(taskid)
{
	static id
	id = ID_SHOWHUD;
	
	// Player died?
	if (!g_isalive[id])
	{
		// Get spectating target
		id = pev(id, PEV_SPEC_TARGET)
		
		// Target not alive
		if (!g_isalive[id]) return;
	}
	
	// Format classname
	static class[32], red, green, blue
	
	if (g_zombie[id]) // zombies
	{
		red = 255
		green = 0
		blue = 0
		
		if (g_nemesis[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_NEMESIS")
		else if (g_assassin[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_ASSASSIN")
		else
			copy(class, charsmax(class), g_zombie_classname[id])
	}
	else // humans
	{
		red = 255
		green = 0
		blue = 0
		
		if (g_survivor[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SURVIVOR")
		else if (g_sniper[id])
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_SNIPER")
		else
			formatex(class, charsmax(class), "%L", ID_SHOWHUD, "CLASS_HUMAN")
	}
	
	// Spectating someone else?
	if (id != ID_SHOWHUD)
	{
		// Show name, mode, health, class and ammo packs
		set_hudmessage(255, 255, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
		ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "[ %L %s | Mode: %s ]^n[ HP: %d | %L %s | %L %d | %L %d ]", ID_SHOWHUD, "SPECTATING", g_playername[id], g_mode_names[g_currentmode], pev(id, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[id], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
	}
	else
	{
		// Show health, class and ammo packs
		switch(get_pcvar_num(cvar_huddisplaytype))
		{
			case 1:
			{
				set_hudmessage(red, green, blue, 0.02, 0.9, 0, 0.1, 1.1, 0.0, 0.0, -1)
				ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "[ %L: %d | %L %s | %L %d | %L: %d ]", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
			}

			case 2:
			{
				new szHP[ 15 ], szAP[ 15 ], szArmor[ 15 ]
				AddCommas(pev(ID_SHOWHUD, pev_health), szHP, charsmax(szHP))
				AddCommas(g_ammopacks[ID_SHOWHUD], szAP, charsmax(szAP))
				AddCommas(pev(ID_SHOWHUD, pev_armorvalue), szArmor, charsmax(szArmor))
				
				// Show health, class and ammo packs and armor
				set_dhudmessage(random_num(0, 0), random_num(255, 0), random_num(0, 0), -1.0, -0.06, 0, 6.0, 1.1, 0.0, 0.0)
				show_dhudmessage(ID_SHOWHUD, "%L: %d | %L %s | %L %d | %L: %d", id, "ZOMBIE_ATTRIB1", pev(ID_SHOWHUD, pev_health), ID_SHOWHUD, "CLASS_CLASS", class, ID_SHOWHUD, "AMMO_PACKS1", g_ammopacks[ID_SHOWHUD], ID_SHOWHUD, "ARMOR", pev(id, pev_armorvalue))
			}
		}
	}
}

// Virgula
public AddCommas( iNum , szOutput[] , iLen )
{
    new szTmp[ 15 ] , iOutputPos , iNumPos , iNumLen;
    
    if ( iNum < 0 )
    {
        szOutput[ iOutputPos++ ] = '-';
        iNum = abs( iNum );
    }
    
    iNumLen = str_to_num( iNum , szTmp , charsmax( szTmp ) );

    if ( iNumLen <= 3 )
    {
        iOutputPos += copy( szOutput[ iOutputPos ] , iLen , szTmp );
    }
    else
    {
        while ( ( iNumPos < iNumLen ) && ( iOutputPos < iLen ) ) 
        {
            szOutput[ iOutputPos++ ] = szTmp[ iNumPos++ ];
        
            if( ( iNumLen - iNumPos ) && !( ( iNumLen - iNumPos ) % 3 ) ) 
                szOutput[ iOutputPos++ ] = ',';
        }
        
        szOutput[ iOutputPos ] = EOS;
    }
    
    return iOutputPos;
}
User avatar
kidd0x
Utilizator neserios (tepar)
Utilizator neserios (tepar)
Posts: 1054
Joined: 06 Oct 2018, 14:41
Detinator Steam: Da
SteamID: /id/kidd0x/
Reputatie: Utilizator neserios (tepar!)
Fond eXtream: 0
Location: Constangeles
Discord: kidd0x
Has thanked: 172 times
Been thanked: 81 times

02 Feb 2021, 21:22

lexz wrote:
02 Feb 2021, 17:34
daca ai %s inseamna ca e de tip string si tu vrei %d deci integer, foloseste str_to_num pentru variabilele string si dupa le poti afisa cu %d
pentru acea "virgula" se foloseste %s

Uite un exemplu foarte usor

Code: Select all

public Fw_TakeDamage_Post(iVictim, iInflictor, iAttacker, Float:fDamage, bitsDamageType)
{
    if (get_member(iAttacker, m_iTeam) == TEAM_CT && get_member(iVictim, m_iTeam) == TEAM_TERRORIST)
	{
		if (get_pcvar_num(cvar_enable_commas) == 1)
		{
			new szHealth[15];
			AddCommas(get_user_health(iVictim), szHealth, charsmax(szHealth))
			client_print(iAttacker, print_center,"HP: %s", szHealth)
		}
		else
		{
			client_print(iAttacker, print_center,"HP: %i", get_user_health(iVictim))
		}
	}
}
User avatar
Rainq
Membru, skill +2
Membru, skill +2
Posts: 681
Joined: 21 Jul 2015, 19:50
Detinator Steam: Da
CS Status: Retras
Detinator server CS: zm.extreamcs.com
SteamID: mrainq
Reputatie: Fost super moderator
Fost detinator ZM.eXtreamCS.COM
Fost Membru Club eXtreamCS (trei luni)
Fond eXtream: 0
Location: Bucharest
Discord: manuraiders
Has thanked: 29 times
Been thanked: 51 times
Contact:

02 Feb 2021, 21:27

sau alt exemplu

Code: Select all

public ShowHUD(taskid) {
	new Player = ID_SHOWHUD;
	new g_pClass[32];

	if(!g_isalive[Player]) {
		Player = pev(Player, PEV_SPEC_TARGET);
		if(!g_isalive[Player])	return;
	}

	if(g_zombie[Player]) {
		if(g_nemesis[Player])
			formatex(g_pClass, charsmax(g_pClass), "Nemesis");
		if(g_assassin[Player])
			formatex(g_pClass, charsmax(g_pClass), "Assassin");
		if(!g_assassin[Player] && !g_nemesis[Player])
			copy(g_pClass, charsmax(g_pClass), g_zombie_classname[Player]);
	}
	else
	{
		if(g_survivor[Player])
			formatex(g_pClass, charsmax(g_pClass), "Survivor");
		if(g_sniper[Player])
			formatex(g_pClass, charsmax(g_pClass), "Sniper");
		if(!g_survivor[Player] && !g_sniper[Player])
			formatex(g_pClass, charsmax(g_pClass), "Human");
	}

	new strPacks[16], strHealth[16], strPoints[16];
	new strIP[16], strCountry[32], strCity[32];

	if(Player != ID_SHOWHUD) {
		AddCommas(g_ammopacks[Player], strPacks, charsmax(strPacks));
		AddCommas(get_user_health(Player), strHealth, charsmax(strHealth));
		AddCommas(iPoints[Player], strPoints, charsmax(strPoints));

		get_user_ip(Player, strIP, charsmax(strIP), 1);
		geoip_country(strIP, strCountry, charsmax(strCountry));
		geoip_city(strIP, strCity, charsmax(strCity));

		strCountry = equal(strCountry, "error") ? "N/A" : strCountry;
		strCity = equal(strCity, "error") ? "N/A": strCity;
	
		set_hudmessage(0, 127, 255, HUD_SPECT_X, HUD_SPECT_Y, 1, 6.0, 1.1, 0.0, 0.0, -1)
		ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%s Spectating: %s^n%s HP: %s AP: %d Packs: %s Points: %s^n%s, %s", (zv_get_user_flags(Player) & ZV_UNLIMITED) ? "(Gold Member®)" : "", g_playername[Player], g_pClass, strHealth, get_user_armor(Player), strPacks, strPoints, strCountry, strCity);
	}
	else {
		AddCommas(g_ammopacks[ID_SHOWHUD], strPacks, charsmax(strPacks));
		AddCommas(get_user_health(ID_SHOWHUD), strHealth, charsmax(strHealth));
		AddCommas(iPoints[ID_SHOWHUD], strPoints, charsmax(strPoints));

		new strFrost[64];
		formatex(strFrost, charsmax(strFrost), "(Press T to freeze human)");

		set_hudmessage(0, 127, 255, HUD_STATS_X, HUD_STATS_Y, 0, 6.0, 1.1, 0.0, 0.0, -1)
		ShowSyncHudMsg(ID_SHOWHUD, g_MsgSync2, "%s | Health: %s Armor %d Packs %s Points %s^n%s", g_pClass, strHealth, get_user_armor(ID_SHOWHUD), strPacks, strPoints, g_nemesis[ID_SHOWHUD] ? strFrost : "");
	}
}
ignora ce nu are treaba
Image
User avatar
kerasseN
Membru, skill 0
Membru, skill 0
Posts: 53
Joined: 04 Feb 2020, 00:00
Detinator Steam: Nu
Fond eXtream: 0
Has thanked: 1 time

02 Feb 2021, 21:47

Pai la mine e %d nu %s ... nu se vede?
User avatar
Rainq
Membru, skill +2
Membru, skill +2
Posts: 681
Joined: 21 Jul 2015, 19:50
Detinator Steam: Da
CS Status: Retras
Detinator server CS: zm.extreamcs.com
SteamID: mrainq
Reputatie: Fost super moderator
Fost detinator ZM.eXtreamCS.COM
Fost Membru Club eXtreamCS (trei luni)
Fond eXtream: 0
Location: Bucharest
Discord: manuraiders
Has thanked: 29 times
Been thanked: 51 times
Contact:

02 Feb 2021, 21:50

kerasseN wrote:
02 Feb 2021, 21:47
Pai la mine e %d nu %s ... nu se vede?

Code: Select all

AddCommas(iNum, szOutput[], iLen) {
	static Tmp[15], Pos, Num, Len;
	Tmp[0] = '^0', Pos = Num = Len = 0;

	if(iNum < 0) {
		szOutput[Pos++] = '-';
		iNum = abs(iNum);
	}

	Len = num_to_str(iNum, Tmp, charsmax(Tmp));
	if(Len <=3)
		Pos += copy(szOutput[Pos], iLen, Tmp);
	else {
		while((Num < Len) && (Pos < iLen)) {
			szOutput[Pos++] = Tmp[Num++];
			if((Len - Num) && !((Len - Num) % 3))
				szOutput[Pos++] = ',';
		}

		szOutput[Pos] = EOS;
	}
Image
User avatar
kerasseN
Membru, skill 0
Membru, skill 0
Posts: 53
Joined: 04 Feb 2020, 00:00
Detinator Steam: Nu
Fond eXtream: 0
Has thanked: 1 time

02 Feb 2021, 22:03

nu merge
User avatar
Rainq
Membru, skill +2
Membru, skill +2
Posts: 681
Joined: 21 Jul 2015, 19:50
Detinator Steam: Da
CS Status: Retras
Detinator server CS: zm.extreamcs.com
SteamID: mrainq
Reputatie: Fost super moderator
Fost detinator ZM.eXtreamCS.COM
Fost Membru Club eXtreamCS (trei luni)
Fond eXtream: 0
Location: Bucharest
Discord: manuraiders
Has thanked: 29 times
Been thanked: 51 times
Contact:

02 Feb 2021, 22:04

kerasseN wrote:
02 Feb 2021, 22:03
nu merge

Code: Select all

AddCommas(iNum, szOutput[], iLen) {
	static Tmp[15], Pos, Num, Len;
	Tmp[0] = '^0', Pos = Num = Len = 0;

	if(iNum < 0) {
		szOutput[Pos++] = '-';
		iNum = abs(iNum);
	}

	Len = num_to_str(iNum, Tmp, charsmax(Tmp));
	if(Len <=3)
		Pos += copy(szOutput[Pos], iLen, Tmp);
	else {
		while((Num < Len) && (Pos < iLen)) {
			szOutput[Pos++] = Tmp[Num++];
			if((Len - Num) && !((Len - Num) % 3))
				szOutput[Pos++] = ',';
		}

		szOutput[Pos] = EOS;
	}

	return Pos;
}
Image
User avatar
kerasseN
Membru, skill 0
Membru, skill 0
Posts: 53
Joined: 04 Feb 2020, 00:00
Detinator Steam: Nu
Fond eXtream: 0
Has thanked: 1 time

02 Feb 2021, 22:13

am pus si eu } la final daca doar aia ai facut, am incercat iar si tot nu merge
Post Reply

Return to “Cereri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 32 guests