First character - lower to Upper
#1

I want to make the first character of the first word to upper.
Something like a CAPS LOCK but then only for the first character of the first word.


3 Example:
I write this down: follow me
Message appears as: Follow me

I write this down: hacks OFF or ban!
Message appears as: Hacks OFF or ban!

I write this down: aaaaaaaaaaaaaaaa bbbbbb ccccccccccc
Message appears as: Aaaaaaaaaaaaaaaa bbbbbb ccccccccccc
Reply
#2

In Final GameMode
pawn Code:
forward UpperToLower(text[]);
public UpperToLower(text[])
{
    for(new Char ; Char < strlen(text) ; Char++)
    {
    if(text[Char] > 64 && text[Char] < 91)
    {
    text[Char] += 32;
    }
    }
    return 1;
}
Is OnPlayerText
pawn Code:
UpperToLower(text);
Reply
#3

pawn Code:
public OnPlayerText(playerid, text[])
{
  if(text[0] >= 97 && text[0] <= 122) text[0]-=32;
  return SendPlayerMessageToAll(playerid, text);
}
Edit to Drakon: For some weird reason lowerchase starts at 97, and upperchar at 65
Reply
#4

Ugh sorry I didn't mention this, But its for a command..

Code:
	if(text[0] == '&' && PlayerInfo[playerid][Level] >= 1) {
	    new string[128];
		format(string,sizeof(string),"Admin:   %s%s",string,text[1]); SendClientMessageToAll(green,string);
	    return 0;
	}
Reply
#5

lool jus put under OnPlayerText

Code:
text[0] = toupper(text[0]);
That will make the first char of the text / string to upper so if you do let say :

Ivex say: dsadasdad nnnddd

it will be

Ivex say: Dsadasdad nnnddd

etc ... else if you do for other chats than you put insteed of "text" you put string or result or what ever you got
Reply
#6

Nope still fails =\
Reply
#7

im sure this one that ****** said it working... epic ****** win... XD

just need to put ****** code and onplayertext

pawn Code:
text[0] = toupper(text[0]);
already tested... and works

EDIT: ****** please check your pm's
Reply
#8

If you want to implement it in the specific command that you posted, it would look like this.

pawn Code:
if(text[0] == '&' && PlayerInfo[playerid][Level] >= 1)
{
    new string[128];
    text[1] = toupper(text[1]);
    format(string,sizeof(string),"Admin: %s",text[1]); SendClientMessageToAll(green,string);
    return 0;
}
The other code didn't work because text[0] is not used at all in the string in your command.
Reply
#9

yep... anyways thanks


@offtopic and JaTochNietDan please visit this https://sampforum.blast.hk/showthread.php?tid=166896 no one tryng to help me... in a plugin
Reply
#10

*DELETED* (where is delete function? -.-)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)