str shadows problem - 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: str shadows problem (
/showthread.php?tid=325063)
str shadows problem -
iStrow - 11.03.2012
guys i've been creating my own roleplay gamemode and i got stuck on one warning, i got it because i created a local chat with prox detector
here is error
Код:
E:\servers\e-Sport.hr RolePlay\gamemodes\iSRP.pwn(209) : warning 219: local variable "str" shadows a variable at a preceding level
and here is the script
http://pastebin.com/TS2EXEsf
Re: str shadows problem -
captainjohn - 11.03.2012
Have you defined the variable str more than once?
Re: str shadows problem -
IstuntmanI - 11.03.2012
Change
Код:
public OnPlayerText(playerid, text[])
{
new name[24], str[128];
GetPlayerName(playerid, name, 24);
format(str, sizeof(str), "%s says: %s", name, text);
ProxDetector(10.0, playerid, str, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
return 0;
}
to
Код:
public OnPlayerText(playerid, text[])
{
new name[24], strOPT[128];
GetPlayerName(playerid, name, 24);
format(strOPT, sizeof(strOPT), "%s says: %s", name, text);
ProxDetector(10.0, playerid, strOPT, COLOR_FADE1, COLOR_FADE2, COLOR_FADE3, COLOR_FADE4, COLOR_FADE5);
return 0;
}
"shadows ..." = variable already defined
Re: str shadows problem -
[ABK]Antonio - 11.03.2012
new levels,Nam[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME],str[128],ID;
Right there, line 21. You've defined it there making it a global variable. You would need to remove that and then only create it inside of the function you're using to make it local.