SA-MP Forums Archive
Chatbox replaces % with # - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: Chatbox replaces % with # (/showthread.php?tid=241772)



Chatbox replaces % with # - viKKmaN - 18.03.2011

Is there a reason why i write % and the chat-box shows # instead?


Re: Chatbox replaces % with # - Calgon - 18.03.2011

Yes, because '%' is the placeholder for variables. You can use '%%' to insert a literal percentage sign in format(), but you can't use it directly in chat.


Re: Chatbox replaces % with # - CJ101 - 18.03.2011

% is used with formatting messages. To avoid server crashing, The server replaces % with #.


Re: Chatbox replaces % with # - viKKmaN - 18.03.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
Yes, because '%' is the placeholder for variables. You can use '%%' to insert a literal percentage sign in format(), but you can't use it directly in chat.
I saw that I can use %% to insert literal % on the wiki, and I tried to replace any % in text[] under OnPlayerText() with str_replace("%","%%", text[]) but for some reason it didn't work...
PS: I am formating the player messages to insert [ID] after their name.
str_replace aquired from the wiki @ uf.inc


Re: Chatbox replaces % with # - Calgon - 18.03.2011

'%' isn't sent to the text variable, you could for example use str_replace to search for '[percentage]' and try replace it with a literal percentage sign.


Re: Chatbox replaces % with # - viKKmaN - 18.03.2011

I don't get your point? Isn't that what I said I tried above?


Re: Chatbox replaces % with # - Calgon - 18.03.2011

Read my post properly.

You cannot search for '%s' in text, as it will be '#', your code searches for '%' and NOT '[percentage]' (my suggestion).