AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   percent symbol (https://forums.alliedmods.net/showthread.php?t=308539)

orel56000 06-24-2018 14:10

percent symbol
 
Hello, before the last cs update percent symbol used to be working with "%%%", and now its don't working. any suggestions?

fysiks 06-24-2018 14:25

Re: percent symbol
 
In what context? If you are formatting a string and you want to show a % then you need to escape it with a %. So, "%%" will give you "%". I'm not sure why you are showing three, that doesn't make sense.

orel56000 06-24-2018 14:37

Re: percent symbol
 
Quote:

Originally Posted by fysiks (Post 2599110)
In what context? If you are formatting a string and you want to show a % then you need to escape it with a %. So, "%%" will give you "%". I'm not sure why you are showing three, that doesn't make sense.

because before the 2017 update only %%% worked for me, and now nothing is woking for me.. idk why, I have tried %% and %%% and "%s", "%" and even "%s", "%%".
and nothing works..

orel56000 06-24-2018 14:47

Re: percent symbol
 
I have checked now and if I do this:
PHP Code:

formatex(str2sizeof(str2), "(%s+%i%%^1)"rand 34 ? (won == ? ("^4") : ("")) : ("^1"), percentBonus); 

its now working and prints only the %i, like this (+7 ).

but if I'm doing this:
PHP Code:

ColorChat(0"%%"); 

it is working (prints %).


how to fix it?

fysiks 06-24-2018 16:38

Re: percent symbol
 
Does it happen if you don't use colored chat (i.e. use client_print() without any color-based formatting)? If it works without colored chat, there is probably a problem with the colored chat function you are using.

orel56000 06-24-2018 16:47

Re: percent symbol
 
Quote:

Originally Posted by fysiks (Post 2599127)
Does it happen if you don't use colored chat (i.e. use client_print() without any color-based formatting)? If it works without colored chat, there is probably a problem with the colored chat function you are using.

No, its the same..
maybe there is a problem with my code?:
PHP Code:

new str[256], str2[16];
formatex(str2sizeof(str2), "(%s+%i%%^1)"rand 34 ? (won == ? ("^4") : ("")) : ("^1"), percentBonus);
formatex(strsizeof(str), ", total cash - %s"AddCommas(cash));
for(new 
133i++)if(is_user_loggedin(i))
        
ColorChat(i"^3%s ^1has gambled%s on %s and %s%s%s",GetName(client), allin == 1? ("^4 allin^1") : (""), AddCommas(amount), won == ? ("Won"): ("Lost"),percentBonus ? (str2) : (""), totalcash[client] == ? (".") : (str)); 
    return 
1


fysiks 06-24-2018 17:04

Re: percent symbol
 
Are you using the latest official release of AMX Mod X (v1.8.2)? If you are using the current dev beta, try using the official release instead and see if that changes.

What if you print only str2? does it show the % correctly there? Try this:

Code:

ColorChat(0, "(%s+%i%%^1)", rand > 34 ? (won == 1 ? ("^4") : ("")) : ("^1"), percentBonus)

E1_531G 06-24-2018 17:05

Re: percent symbol
 
Try this method:
Quote:

formatex( string, len, "%s+%i%c^1", text, int, '%' )

orel56000 06-24-2018 17:22

Re: percent symbol
 
Quote:

Originally Posted by fysiks (Post 2599134)
Are you using the latest official release of AMX Mod X (v1.8.2)? If you are using the current dev beta, try using the official release instead and see if that changes.

What if you print only str2? does it show the % correctly there? Try this:

Code:

ColorChat(0, "(%s+%i%%^1)", rand > 34 ? (won == 1 ? ("^4") : ("")) : ("^1"), percentBonus)

Quote:

Originally Posted by E1_531G (Post 2599135)
Try this method:

Yes, I'm using AMX Mod X v 1.8.2.

That the result from both suggestions:

PHP Code:

E1_531G Player has gambled on 300 and Lost(+).
fysiks - (+7


fysiks 06-24-2018 21:50

Re: percent symbol
 
Try writing str2 to a file and then attach the file to your next post (don't edit or change it in any way before attaching it).


All times are GMT -4. The time now is 06:12.

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