Lowercase to Uppercase - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lowercase to Uppercase (
/showthread.php?tid=461035)
Lowercase to Uppercase -
JaKe Elite - 31.08.2013
Okay, Most of users look for "Uppercase to Lowercase"
Now i'm doing opposite, I'm looking for "Lowercase to Uppercase"
I cannot find one i search everywhere, All i can find is Uppercase to Lowercase.
So how can i do this?
Re: Lowercase to Uppercase -
doreto - 31.08.2013
Toupper
Re: Lowercase to Uppercase -
Misiur - 31.08.2013
pawn Код:
stock strToUpper(string[]) {
new
i = 0;
while(EOS != string[i]) {
if('a' <= string[i] <= 'z') string[i] -= 32;
++i;
}
}
Re: Lowercase to Uppercase -
[HiC]TheKiller - 31.08.2013
You can either just minus 32 of the ASCII value per character or use
https://sampwiki.blast.hk/wiki/Toupper
pawn Код:
new string[10] = "potato", id;
while(string[id] != EOS)
{
string[id] = toupper(string[id]);
id++;
}
Re: Lowercase to Uppercase -
JaKe Elite - 31.08.2013
Misiur that didn't work, It returns my name instead of the parameter.
pawn Код:
format(string, sizeof(string), "[POLICE MEGAPHONE] %s(%d): %s", GetName(playerid), playerid, UpperWord(params));
Returns:
Код:
[POLICE MEGAPHONE]: Jake_Hero(0): Jake_Hero
instead of
[POLICE MEGAPHONE]: Jake_Hero(0): HEY STOP NOW
Re: Lowercase to Uppercase -
Misiur - 31.08.2013
The function shouldn't return anything. Try
pawn Код:
format(string, sizeof(string), "[POLICE MEGAPHONE] %s(%d): %s", GetName(playerid), playerid, (UpperWord(params), params));
Re: Lowercase to Uppercase -
JaKe Elite - 31.08.2013
Misiur works now thanks, anyway [HiC]TheKiller i try your code and compile it in a blank script it gives error but nvm then.
Re: Lowercase to Uppercase -
Misiur - 31.08.2013
I don't remember if there's any performance diffrence, but if you don't want to use this comma thingy, you should be able to just add return to the stock
pawn Код:
stock UpperWord(string[]) {
new
i = 0;
while(EOS != string[i]) {
if('a' <= string[i] <= 'z') string[i] -= 32;
++i;
}
return string;
}