SA-MP Forums Archive
codition - 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: codition (/showthread.php?tid=607501)



codition - ratxrat - 20.05.2016

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?


Re: codition - luke49 - 20.05.2016

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


Re: codition - ratxrat - 20.05.2016

ok thank i will try


Re: codition - Naruto_Emilio - 20.05.2016

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


Re: codition - ratxrat - 20.05.2016

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


Re: codition - Konstantinos - 20.05.2016

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.


Re: codition - ratxrat - 20.05.2016

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


Re: codition - ratxrat - 20.05.2016

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