Function should return a value - 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: Function should return a value (
/showthread.php?tid=284167)
Function should return a value -
McCarthy - 18.09.2011
pawn Код:
stock IsFBIVehicles(playerid)
{
for(new i=9; i<sizeof(fbicar); i++)
if(GetPlayerVehicleID(playerid) == fbicar[i])
return 1;
}
Compiling fails with
"warning 209: function "IsFBIVehicles" should return a value" I dont see whats wrong D:
Re: Function should return a value -
|_ⒾⓇⓄN_ⒹⓄG_| - 18.09.2011
where are u using it?
Re: Function should return a value -
Cyanide - 18.09.2011
You need to create a return value if IsFBIVehicles is
not true.
pawn Код:
stock IsFBIVehicles(playerid)
{
for(new i=9; i<sizeof(fbicar); i++)
if(GetPlayerVehicleID(playerid) == fbicar[i])
return 1;
else
return 0;
}
AW: Re: Function should return a value -
Nero_3D - 18.09.2011
Quote:
Originally Posted by Cyanide
You need to create a return value if IsFBIVehicles is not true.
|
Here a working version
pawn Код:
stock IsFBIVehicles(playerid) {
playerid = GetPlayerVehicleID(playerid);
if(playerid) {
for(new i = 9; i != sizeof fbicar; ++i) {
if(playerid == fbicar[i]) {
return true;
}
}
}
return false;
}
@McCarthy
Just indent your code correctly and use brackets till you are advanced enough to leave them away
Re: Function should return a value -
McCarthy - 18.09.2011
Thank you Nero..can you fix this too?
pawn Код:
public Repair(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
PlayerPlaySound(playerid,1134,0,0,0);
RepairVehicle(GetPlayerVehicleID(playerid));
return 1;
}
}
Re: Function should return a value -
Kush - 18.09.2011
Quote:
Originally Posted by McCarthy
Thank you Nero..can you fix this too?
pawn Код:
public Repair(playerid) { if(IsPlayerInAnyVehicle(playerid)) { PlayerPlaySound(playerid,1134,0,0,0); RepairVehicle(GetPlayerVehicleID(playerid)); return 1; } }
|
PHP код:
public Repair(playerid)
{
if(IsPlayerInAnyVehicle(playerid))
{
PlayerPlaySound(playerid,1134,0,0,0);
RepairVehicle(GetPlayerVehicleID(playerid));
}
return 1;
}