Random help.,
#1

I made a mask system....
but the random maskid isn't going well.
Here's my code:

pawn Код:
CMD:mask(playerid, params[])
{
    if(PlayerInfo[playerid][pMask] != 1) return SCM(playerid, COLOR_FADE5, "You don't have a mask.");
    if(maskOn{playerid} == 0)
    {
        GameTextForPlayer(playerid, "~h~~b~You have put ON your mask.", 4000, 4);
        maskOn{playerid} = 1;
        MaskID{playerid} = randomEx(1000, 9999);
        foreach(Player, i)
        {
            ShowPlayerNameTagForPlayer(playerid, i, 0);
        }
    }
    else
    {
        GameTextForPlayer(playerid, "~h~~b~You have taken OFF your mask.", 4000, 4);
        maskOn{playerid} = 0;
        foreach(Player, i)
        {
            ShowPlayerNameTagForPlayer(playerid, i, 1);
        }
    }
    return 1;
}
This part should make a random number from 1000 to 9999.
MaskID{playerid} = randomEx(1000, 9999);
but when I display it.


pawn Код:
stock GetNameWithMask(playerid)
{
    new string[MAX_PLAYER_NAME];
    if(maskOn{playerid})
    {
        format(string, sizeof(string), "[Masked_%d]", GetMaskID(playerid));
    }
    else
    {
        GetPlayerName(playerid, string, sizeof(string));
        strreplace(string, '_', ' ');
    }
    return string;
}

stock GetMaskID(playerid) return MaskID{playerid};

It displays numbers lower than 1000 like,.. 100, 202
Reply
#2

Actually it can't go over 255 and under zero (char).

Use classic variables for that, or even PvarInt.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)