String uppercase
#1

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.
Reply
#2

for converting all letters in string to lower
PHP код:
lower(str[])
{
for(new 
0strlen(str); <n++)
    {
        
str[i] = tolower(str[i]);
    }
    return 
1;

for converting all letters to upper
PHP код:
upper(str[])
{
for(new 
0strlen(str); <n++)
    {
        
str[i] = toupper(str[i]);
    }
    return 
1;

Reply
#3

thanks
Reply
#4

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.0375.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(playeridreason)
{
    
TextDrawDestroy(HealthText[playerid]);
    return 
1;
}
public 
OnPlayerStateChange(playerid,newstate,oldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
            
HealthTimer[playerid] = SetTimerEx("HealthDown"1000true"i"playerid); // Healthdown timer
            
TextDrawShowForPlayer(playeridHealthText[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(vehhealth);
                                                                        
            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 
0strlen(str); <n++)
    {
        
str[i] = toupper(str[i]);
    }
    return 
1;

IIIIIIIIII is still iiiiiiiiii in game. Why?
Reply
#5

Hello.

Use font 1.
Font 3 are only lowercase.
(https://sampwiki.blast.hk/wiki/TextDrawFont)
Reply
#6

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.
Reply
#7

thank you very much man!
Reply
#8

And how i can get a size for text to be proportional?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)