SA-MP Forums Archive
Alot of warnings.. - 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: Alot of warnings.. (/showthread.php?tid=378375)



Alot of warnings.. - Misterflowers - 17.09.2012

This is the system:
Quote:

new string[16];
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
format(string,sizeof(string),"-%.0f hp",amount);
SetPlayerChatBubble(playerid,string,0xFFFFFF,150.0 ,2500);
return 1;
}

Quote:

And this is the warnings:
warning 219: local variable "string" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level




Re: Alot of warnings.. - Juan.x - 17.09.2012

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new string[16];
format(string,sizeof(string),"-%.0f hp",amount);
SetPlayerChatBubble(playerid,string,0xFFFFFF,150.0 ,2500);
return 1;
}



Re: Alot of warnings.. - dennissk - 17.09.2012

It's something to see, the String is above the Callback, you should leave it.

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new string[256];

format(string,sizeof(string),"-%.0f hp",amount);
SetPlayerChatBubble(playerid,string,0xFFFFFF,150.0 ,2500);
return 1;
}


Re: Alot of warnings.. - AtItsMax - 17.09.2012

Quote:
Originally Posted by Juan.x
Посмотреть сообщение
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new string[16];
format(string,sizeof(string),"-%.0f hp",amount);
SetPlayerChatBubble(playerid,string,0xFFFFFF,150.0 ,2500);
return 1;
}
Quote:
Originally Posted by dennissk
Посмотреть сообщение
It's something to see, the String is above the Callback, you should leave it.

public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new string[256];

format(string,sizeof(string),"-%.0f hp",amount);
SetPlayerChatBubble(playerid,string,0xFFFFFF,150.0 ,2500);
return 1;
}
What the hell? Why don't you both read the warnings properly?
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
new szString[16];
format(szString,sizeof(szString),"-%.0f hp",amount);
SetPlayerChatBubble(playerid,szString,0xFFFFFF,150.0 ,2500);
return 1;
Quote:

warning 219: local variable "string" shadows a variable at a preceding level

Means the character "string" is already defined in your script.
So, using another name rather than "string" will solve it.