25/1*100 = 1? 11?
#1

WTH I have a kill death percentage thing, and look at this code:

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
        SendDeathMessage(killerid, playerid, reason);
        TogglePlayerSpectating(playerid, true);
        PlayerSpectatePlayer(playerid, killerid);
        SetTimerEx("spec", 5000, false, "i", playerid);

        HandleKS(playerid, killerid);

        SetPlayerScore(killerid, GetPlayerScore(killerid)+1);

        if(pInfo[playerid][team] == 0)
        {
            gt--;
        }
        else if(pInfo[playerid][team] == 1)
        {
            bt--;
        }

        TextDrawHideForPlayer(playerid, rTD[playerid]);
        TextDrawHideForPlayer(playerid, kdTD[playerid]);
        TextDrawHideForPlayer(killerid, rTD[killerid]);
        TextDrawHideForPlayer(killerid, kdTD[killerid]);

        pInfo[playerid][deaths]++;
        pInfo[killerid][kills]++;

        kdP[killerid] = pInfo[killerid][kills]/pInfo[killerid][deaths]*100;
       
        if(pInfo[killerid][kills] >= 25)
        {
            pInfo[killerid][rank] = 2;
        }
        else if(pInfo[killerid][kills] >= 50)
        {
            pInfo[killerid][rank] = 3;
        }
        else if(pInfo[killerid][kills] >= 75)
        {
            pInfo[killerid][rank] = 4;
        }
        else if(pInfo[killerid][kills] >= 100)
        {
            pInfo[killerid][rank] = 5;
        }
        else if(pInfo[killerid][kills] >= 125)
        {
            pInfo[killerid][rank] = 6;
        }
        else if(pInfo[killerid][kills] >= 150)
        {
            pInfo[killerid][rank] = 7;
        }
        else
        {
            pInfo[killerid][rank] = 1;
        }

        new tdS2[10];
        format(tdS2, sizeof(tdS2), "RANK: %i", pInfo[killerid][rank]);
        TextDrawSetString(rTD[killerid], tdS2);

        new tdsS2[10];
        format(tdsS2, sizeof(tdsS2), "%i:%i - %%%d", pInfo[playerid][kills], pInfo[playerid][deaths], kdP[playerid]);
        TextDrawSetString(kdTD[killerid], tdsS2);

        TextDrawShowForPlayer(killerid, kdTD[killerid]);
        TextDrawShowForPlayer(killerid, rTD[killerid]);
    }
    else
    {
        SendDeathMessage(killerid, playerid, reason);
        TogglePlayerSpectating(playerid, true);
        PlayerSpectatePlayer(playerid, killerid);
        SetTimerEx("spec", 5000, false, "i", playerid);

        HandleKS(playerid, killerid);

        if(pInfo[playerid][team] == 0)
        {
            gt--;
        }
        else if(pInfo[playerid][team] == 1)
        {
            bt--;
        }

        TextDrawHideForPlayer(playerid, rTD[playerid]);
        TextDrawHideForPlayer(playerid, kdTD[playerid]);

        pInfo[playerid][deaths]++;
    }
    return 1;
}
I have 25 kills and 1 death. And it says %1. If I make %%%d into %d it says 11. Any ideas? This is scary... and I tested it with 25/1*100 and it still says 11...
Reply
#2

I changed %%%d to %f and it works. Why doesnt %%%f work? Is there a way around this?
Reply
#3

To insert a percent, I do this:

pawn Код:
format(x, sizeof(x), "Your health is %f%s.", 6.9, "%%"); // "Your health is 69.000000%.'
NOT tested, may have made an error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)