str shadows problem
#1

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
Reply
#2

Have you defined the variable str more than once?
Reply
#3

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
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)