Help - 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: Help (
/showthread.php?tid=360848)
Help -
SkL_MD - 19.07.2012
I have these warnings:
pawn Код:
E:\SA-MP Resources\Server nou\gamemodes\RNG v0.1.pwn(310) : warning 209: function "cmd_pee" should return a value
E:\SA-MP Resources\Server nou\gamemodes\RNG v0.1.pwn(332) : warning 209: function "cmd_sarme" should return a value
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
2 Warnings.
look commands:
pawn Код:
CMD:pee(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
SendClientMessage(playerid,0xFF0606AA,"You can not urinate in the vehicle!");
}
else
{
SendClientMessage(playerid,0xFFFF00AA,"Ahhh .. I feel very well ..");
SetPlayerSpecialAction(playerid, 68);
return 1;
}
}
//---------------------------------------------------------------------
CMD:sarme(playerid,params[])
{
if (GetPlayerMoney(playerid) >= 300000)
{
GivePlayerWeapon(playerid, 24, 14);
GivePlayerWeapon(playerid, 25, 15);
GivePlayerWeapon(playerid, 29, 60);
GivePlayerWeapon(playerid, 31, 100);
GivePlayerWeapon(playerid, 34, 5);
GivePlayerWeapon(playerid, 46, 1);
SetPlayerHealth(playerid,100);
SetPlayerArmour(playerid,100);
GivePlayerMoney(playerid, -300000);
SendClientMessage(playerid,0x33AA33AA, " Knew got a kit with more weapons and life with full armor!");
}
else
{
SendClientMessage(playerid, 0xFF0606AA, " Do not have enough money! You need $ 300,000.");
return 1;
}
}
Re: Help -
iggy1 - 19.07.2012
In this case don't return your values from inside the else statement, return after it.
Eg,
pawn Код:
CMD:pee(playerid,params[])
{
if(IsPlayerInAnyVehicle(playerid))
{
return SendClientMessage(playerid,0xFF0606AA,"You can not urinate in the vehicle!");
}
else
{
SendClientMessage(playerid,0xFFFF00AA,"Ahhh .. I feel very well ..");
SetPlayerSpecialAction(playerid, 68);
}
return 1;
}
In your version if the "
else" is executed it will return a value. But if the "
else" is not executed no value will be returned. Hence the function doesn't return a value.
And learn to indent, it will help you and others reading your code, and this mistake is easier to spot along with many other errors..