Random numbers for the mask - 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: Random numbers for the mask (
/showthread.php?tid=516380)
Random numbers for the mask -
lulo356 - 31.05.2014
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!
Re: Random numbers for the mask -
SilentSoul - 31.05.2014
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
Re: Random numbers for the mask -
lulo356 - 31.05.2014
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,
Re: Random numbers for the mask -
lulo356 - 31.05.2014
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
Re: Random numbers for the mask -
Tayab - 31.05.2014
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.