20.02.2016, 11:27
Hi. This is my code:
It shows no error while compiling and it is a mask system.
The purpose is that each user has his own Mask ID that is a random 6-digit number.
I run the script and everything seems fine, I can take off my mask and put it back on.
But when I join with two accounts, the names get messed up real bad.
Example:
[ID0] Justin has a mask on
[ID1] Anna has a mask on
I type: /behindmask 1 and it shows this:
Stranger 105 = AnJustin
Then as the two accounts have the mask on at the same time, one account copies the REAL NAME of the other account and when that account takes off their mask (Let's say Anna took off her mask), her real name becomes "stin" which is a part of Justin's name.
Someone help, cheers.
PHP код:
CMD:buymask(playerid)
{
if(PlayerInfo[playerid][pMask] == 1) return InfoMessage(playerid, "You already have a mask.");
else
{
InfoMessage(playerid, "You have received a mask.");
PlayerInfo[playerid][pMaskID] = randomEx(111111,999999);
PlayerInfo[playerid][pMask] = 1;
}
return 1;
}
CMD:mask(playerid)
{
if(PlayerInfo[playerid][pMask] == 0) return SendClientMessage(playerid, -1, "You don't have a mask");
if(maskon[playerid] == 0)
{
new string[240];
maskon[playerid] = 1;
GetPlayerName(playerid, string, sizeof(string));
strmid(PlayerInfo[playerid][pRealName], string, 0, strlen(string), 64);
format(string,sizeof(string), "Stranger_%d", PlayerInfo[playerid][pMaskID]);
SetPlayerName(playerid, string);
MeMessage(playerid,"puts on their mask.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
ShowPlayerNameTagForPlayer(i, playerid, 0);
}
}
else if(maskon[playerid] == 1)
{
SetPlayerName(playerid, PlayerInfo[playerid][pRealName]);
maskon[playerid] = 0;
MeMessage(playerid,"takes off their mask.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
ShowPlayerNameTagForPlayer(i, playerid, 1);
}
}
return 1;
}
CMD:behindmask(playerid, params[])
{
new playerb, string[128];
if(sscanf(params, "i", playerb)) return UsageMessage(playerid, "/behindmask (playerid)");
format(string, sizeof(string), "Stranger %d = %s", PlayerInfo[playerb][pMaskID], PlayerInfo[playerb][pRealName]);
SendClientMessage(playerid, -1, string);
return 1;
}
The purpose is that each user has his own Mask ID that is a random 6-digit number.
I run the script and everything seems fine, I can take off my mask and put it back on.
But when I join with two accounts, the names get messed up real bad.
Example:
[ID0] Justin has a mask on
[ID1] Anna has a mask on
I type: /behindmask 1 and it shows this:
Stranger 105 = AnJustin
Then as the two accounts have the mask on at the same time, one account copies the REAL NAME of the other account and when that account takes off their mask (Let's say Anna took off her mask), her real name becomes "stin" which is a part of Justin's name.
Someone help, cheers.