SA-MP Forums Archive
format + float + Linux = Ё%*@#(!*Ё!@ - 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: format + float + Linux = Ё%*@#(!*Ё!@ (/showthread.php?tid=316073)



format + float + Linux = Ё%*@#(!*Ё!@ - CyNiC - 05.02.2012

pawn Код:
new Float:Objective = GetVictimsTotalHealth(playerid), Float:Hits = GetAmountTakenFromVictims(playerid), Float:Result;
Result = floatmul(floatdiv(Hits, Objective), 100.0);
format(str[1], sizeof str[], "~n~Victims -- (Hits percent: %.1f):", Result);
On the host, when I try to show these things in a textdraw it appears wrong, a lot of strong symbols like: @(Ё#!&#ЁЁ!, on Windows(my PC) it works perfectly.


Re: format + float + Linux = Ё%*@#(!*Ё!@ - ғαιιοцт - 05.02.2012

Are you sure that Objective can never become 0?

And can you show me where you create the variable Result please?


Re: format + float + Linux = Ё%*@#(!*Ё!@ - FireCat - 05.02.2012

Try this:
pawn Код:
format(str[1], 128, "~n~Victims -- (Hits percent: %.1f):", Result);



Re: format + float + Linux = Ё%*@#(!*Ё!@ - CyNiC - 05.02.2012

Quote:
Originally Posted by ғαιιοцт
Посмотреть сообщение
Are you sure that Objective can never become 0?

And can you show me where you create the variable Result please?
First line of the my post, I tried it in a round that I killed 3 players without die, so...

Quote:
Originally Posted by FireCat
Посмотреть сообщение
Try this:
pawn Код:
format(str[1], 128, "~n~Victims -- (Hits percent: %.1f):", Result);
The problem can't be there, I used "sizeof str[]" instead of "sizeof str" because the array is bi-dimensional.

Here is the declaration:

pawn Код:
new str[2][(sizeof substr) * (PER_ROUND_ATTACKERS)];



Re: format + float + Linux = Ё%*@#(!*Ё!@ - ғαιιοцт - 05.02.2012

Oh sorry, i can't see the end of that first line on my ipod, the text shows bigger here and doesn't fit on the page.


Re: format + float + Linux = Ё%*@#(!*Ё!@ - T0pAz - 05.02.2012

Looks fine for me on my linux machine. Show me your str variable deceleration.


Re: format + float + Linux = Ё%*@#(!*Ё!@ - CyNiC - 05.02.2012

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
Looks fine for me on my linux machine. Show me your str variable deceleration.
http://pastebin.com/UpkkV3aT


Re: format + float + Linux = Ё%*@#(!*Ё!@ - Kar - 05.02.2012

print the values of Hits and Objective and get back to me here


Re: format + float + Linux = Ё%*@#(!*Ё!@ - T0pAz - 05.02.2012

The problem can be on these things:

1) GetVictimsTotalHealth.
2) GetAmountTakenFromVictims.
3) str.


Re: format + float + Linux = Ё%*@#(!*Ё!@ - CyNiC - 05.02.2012

Thanks for all.

Quote:
Originally Posted by Kar
Посмотреть сообщение
print the values of Hits and Objective and get back to me here
pawn Код:
DEBUG-ROUNDSTATS: HITS: 46.2 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 56.1 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 227.7 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 29.7 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 108.9 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 183.1 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 46.2 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 92.4 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 46.2 OBJECTIVE: 0.0
DEBUG-ROUNDSTATS: HITS: 89.1 OBJECTIVE: 0.0
I didn't have made any test of this yet, just now I can see that objective is always 0.0, I'll check what happens.

Quote:
Originally Posted by T0pAz
Посмотреть сообщение
The problem can be on these things:

1) GetVictimsTotalHealth.
2) GetAmountTakenFromVictims.
3) str.
pawn Код:
Float:GetAmountTakenFromVictims(playerid)
{
    new Float:GivenDamage;
    for(new i = 0; i < PER_ROUND_ATTACKERS; i++)
    {
        for(new p = 0; p < MAX_PLAYERS; p++)
        {
            if(DamageGiven[p][i][attacker] == playerid)
            {
                GivenDamage += DamageGiven[p][i][damage_amount];
            }
        }
    }
    return GivenDamage;
}

Float:GetVictimsTotalHealth(playerid)
{
    new Float:hCount;
    for(new i = 0; i < PER_ROUND_ATTACKERS; i++)
    {
        if(IsPlayerConnected(DamageTaken[playerid][i][victim]) && DamageTaken[playerid][i][in_use])
        {
            hCount += pTotalHealth[DamageTaken[playerid][i][victim]];
        }
    }
    return hCount;
}