Returning but still a warning - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Returning but still a warning (
/showthread.php?tid=221662)
Returning but still a warning -
Rizard - 05.02.2011
This code does work! it does return the value as it should but pawno returns a warning saying this function should return a value... any id's?
pawn Код:
stock readownedprop(playerid)
{
new file[LENGTH];
for(new i = 0; i < MAX_HOUSES; i++)
{
format(file, sizeof(file), PATH, i);
if(dini_Exists(file))
{
if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
{
return i;
}
}
}
}
Re: Returning but still a warning -
Jefff - 05.02.2011
pawn Код:
stock readownedprop(playerid)
{
new file[LENGTH];
for(new i = 0; i < MAX_HOUSES; i++)
{
format(file, sizeof(file), PATH, i);
if(dini_Exists(file))
{
if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
{
return i;
}
}
}
return -1;
}
Re: Returning but still a warning -
zSuYaNw - 05.02.2011
Quote:
Originally Posted by Rizard
This code does work! it does return the value as it should but pawno returns a warning saying this function should return a value... any id's?
pawn Код:
stock readownedprop(playerid) { new file[LENGTH]; for(new i = 0; i < MAX_HOUSES; i++) { format(file, sizeof(file), PATH, i); if(dini_Exists(file)) { if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true)) { return i; } } } }
|
You to check ?
simple:
pawn Код:
stock readownedprop(playerid)
{
new file[LENGTH];
for(new i = 0; i < MAX_HOUSES; i++)
{
format(file, sizeof(file), PATH, i);
if(dini_Exists(file))
{
if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true))
{
return true;
}
else return false;
}
}
}
Re: Returning but still a warning -
Rizard - 05.02.2011
Quote:
Originally Posted by [Full]Garfield[XDB]
You to check ?
simple:
pawn Код:
stock readownedprop(playerid) { new file[LENGTH]; for(new i = 0; i < MAX_HOUSES; i++) { format(file, sizeof(file), PATH, i); if(dini_Exists(file)) { if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true)) { return true; } else return false; } } }
|
euh... no, I need the value from the for loop
Quote:
Originally Posted by Jefff
pawn Код:
stock readownedprop(playerid) { new file[LENGTH]; for(new i = 0; i < MAX_HOUSES; i++) { format(file, sizeof(file), PATH, i); if(dini_Exists(file)) { if(!strcmp(dini_Get(file, "owner"), playerName(playerid), true)) { return i; } } } return -1; }
|
Tyvm but can you also explain this? Is it just a 'bug-/warningcatcher' for pawno? I never saw this before.
Grts
Re: Returning but still a warning -
Jefff - 05.02.2011
pawn Код:
new houseID;
if(((houseID = readownedprop(playerid)) != -1))
{
}else SCM("You dont have any house");
not bug just normal warning xd
Re: Returning but still a warning -
SWEMike - 06.02.2011
1. This warning means that you have to set a return right before the last closing bracket in function.
2. Jefff said "return -1;" because if he had put "return 0;" the server would think you wanted the function to return ID 0 when all house files had been read.