Waring.... Weee...
#1

How can i get rid of the error?

Код:
C:\Users\Robert\Desktop\VortexRoleplay\gamemodes\VortexRoleplay.pwn(9789) : 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 Код:
new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s has joined the server", pname);
    SendClientMessageToAll(0xAAAAAAAA, string);
Reply
#2

there may be two , new string[22+MAX_PLAYER_NAME]; in the same callback , or what ever that is called
Reply
#3

pawn Код:
new pname[MAX_PLAYER_NAME], stringz[46];
GetPlayerName(playerid, pname, sizeof(pname));
format(stringz, sizeof(stringz), "%s has joined the server", pname);
SendClientMessageToAll(0xAAAAAAAA, stringz);
You created the variable string twice, make sure you don't fall for that again.
Reply
#4

Try just using

pawn Код:
new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s has joined the server.",pName);
    SendClientMessageToAll(0xFFFFFFAA,string);
Reply
#5

Quote:
Originally Posted by Las Venturas CNR
Посмотреть сообщение
Try just using

pawn Код:
new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s has joined the server.",pName);
    SendClientMessageToAll(0xFFFFFFAA,string);
That wouldn't work because you're still making the error occur.
Reply
#6

Quote:
Originally Posted by Carlton
Посмотреть сообщение
That wouldn't work because you're still making the error occur.
Huh...? Umm... wonder why thats on Wiki then, strange...


go to https://sampwiki.blast.hk/wiki/OnPlayerConnect and look at the example, lol.
Reply
#7

Quote:
Originally Posted by Las Venturas CNR
Посмотреть сообщение
Huh...? Umm... wonder why thats on Wiki then, strange...


go to https://sampwiki.blast.hk/wiki/OnPlayerConnect and look at the example, lol.
If you know what the warning means then don't reply, but obviously you don't. It means you defined a variable twice. He used string twice in a callback. That wiki link has Nothing to do with this solving this.
Reply
#8

Quote:
Originally Posted by Carlton
Посмотреть сообщение
If you know what the warning means then don't reply, but obviously you don't. It means you defined a variable twice. He used string twice in a callback. That wiki link has Nothing to do with this solving this.

I misread something. Sorry, please excuse me...
Reply
#9

You have 2 of the same variable.
Delete the 1 on the lowest level, AKA the 1 that is pointed out by the warning.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)