Random numbers for the mask
#1

How can you create some random numbers in this mask code... Like stranger [number]

pawn Код:
CMD:mask(playerid, params[])
{
    if(IsPlayerConnected(playerid))
    {
        if(Masked[playerid] == false)
        {
            new pname[24];
            GetPlayerName(playerid, pname, sizeof(pname));
            Masked[playerid] = true;
            strmid(OldName[playerid], pname, 0, strlen(pname), 64);
            SetPlayerName(playerid, "The Stranger");
            SendClientMessage(playerid, COLOR_GREEN, "* You have put on your mask.");
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                ShowPlayerNameTagForPlayer(i, playerid, 0);
            }
        }
        else
        {
            SetPlayerName(playerid, OldName[playerid]);
            Masked[playerid] = false;
            SendClientMessage(playerid, COLOR_GREEN, "* You have removed your mask.");
            for(new i=0;i<MAX_PLAYERS;i++)
            {
                ShowPlayerNameTagForPlayer(i, playerid, 1);
            }
        }
    }
    return 1;
}
+rep if you helped me!
Reply
#2

Explain more please what you mean with numbers in this mask code? Btw, i will show you how random function works.
pawn Код:
new randomnumber = random(5); // random ( Maximum value ) 5
printf("%i",randomnumber);//it will pick a random number from 0 to 5!
EDIT: Source of random function from sa-mp wiki here
Reply
#3

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
Explain more please what you mean with numbers in this mask code? Btw, i will show you how random function works.
pawn Код:
new randomnumber = random(5); // random ( Maximum value ) 5
printf("%i",randomnumber);//it will pick a random number from 0 to 5!
EDIT: Source of random function from sa-mp wiki here
Thanks, i will try it +rep for you,
Reply
#4

Okay, other question, if you do /mask you get a random ID, but if you talk how do you see the same number as your mask
Reply
#5

If I'm got you right, you mean in chat, you want to show the ID of the mask that you set randomly?

Inside the OnPlayerText, format the string with the id you randomly set for masked person.

pawn Код:
public OnPlayerText(playerid, text[])
{
    new string[128];
    format(string,sizeof(string),"%s(%d): %s",pName(playerid),id_of_mask,text);  // replace the id_of_mask to the random id you set.
    SendClientMessageToAll(GetPlayerColor(playerid),string);
    return 1;
}

// In case you need this.
stock pName(playerid)
{
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,PlayerName,sizeof(PlayerName));
    return PlayerName;
}
Please elaborate your question in order for me to explain/answer better.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)