warning - 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 (
/showthread.php?tid=494618)
warning -
aboa - 14.02.2014
C:\Users\Mohamad\Desktop\SRP.pwn(48745) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
pawn Код:
if(Phunted[playerid] != 0 && hunted == playerid)
  {
    new string[128];
    format(string, sizeof(string), "Please forgive %s for killing the hunted %s.", GetPlayerNameEx(killerid),killerid,GetPlayerNameEx(playerid),playerid);
    SendClientMessageToAllEx(COLOR_LIGHTBLUE, string);
    GivePrize(killerid, huntedpricetype);
    Phunted[playerid] = 0;
    hunted = INVALID_PLAYER_ID;
  }
Re: warning -
itsCody - 14.02.2014
It means you already have a string, identified. Check your call backs
Re: warning -
aboa - 14.02.2014
ok thanks bro
Re: warning -
Ceez - 14.02.2014
Delete this line
new string[128];
And it will work just fine
Re: warning -
TheFlyer - 14.02.2014
No Dont delete it
just rename it to smth else
like
new string2[128];
that works fine
Re: warning -
Konstantinos - 14.02.2014
It's declared as global but it's better to use local variables for strings (basically arrays) because you can use lower size and it's not going to be a waste.
Replace:
pawn Код:
new string[128];
format(string, sizeof(string), "Please forgive %s for killing the hunted %s.", GetPlayerNameEx(killerid),killerid,GetPlayerNameEx(playerid),playerid);
SendClientMessageToAllEx(COLOR_LIGHTBLUE, string);
with:
pawn Код:
new sz_Msg[83];
format(sz_Msg, sizeof(sz_Msg), "Please forgive %s for killing the hunted %s.", GetPlayerNameEx(killerid),GetPlayerNameEx(playerid));
SendClientMessageToAllEx(COLOR_LIGHTBLUE, sz_Msg);
You had also 2 arguments more but without a placeholder in the format.