SA-MP Forums Archive
warning 219: local variable "giveplayerid" shadows a variable at a preceding level - 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: warning 219: local variable "giveplayerid" shadows a variable at a preceding level (/showthread.php?tid=514799)



warning 219: local variable "giveplayerid" shadows a variable at a preceding level - Slicebook - 23.05.2014

help how to fix?
Код:
warning 219: local variable "giveplayerid" shadows a variable at a preceding level
Код:
if(strcmp(cmd, "/bemutatkoz",true) == 0)
    {
		new giveplayerid; <<<WARNING!
	//	if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");
		if(playerid == giveplayerid) return SendClientMessage(playerid, 0x33AA33AA, "(( Magadnak nem mutatkozhatsz be! ))");
		new USER_FILE[64];
		format(USER_FILE, sizeof(USER_FILE), "SFSUsers/%s.ini", GetPlayerNameEx(playerid));
		if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(giveplayerid)) == 1) return SendClientMessage(playerid, 0x33AA33AA, "(( Mбr ismeritek egymбst! ))");
		new iStr[70];
		format(iStr, sizeof(iStr), "(( Bemutatkozбs kйrelmet elkьldted neki: %s ))", GetPlayerNameEx(giveplayerid));
		SendClientMessage(playerid, 0x33AA33AA, iStr);
		format(iStr, sizeof(iStr), "Ьdv! %s vagyok йs a barбtod szeretnйk lenni.\nElfogadod?", GetPlayerNameEx(playerid));
		ShowPlayerDialog(giveplayerid, AMIGODIALOG, DIALOG_STYLE_MSGBOX, "Цn elfogadja?", iStr, "Igen", "Nem");
		SetPVarInt(giveplayerid, "AmigoRequest", playerid);
		return 1;
	}



Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - Stanford - 23.05.2014

You have giveplayerid as a global (in top of your script), pick another thing like:

pawn Код:
if(strcmp(cmd, "/bemutatkoz",true) == 0)
    {
        new guyid; <<<WARNING!
    //  if(sscanf(params, "u", guyid)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");
        if(playerid == guyid) return SendClientMessage(playerid, 0x33AA33AA, "(( Magadnak nem mutatkozhatsz be! ))");
        new USER_FILE[64];
        format(USER_FILE, sizeof(USER_FILE), "SFSUsers/%s.ini", GetPlayerNameEx(playerid));
        if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(guyid)) == 1) return SendClientMessage(playerid, 0x33AA33AA, "(( M?r ismeritek egym?st! ))");
        new iStr[70];
        format(iStr, sizeof(iStr), "(( Bemutatkoz?s kйrelmet elkьldted neki: %s ))", GetPlayerNameEx(guyid));
        SendClientMessage(playerid, 0x33AA33AA, iStr);
        format(iStr, sizeof(iStr), "Udv! %s vagyok йs a bar?tod szeretnйk lenni.\nElfogadod?", GetPlayerNameEx(playerid));
        ShowPlayerDialog(guyid, AMIGODIALOG, DIALOG_STYLE_MSGBOX, "?n elfogadja?", iStr, "Igen", "Nem");
        SetPVarInt(guyid, "AmigoRequest", playerid);
        return 1;
    }
I hope that I helped you!.


Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - SilentSoul - 23.05.2014

You have declared this variable before, however you can do one of the following things:
1) Change the giveplayerid to another variable like 'targetid'.
2) Find the giveplayerid variable and replace it with another variable by using (Control+F).

EDIT: Sorry Stanford. i was too late.


Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - Slicebook - 23.05.2014

thanks, 1 problem please help
Код:
error 035: argument type mismatch (argument 1)

	if(sscanf(params, "u", giveplayeride)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");



Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - SilentSoul - 23.05.2014

Change it to the new variable you have declared however it is , or show me your command.
pawn Код:
if(sscanf(params, "u", guyid)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");



Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - Slicebook - 23.05.2014

Quote:
Originally Posted by SilentSoul
Посмотреть сообщение
Change it to the new variable you have declared however it is , or show me your command.
pawn Код:
if(sscanf(params, "u", guyid)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");
don't work !! please help but not important


Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - SilentSoul - 23.05.2014

Show me your command?


Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - Slicebook - 23.05.2014

full code:
Код:
	if(strcmp(cmd, "/bemutatkoz",true) == 0)
    {
		new giveplayeride;
		if(sscanf(params, "u", giveplayeride)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");
		if(playerid == giveplayeride) return SendClientMessage(playerid, 0x33AA33AA, "(( Magadnak nem mutatkozhatsz be! ))");
		new USER_FILE[64];
		format(USER_FILE, sizeof(USER_FILE), "SFSUsers/%s.ini", GetPlayerNameEx(playerid));
		if(DOF2_GetInt(USER_FILE, GetPlayerNameEx(giveplayeride)) == 1) return SendClientMessage(playerid, 0x33AA33AA, "(( Mбr ismeritek egymбst! ))");
		new iStr[70];
		format(iStr, sizeof(iStr), "(( Bemutatkozбs kйrelmet elkьldted neki: %s ))", GetPlayerNameEx(giveplayeride));
		SendClientMessage(playerid, 0x33AA33AA, iStr);
		format(iStr, sizeof(iStr), "Ьdv! %s vagyok йs a barбtod szeretnйk lenni.\nElfogadod?", GetPlayerNameEx(playerid));
		ShowPlayerDialog(giveplayeride, AMIGODIALOG, DIALOG_STYLE_MSGBOX, "Цn elfogadja?", iStr, "Igen", "Nem");
		SetPVarInt(giveplayeride, "AmigoRequest", playerid);
		return 1;
	}



Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - Fred1993 - 23.05.2014

pawn Код:
new guyid;
if(sscanf(params, "u", guyid)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");
Try this


Re: warning 219: local variable "giveplayerid" shadows a variable at a preceding level - SilentSoul - 23.05.2014

You are using the OnPlayerCommandText not zcmd or a thing that uses params. You should use cmdtext instead.
pawn Код:
if(sscanf(cmdtext, "u", giveplayeride)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");
EDIT: Sorry use cmd not cmdtext if it didn't work.
pawn Код:
if(sscanf(cmd, "u", giveplayeride)) return SendClientMessage(playerid, 0x33AA33AA, "(( /bemutatkoz [playerid] ))");