AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Fix Code (https://forums.alliedmods.net/showthread.php?t=299611)

DarthMan 07-20-2017 04:03

[ H3LP ] Fix Code
 
Hello. I noticed that if I want to show a hud, for example, that contains more lines and I put ^n after the %% the "%" wll not be displayed in the hud. Any way to fix that? If I don't use ^n then it works fine, but ti will show everything on the same line. Thanks !

PRoSToTeM@ 07-20-2017 04:37

Re: [ H3LP ] Use %% if ^n
 
Give an example please, because it works good for me.

DarthMan 07-20-2017 04:41

Re: [ H3LP ] Use %% if ^n
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2536523)
Give an example please, because it works good for me.

For example if I use formatex : formatex(sBuffer, charsmax(sBuffer), "%%^n"), it will not display the %.

DarthMan 07-20-2017 05:11

Re: [ H3LP ] Use %% if ^n
 
Fixed by using %% twice. (%%%%)

klippy 07-20-2017 05:13

Re: [ H3LP ] Use %% if ^n
 
I almost feel like you are double formatting (which can be a security hole too!). Better show your code.

DarthMan 07-20-2017 05:23

Re: [ H3LP ] Use %% if ^n
 
Quote:

Originally Posted by KliPPy (Post 2536527)
I almost feel like you are double formatting (which can be a security hole too!). Better show your code.

That's what I did.

Code:
formatex(sBuffer, charsmax(sBuffer), "%s. %s - %d%%%%^n", map_position[i], szTemp, iHealth) add( buff, charsmax( buff ), sBuffer )

It adds each on a new line.

PRoSToTeM@ 07-20-2017 06:58

Re: [ H3LP ] Use %% if ^n
 
Show the part of code with show_hudmessage.

DarthMan 07-20-2017 07:02

Re: [ H3LP ] Use %% if ^n
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2536536)
Show the part of code with show_hudmessage.

Code:
public mapvote_hud(taskid) {     if(!PLAYERS_CONNECTED)         return;         new i_Ent = -1, x_Ent = -1, iArray[MAXSHOW];     new Float:fCurrHealth, iHealth, iCount;     new buff[1024], szList[1024];         for(new i = 0, j; i < EXISTED_PANELS; i++)     {         if(iCount >= MAXSHOW)         {             break;         }                 i_Ent = PANELS[i];                 if(!pev_valid(i_Ent))             continue;                 iHealth = pev(i_Ent, pev_health, fCurrHealth);                 if(fCurrHealth >= MAX_PANEL_HEALTH)             continue;                 iArray[iCount] = i_Ent;                 for(j = i+1; j < EXISTED_PANELS; j++)         {             x_Ent = PANELS[j];                         if(pev(i_Ent, pev_health) > pev(x_Ent, pev_health))             {                 iArray[iCount] = x_Ent;             }         }                 iCount ++;     }         if(!iCount)         return;         new sBuffer[500], szTemp[32];         for(new i; i < iCount; i++)     {         x_Ent = iArray[i]                 pev(x_Ent, pev_targetname, szTemp, charsmax(szTemp))         pev(x_Ent, pev_health, fCurrHealth)                 iHealth = floatround((fCurrHealth / MAX_PANEL_HEALTH) * 100)         formatex(sBuffer, charsmax(sBuffer), "%s. %s - %d%%^n", map_position[i], szTemp, iHealth)         add( buff, charsmax( buff ), sBuffer )     }         formatex(szList, charsmax(szList), "Vote Results:^n%s", buff)         set_hudmessage(255, 255, 255, 0.80, 0.05, 0, 0.0, 0.2, 0.0, 0.0, 4)     show_hudmessage(0,  "%s", szList) }

Maybe you can fix the sorting :)

PRoSToTeM@ 07-20-2017 07:09

Re: [ H3LP ] Use %% if ^n
 
Code:
show_hudmessage(0, szList)
->
Code:
show_hudmessage(0, "%s", szList)

DarthMan 07-20-2017 07:13

Re: [ H3LP ] Use %% if ^n
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2536540)
Code:
show_hudmessage(0, szList)
->
Code:
show_hudmessage(0, "%s", szList)

Now it works with %%, but cold u fix the sorting?


All times are GMT -4. The time now is 23:03.

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