SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 13/08/2019, 11:02 AM   #1
Uberanwar
Gangsta
 
Uberanwar's Avatar
 
Join Date: May 2012
Location: Malaysia
Posts: 855
Reputation: 62
Default auto capital letter chat

How do I make auto capital letter chat? For instance, when some types like "hi, how are you? are you okay?" it will turn to "Hi, how are you? Are you okay?"
Uberanwar is offline   Reply With Quote
Old 13/08/2019, 11:17 AM   #2
YouShootIDodge
Little Clucker
 
Join Date: May 2019
Posts: 42
Reputation: 11
Default Re: auto capital letter chat

IDK if it works just made it up, test if it works:

Make an array of lowercase letters and uppercase with same sequence, example:

Code:
new lowercase_letters [5] = { 'a', 'b', 'c', 'd', 'e' };
new uppercase_letters [5] = { 'A', 'B', 'C', 'D', 'E' };

public OnPlayerText(playerid, text[])
{
    for (new i = 0; i < sizeof (lowercase_letters); i++) { if (text [0] == lowercase_letters [i]) {  [0] = uppercase_letters [i]; } }
    return 1;
}
Other is pretty much self-explainatory.
YouShootIDodge is offline   Reply With Quote
Old 13/08/2019, 11:41 AM   #3
NaS
High-roller
 
NaS's Avatar
 
Join Date: Mar 2008
Location: 🇩🇪
Posts: 1,641
Reputation: 541
Default Re: auto capital letter chat

Quote:
Originally Posted by YouShootIDodge View Post
IDK if it works just made it up, test if it works:

Make an array of lowercase letters and uppercase with same sequence, example:

Code:
new lowercase_letters [5] = { 'a', 'b', 'c', 'd', 'e' };
new uppercase_letters [5] = { 'A', 'B', 'C', 'D', 'E' };

public OnPlayerText(playerid, text[])
{
    for (new i = 0; i < sizeof (lowercase_letters); i++) { if (text [0] == lowercase_letters [i]) {  [0] = uppercase_letters [i]; } }
    return 1;
}
Other is pretty much self-explainatory.
Much simpler:

Code:
text[0] = toupper(text[0]);
And even if you wanted to code that manually, you can just do this:

Code:
if(text[0] >= 'a' && text[0] <= 'z') text[0] -= 32;
But I think that's not all OP wanted to know. If you want to make all sentences in the message start with a lower case character, you need to detect dots, exclamation marks and question marks and convert the letter after them to an uppercase letter. You could do that with a loop to find those, then the next character that's found should be converted like above.
NaS is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Auto Chat Wipe NaS Includes 1 02/10/2017 09:10 PM
Textdraw letter problem ("\")>this letter is making errors CoachCarter Scripting Help 2 27/08/2016 10:07 AM
Capital letter. Noliax8 Scripting Help 17 02/05/2013 12:45 PM
Non Roleplay Name - First letter and last letter of name must be capital! Eazy_Efolife Help Archive 11 03/09/2009 10:06 PM


All times are GMT. The time now is 04:26 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.