4 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: 4 warnings. (
/showthread.php?tid=450396)
4 warnings. -
OpticKiller - 13.07.2013
as the Title: says guys
warning codes below.
Код:
(1573) : warning 219: local variable "s1" shadows a variable at a preceding level
(1574) : warning 219: local variable "s2" shadows a variable at a preceding level
(3632) : warning 219: local variable "int" shadows a variable at a preceding level
(4415) : warning 219: local variable "int" shadows a variable at a preceding level
the code making the warnings.
Код:
stock udb_hash(buf[])
{
new length=strlen(buf);
new s1 = 1;
new s2 = 0;
new n;
for (n=0; n<length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
CMD:gotox(playerid, params[])
{
new Float:tpx, Float:tpy, Float:tpz, int;
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(AdminDuty[playerid] == 0 && PlayerInfo[playerid][pAdmin] < 6) return SendClientMessage(playerid, -1, "You are not on duty as an admin");
if(sscanf(params, "fffi", tpx, tpy, tpz, int)) return SendClientMessage(playerid, -1, "USAGE: /gotox [coord x] [coord y] [coord z] [int]");
if(!isnull(params))
{
SetPlayerPos(playerid, tpx, tpy, tpz);
SetPlayerInterior(playerid, int);
SendClientMessage(playerid, -1, "You have been teleported.");
return 1;
}
return 1;
}
Re: 4 warnings. -
Sandiel - 13.07.2013
4 global variables have the same name as those inside the udb_hash stock.
If you look ontop of your script, you will find 4 variables named "sl, "sl2", "int"
If you've no use to them, either delete them or rename them.
Re: 4 warnings. -
CaveDweller - 13.07.2013
s1, s2, int and int are already defined in your script (somewhere before "udb_hash", and at a higher level - outside of any functions).
You could simply rename s1, s2, int and int.
Re: 4 warnings. -
OpticKiller - 13.07.2013
got it thanks guys.