String 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: String uppercase (
/showthread.php?tid=614426)
String uppercase -
alex25alex - 08.08.2016
How to make string letters to be uppercase?
Код:
if(health == 1000) format(string,sizeof(string)," Health: IIIIIIIIII");
TextDrawSetString(HealthText[playerid], string);
All uppercase letter are transformed in lowercase letters. How to fix it?
Sorry for my bad english.
Re: String uppercase -
SyS - 08.08.2016
for converting all letters in string to lower
PHP код:
lower(str[])
{
for(new i = 0, n = strlen(str); i <n; i ++)
{
str[i] = tolower(str[i]);
}
return 1;
}
for converting all letters to upper
PHP код:
upper(str[])
{
for(new i = 0, n = strlen(str); i <n; i ++)
{
str[i] = toupper(str[i]);
}
return 1;
}
Re: String uppercase -
alex25alex - 08.08.2016
thanks
Re: String uppercase -
alex25alex - 08.08.2016
i tried that and it didn`t work.
Here is my code.
PHP код:
#include <a_samp>
#include <zcmd>
new Text:HealthText[MAX_PLAYERS];
new HealthTimer[MAX_PLAYERS];
public OnFilterScriptInit()
{
printf("Health System");
return 1;
}
public OnPlayerConnect(playerid)
{
HealthText[playerid] = TextDrawCreate(450.0, 375.0," ");
TextDrawHideForPlayer(playerid,HealthText[playerid]);
TextDrawAlignment(HealthText[playerid],0);
TextDrawSetProportional(HealthText[playerid],1);
TextDrawSetShadow(HealthText[playerid], 1);
TextDrawSetOutline(HealthText[playerid], 2);
TextDrawLetterSize(HealthText[playerid],0.60,2.0);
TextDrawFont(HealthText[playerid], 3);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(HealthText[playerid]);
return 1;
}
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
HealthTimer[playerid] = SetTimerEx("HealthDown", 1000, true, "i", playerid); // Healthdown timer
TextDrawShowForPlayer(playerid, HealthText[playerid]);
}
else
{
TextDrawHideForPlayer(playerid,HealthText[playerid]);
TextDrawSetString(HealthText[playerid], " ");
}
return 1;
}
forward HealthDown(playerid);
forward upper(str[]);
public HealthDown(playerid)
{
new string[128];
if(IsPlayerInAnyVehicle(playerid))
{
new Float:health;
new veh = GetPlayerVehicleID(playerid);
GetVehicleHealth(veh, health);
if(health == 1000) format(string,sizeof(string)," Health: IIIIIIIIII");
else if(health >= 900) format(string,sizeof(string),"~g~ Health: ~g~IIIIIIIII");
else if(health >= 800) format(string,sizeof(string),"~g~ Health: ~g~IIIIIIII");
else if(health >= 700) format(string,sizeof(string),"~g~ Health: ~y~IIIIIII");
else if(health >= 600) format(string,sizeof(string),"~g~ Health: ~y~IIIIII");
else if(health >= 500) format(string,sizeof(string),"~g~ Health: ~y~IIIII");
else if(health >= 400) format(string,sizeof(string),"~g~ Health: ~y~IIII");
else if(health >= 300) format(string,sizeof(string),"~g~ Health: ~r~III");
else if(health >= 200) format(string,sizeof(string),"~g~ Health: ~r~II");
else if(health >= 100) format(string,sizeof(string),"~g~ Health: ~r~I");
upper(string);
TextDrawSetString(HealthText[playerid], string);
}
else
{
format(string,sizeof(string),"~g~ Health: ~w~ ");
KillTimer(HealthTimer[playerid]);
}
}
public upper(str[])
{
for(new i = 0, n = strlen(str); i <n; i ++)
{
str[i] = toupper(str[i]);
}
return 1;
}
IIIIIIIIII is still iiiiiiiiii in game. Why?
Re: String uppercase -
Mencent - 08.08.2016
Hello.
Use font 1.

Font 3 are only lowercase.

(
https://sampwiki.blast.hk/wiki/TextDrawFont)
Re: String uppercase -
K0P - 08.08.2016
That is according to the text style you are using in the textdraw,forexample in iTD Editor you cannot use uppercase letters in pircedown text style,try using the Adir's TDE.
Re: String uppercase -
alex25alex - 08.08.2016
thank you very much man!
Re: String uppercase -
alex25alex - 08.08.2016
And how i can get a size for text to be proportional?