codition
#1

i create condition for hunger update every 5 second . but text just cange if value 100 and <0 this my code.
PHP Code:
if (PlayerInfo[playerid][pHunger] >91 && PlayerInfo[playerid][pHunger] <150 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIIIIIIIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >81 && PlayerInfo[playerid][pHunger] <90 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIIIIIIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >71 && PlayerInfo[playerid][pHunger] <80 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIIIIIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >61 && PlayerInfo[playerid][pHunger] <70 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIIIIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >51 && PlayerInfo[playerid][pHunger] <60 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIIIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >41 && PlayerInfo[playerid][pHunger] <50 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >31 && PlayerInfo[playerid][pHunger] <40 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "IIII"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >21 && PlayerInfo[playerid][pHunger] <30 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "III"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >11 && PlayerInfo[playerid][pHunger] <20 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "II"); //tdies
    
}
    if (
PlayerInfo[playerid][pHunger] >&& PlayerInfo[playerid][pHunger] <10 )
    {
        
PlayerTextDrawSetString(playeridtampilan[playerid][10], "I"); //tdies
    

how to check range for example 1 to 10 = a, 11 to 20 = b, etc?
Reply
#2

First hide textdraw with function TextDrawHideForPlayer, then set string for your textdraw and then show it again with function TextDrawShowForPlayer
Reply
#3

ok thank i will try
Reply
#4

You have to refresh your textdraws, and also try using switch case instead
Reply
#5

im just use looping for every condition , and bam that work, thanks for helping
Reply
#6

Wouldn't something like this be easier?
pawn Code:
new new_value[17];
for (new i, j = floatround(i / 10, floatround_floor) + 1; i != j; i++) new_value[i] = 'I';
PlayerTextDrawSetString(playerid, tampilan[playerid][10], new_value);
However if pHunger is 150 then the text is double (16 'I's) that's because you don't count 110-140 in your if statements.
Reply
#7

yes im use for loop, like this , range 20 to 30 example
PHP Code:
for(new x=20x<31;x++)
if (
rangenumber == x)
{
condition work

bu im create for() loop for every range conditional
Reply
#8

Quote:
Originally Posted by Konstantinos
View Post
Wouldn't something like this be easier?
pawn Code:
new new_value[17];
for (new i, j = floatround(i / 10, floatround_floor) + 1; i != j; i++) new_value[i] = 'I';
PlayerTextDrawSetString(playerid, tampilan[playerid][10], new_value);
However if pHunger is 150 then the text is double (16 'I's) that's because you don't count 110-140 in your if statements.
new_value every 10 = "i" ? i will learn more for this loop, btw thanks for something new
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)