Random help., - 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 help., (
/showthread.php?tid=422673)
Random help., -
PaulDinam - 14.03.2013
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
Re: Random help., -
Djole1337 - 14.03.2013
Actually it can't go over 255 and under zero (char).
Use classic variables for that, or even PvarInt.