Raised This Month: $120 Target: $400
 30% 

% in string text


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
NeXoU
Junior Member
Join Date: Jan 2014
Location: France
Old 07-21-2015 , 10:12   % in string text
Reply With Quote #1

Hello,

How can i display "%" in text, when i write % in text with Format, % does not appear.

PHP Code:
Format(testsizeof(test), "%d%"Pourcentage); // Don't work
Format(testsizeof(test), "%d\%"Pourcentage); // Don't work 
Thanks in advance
NeXoU is offline
Icetea16
Member
Join Date: Jul 2015
Location: France
Old 07-21-2015 , 10:24   Re: % in string text
Reply With Quote #2

Tien :

PHP Code:
#include <sdktools>

#define pourcent '%'

public Action OnClientPreAdminCheck(int client)
{
    
CreateTimer(5.0timer_TIMER_REPEAT);
}

public 
Action timer(Handle timer)
{
    
PrintToChatAll(" 5 %s"pourcent);

__________________
I'm French, sorry for my bad english...
Icetea16 is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 07-21-2015 , 10:27   Re: % in string text
Reply With Quote #3

%%
Miu is offline
NeXoU
Junior Member
Join Date: Jan 2014
Location: France
Old 07-21-2015 , 10:33   Re: % in string text
Reply With Quote #4

Quote:
Originally Posted by Icetea16 View Post
Tien :

PHP Code:
#include <sdktools>

#define pourcent '%'

public Action OnClientPreAdminCheck(int client)
{
    
CreateTimer(5.0timer_TIMER_REPEAT);
}

public 
Action timer(Handle timer)
{
    
PrintToChatAll(" 5 %s"pourcent);

--> Don't work

Quote:
Originally Posted by Miu View Post
%%
--> Don't work

It's for Menu & Hud.

Thanks in advance

Last edited by NeXoU; 07-21-2015 at 10:37.
NeXoU is offline
Icetea16
Member
Join Date: Jul 2015
Location: France
Old 07-21-2015 , 10:45   Re: % in string text
Reply With Quote #5

Sa fonctionne

PHP Code:
#include <sdktools>

#pragma newdecls required

#define pourcent '%'

public Action OnClientPreAdminCheck(int client)
{
    
CreateTimer(5.0timerclientTIMER_REPEAT);
}

public 
Action timer(Handle timerany client)
{
    
char sText[64];
    
Format(sTextsizeof(sText), "5 %s"pourcent);
    
PrintToChatAll(sText);
    
    
Menu menu = new Menu(Menu_Test);
    
menu.SetTitle("titre");
    
menu.AddItem(""sText);
    
menu.ExitButton true;
    
menu.Display(client0);
}

public 
int Menu_Test(Menu menuMenuAction actionint clientint item)
{
    if (
action == MenuAction_Select)
    {
        
delete menu;
    }
    else if (
action == MenuAction_End)
    {
        
delete menu;
    }

Screenshot:

http://www.noelshack.com/2015-30-143...7-21-00002.jpg
Attached Images
File Type: jpeg bloggif_55ae4ce39e29d.jpeg (15.8 KB, 37 views)
__________________
I'm French, sorry for my bad english...

Last edited by Icetea16; 07-21-2015 at 10:47.
Icetea16 is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 07-21-2015 , 10:52   Re: % in string text
Reply With Quote #6

This was mentioned here many times. The right answer is %%.

Always when the string is formated (Format, FormatEx, PrintTo* functions etc.) it converts %% to %.
So, if you format your string twice, you need to use %%%% - first format output is %% and second format output is %.
KissLick is offline
Icetea16
Member
Join Date: Jul 2015
Location: France
Old 07-21-2015 , 10:55   Re: % in string text
Reply With Quote #7

Ok, good explanation.

I did not know
__________________
I'm French, sorry for my bad english...

Last edited by Icetea16; 07-21-2015 at 10:55.
Icetea16 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 07-21-2015 , 11:01   Re: % in string text
Reply With Quote #8

If you need to print text that you've already formatted, pass it as a String argument to a format-class function.

For example:

Code:
char myString[32];
Format(myString, sizeof(myString), "%s", "5%");
PrintToChatAll("%s", myString);
This example is really contrived, but there are other reasons to do it. I ended up fixing a bug in colors.inc that was doing double formatting this way.
__________________
Am I back? Well, we'll see.
Powerlord is offline
NeXoU
Junior Member
Join Date: Jan 2014
Location: France
Old 07-21-2015 , 11:02   Re: % in string text
Reply With Quote #9

Quote:
Format(BarreAnime[client], 64, "▄▄▄▄▄▄▄▄▄▄\n%d %%", Pourcentage);
I don't now why but it does not work

Thanks in advance
NeXoU is offline
NeXoU
Junior Member
Join Date: Jan 2014
Location: France
Old 07-21-2015 , 20:05   Re: % in string text
Reply With Quote #10

It's fix.
Thank to all.
NeXoU is offline
Reply


Thread Tools
Display Modes

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 23:37.


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