SA-MP Forums Archive
How to fixing this error? help me Guys - 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: How to fixing this error? help me Guys (/showthread.php?tid=607899)



How to fixing this error? help me Guys - Zyova - 25.05.2016

pwn(43951) : warning 219: local variable "string" shadows a variable at a preceding level

This is line (43951)
Код:
new string[128];
Half code
Код:
if(PlayerInfo[playerid][pMaskuse] == 1)
	{
	    new string[128];
		format(string, sizeof(string), "Stranger_%d Whispers: %s", RandMask[playerid], whisper);
		SetPlayerChatBubble(playerid, string, COLOR_WHITE, 3.0, 8000);
		ProxDetector(3.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
	}
Complete code
Код:
CMD:w(playerid, params[])
{
	new giveplayerid, whisper[128], string[128];

	if(gPlayerLogged{playerid} == 0)
	{
		SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
		return 1;
	}
	if(sscanf(params, "us[128]", giveplayerid, whisper))
	{
		SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/w)hisper [playerid] [text]");
		return 1;
	}
	if(WatchingTV[playerid] != 0 && PlayerInfo[playerid][pAdmin] < 2)
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do this while watching TV.");
		return 1;
	}
	if(PlayerInfo[playerid][pMaskuse] == 1)
	{
	    new string[128];
		format(string, sizeof(string), "Stranger_%d Whispers: %s", RandMask[playerid], whisper);
		SetPlayerChatBubble(playerid, string, COLOR_WHITE, 3.0, 8000);
		ProxDetector(3.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
	}
	if (IsPlayerConnected(giveplayerid))
	{
		if(HidePM[giveplayerid] > 0)
		{
			SendClientMessageEx(playerid, COLOR_GREY, "That player is blocking whispers!");
			return 1;
		}
		new giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
		sendername = GetPlayerNameEx(playerid);
		giveplayer = GetPlayerNameEx(giveplayerid);
		if(giveplayerid == playerid)
		{
			if(PlayerInfo[playerid][pSex] == 1) format(string, sizeof(string), "* %s menggerutu didalam hati.", GetPlayerNameEx(playerid));
			else format(string, sizeof(string), "* %s menggerutu didalam hati.", GetPlayerNameEx(playerid));
			return ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
		}
		if(ProxDetectorS(5.0, playerid, giveplayerid) || PlayerInfo[playerid][pAdmin] >= 2)
		{
		    if(PlayerInfo[playerid][pAdmin]<1)
		    {
			    format(string, sizeof(string), "* %s mendekati %s dan membisikan sesuatu.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
				ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
			}

			format(string, sizeof(string), "%s (ID %d) whispers to you: %s", GetPlayerNameEx(playerid), playerid, whisper);

			if(strlen(string) > 92)
			{
				new firstline[128], secondline[128];
				strmid(firstline, string, 0, 88);
				strmid(secondline, string, 88, 128);
				format(firstline, sizeof(firstline), "%s ...", firstline);
				SendClientMessageEx(giveplayerid, COLOR_YELLOW, firstline);
				SendClientMessageEx(giveplayerid, COLOR_YELLOW, secondline);
			}
			else SendClientMessageEx(giveplayerid,COLOR_YELLOW, string);

			format(string, sizeof(string), "You whispered to %s: %s", GetPlayerNameEx(giveplayerid),whisper);
			if(strlen(string) > 92)
			{
				new firstline[128], secondline[128];
				strmid(firstline, string, 0, 88);
				strmid(secondline, string, 88, 128);
				format(firstline, sizeof(firstline), "%s ...", firstline);
				SendClientMessageEx(playerid, COLOR_YELLOW, firstline);
				ProxDetector(5.0, playerid, firstline,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
				SendClientMessageEx(playerid, COLOR_YELLOW, secondline);
				ProxDetector(5.0, playerid, secondline,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
			}
			else SendClientMessageEx(playerid,COLOR_YELLOW, string);
			return 1;
		}
		else
		{
			SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
		}
		return 1;
	}

	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
	}
	new Str[300];
    if(AdminReadPm[playerid] == 1)
    {
  	      format(Str, sizeof(Str), "Whisper From %s(%d) to %s(%d): %s" , GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(giveplayerid), giveplayerid, whisper);
		  MessageToAdmins(COLOR_RED, Str);
	}
	return 1;
}



Re: How to fixing this error? help me Guys - F1N4L - 25.05.2016

You created a variable string global and local.


Re: How to fixing this error? help me Guys - Zyova - 25.05.2016

You are Guys both, are you can give me a solution with more specific? I'm newbie and sorry,if I had bad grammer


Re: How to fixing this error? help me Guys - F1N4L - 25.05.2016

Use the search bar and search for "string".
Delete the variable GLOBAL only (top of the script).


Re: How to fixing this error? help me Guys - Luicy. - 25.05.2016

Here buddy,
pawn Код:
CMD:w(playerid, params[])
{
    new giveplayerid, whisper[128], stringText[128];

    if(gPlayerLogged{playerid} == 0)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
        return 1;
    }
    if(sscanf(params, "us[128]", giveplayerid, whisper))
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/w)hisper [playerid] [text]");
        return 1;
    }
    if(WatchingTV[playerid] != 0 && PlayerInfo[playerid][pAdmin] < 2)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do this while watching TV.");
        return 1;
    }
    if(PlayerInfo[playerid][pMaskuse] == 1)
    {
        new stringText[128];
        format(stringText, sizeof(stringText), "Stranger_%d Whispers: %s", RandMask[playerid], whisper);
        SetPlayerChatBubble(playerid, stringText, COLOR_WHITE, 3.0, 8000);
        ProxDetector(3.0, playerid, stringText,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    if (IsPlayerConnected(giveplayerid))
    {
        if(HidePM[giveplayerid] > 0)
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player is blocking whispers!");
            return 1;
        }
        new giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        sendername = GetPlayerNameEx(playerid);
        giveplayer = GetPlayerNameEx(giveplayerid);
        if(giveplayerid == playerid)
        {
            if(PlayerInfo[playerid][pSex] == 1) format(stringText, sizeof(stringText), "* %s menggerutu didalam hati.", GetPlayerNameEx(playerid));
            else format(stringText, sizeof(stringText), "* %s menggerutu didalam hati.", GetPlayerNameEx(playerid));
            return ProxDetector(5.0, playerid, stringText, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
        if(ProxDetectorS(5.0, playerid, giveplayerid) || PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(PlayerInfo[playerid][pAdmin]<1)
            {
                format(stringText, sizeof(stringText), "* %s mendekati %s dan membisikan sesuatu.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, stringText, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }

            format(stringText, sizeof(stringText), "%s (ID %d) whispers to you: %s", GetPlayerNameEx(playerid), playerid, whisper);

            if(strlen(stringText) > 92)
            {
                new firstline[128], secondline[128];
                strmid(firstline, stringText, 0, 88);
                strmid(secondline, stringText, 88, 128);
                format(firstline, sizeof(firstline), "%s ...", firstline);
                SendClientMessageEx(giveplayerid, COLOR_YELLOW, firstline);
                SendClientMessageEx(giveplayerid, COLOR_YELLOW, secondline);
            }
            else SendClientMessageEx(giveplayerid,COLOR_YELLOW, stringText);

            format(stringText, sizeof(stringText), "You whispered to %s: %s", GetPlayerNameEx(giveplayerid),whisper);
            if(strlen(stringText) > 92)
            {
                new firstline[128], secondline[128];
                strmid(firstline, stringText, 0, 88);
                strmid(secondline, stringText, 88, 128);
                format(firstline, sizeof(firstline), "%s ...", firstline);
                SendClientMessageEx(playerid, COLOR_YELLOW, firstline);
                ProxDetector(5.0, playerid, firstline,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                SendClientMessageEx(playerid, COLOR_YELLOW, secondline);
                ProxDetector(5.0, playerid, secondline,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            }
            else SendClientMessageEx(playerid,COLOR_YELLOW, stringText);
            return 1;
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
        }
        return 1;
    }

    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    }
    new Str[300];
    if(AdminReadPm[playerid] == 1)
    {
          format(Str, sizeof(Str), "Whisper From %s(%d) to %s(%d): %s" , GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(giveplayerid), giveplayerid, whisper);
          MessageToAdmins(COLOR_RED, Str);
    }
    return 1;
}
Replace that with yours.

You can't string as a variable, since it's defined as a native.


Re: How to fixing this error? help me Guys - F1N4L - 25.05.2016

Quote:
Originally Posted by Meller
Посмотреть сообщение
Here buddy,
pawn Код:
CMD:w(playerid, params[])
{
    new giveplayerid, whisper[128], stringText[128];

    if(gPlayerLogged{playerid} == 0)
    {
        SendClientMessageEx(playerid, COLOR_GREY, "You're not logged in.");
        return 1;
    }
    if(sscanf(params, "us[128]", giveplayerid, whisper))
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/w)hisper [playerid] [text]");
        return 1;
    }
    if(WatchingTV[playerid] != 0 && PlayerInfo[playerid][pAdmin] < 2)
    {
        SendClientMessageEx(playerid, COLOR_GRAD2, "You can't do this while watching TV.");
        return 1;
    }
    if(PlayerInfo[playerid][pMaskuse] == 1)
    {
        new stringText[128];
        format(stringText, sizeof(stringText), "Stranger_%d Whispers: %s", RandMask[playerid], whisper);
        SetPlayerChatBubble(playerid, stringText, COLOR_WHITE, 3.0, 8000);
        ProxDetector(3.0, playerid, stringText,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    }
    if (IsPlayerConnected(giveplayerid))
    {
        if(HidePM[giveplayerid] > 0)
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player is blocking whispers!");
            return 1;
        }
        new giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        sendername = GetPlayerNameEx(playerid);
        giveplayer = GetPlayerNameEx(giveplayerid);
        if(giveplayerid == playerid)
        {
            if(PlayerInfo[playerid][pSex] == 1) format(stringText, sizeof(stringText), "* %s menggerutu didalam hati.", GetPlayerNameEx(playerid));
            else format(stringText, sizeof(stringText), "* %s menggerutu didalam hati.", GetPlayerNameEx(playerid));
            return ProxDetector(5.0, playerid, stringText, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
        if(ProxDetectorS(5.0, playerid, giveplayerid) || PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(PlayerInfo[playerid][pAdmin]<1)
            {
                format(stringText, sizeof(stringText), "* %s mendekati %s dan membisikan sesuatu.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
                ProxDetector(30.0, playerid, stringText, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
            }

            format(stringText, sizeof(stringText), "%s (ID %d) whispers to you: %s", GetPlayerNameEx(playerid), playerid, whisper);

            if(strlen(stringText) > 92)
            {
                new firstline[128], secondline[128];
                strmid(firstline, stringText, 0, 88);
                strmid(secondline, stringText, 88, 128);
                format(firstline, sizeof(firstline), "%s ...", firstline);
                SendClientMessageEx(giveplayerid, COLOR_YELLOW, firstline);
                SendClientMessageEx(giveplayerid, COLOR_YELLOW, secondline);
            }
            else SendClientMessageEx(giveplayerid,COLOR_YELLOW, stringText);

            format(stringText, sizeof(stringText), "You whispered to %s: %s", GetPlayerNameEx(giveplayerid),whisper);
            if(strlen(stringText) > 92)
            {
                new firstline[128], secondline[128];
                strmid(firstline, stringText, 0, 88);
                strmid(secondline, stringText, 88, 128);
                format(firstline, sizeof(firstline), "%s ...", firstline);
                SendClientMessageEx(playerid, COLOR_YELLOW, firstline);
                ProxDetector(5.0, playerid, firstline,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                SendClientMessageEx(playerid, COLOR_YELLOW, secondline);
                ProxDetector(5.0, playerid, secondline,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            }
            else SendClientMessageEx(playerid,COLOR_YELLOW, stringText);
            return 1;
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
        }
        return 1;
    }

    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    }
    new Str[300];
    if(AdminReadPm[playerid] == 1)
    {
          format(Str, sizeof(Str), "Whisper From %s(%d) to %s(%d): %s" , GetPlayerNameEx(playerid), playerid, GetPlayerNameEx(giveplayerid), giveplayerid, whisper);
          MessageToAdmins(COLOR_RED, Str);
    }
    return 1;
}
Replace that with yours.

You can't string as a variable, since it's defined as a native.
The more variable global, more memory will be used.
We are talking about a STRING variable, it will always have some value because it will not be destroyed until shut down the GM.
Every time you use the function strcat the variable must be reset, because always assume the previous value.


Re: How to fixing this error? help me Guys - Zyova - 25.05.2016

Thank you Guys,compile success