When do I return? - 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: When do I return? (
/showthread.php?tid=154285)
When do I return? -
NiiRV4N4 - 13.06.2010
I don't understand how to return 1;. My friend has helped me a lot but I still need more information. When and what do I return 1; too? Thank you.
Re: When do I return? -
Kar - 13.06.2010
nvm
Re: When do I return? - TheInnocentOne - 13.06.2010
Err no, return does not do that.
Re: When do I return? -
NiiRV4N4 - 13.06.2010
Quote:
Originally Posted by Kar
it stops the server from saying "SERVER: UNKNOWN COMMAND" i think i cant remember
|
That isn't what I asked. I am return 1; wrong, and this happens:
http://forum.sa-mp.com/index.php?topic=179697.0
- According to my friend
Re: When do I return? -
Sergei - 13.06.2010
Return when you want function to be ended. You don't need to return values if you don't need them, so doing
at the end of the function will do the work.
Re: When do I return? -
NiiRV4N4 - 13.06.2010
Quote:
Originally Posted by $ЂЯĢ
Return when you want function to be ended. You don't need to return values if you don't need them, so doing
at the end of the function will do the work.
|
What about in commands?
pawn Код:
if(strcmp(cmd, "/repaircop", true) ==0)
{
if(IsPlayerConnected(playerid))
{
if(PlayerInfo[playerid][pMember] == 1 || PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pLeader] == 11 || PlayerInfo[playerid][pLeader] == 11)
{
if(IsACopCar(GetPlayerVehicleID(playerid)))
{
if(IsPlayerInAnyVehicle(playerid))
{
if(IsPlayerInRangeOfPoint(playerid, 50.0, 1568.77,-1692.75,6.98))
{
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid, COLOR_GREEN, "* Your cruiser ate a donut and is now repaired");
}
else
{
SendClientMessage(playerid, COLOR_GREY,"[Error:] You're not in the garage!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY,"[Error:] Only vehicles can be repaired, not brains!");
}
}
else
{
SendClientMessage(playerid, COLOR_GREY,"[Error:] You're not a cop!");
}
}
}
return 1;
}
Is this command properly returned?
Re: When do I return? -
NiiRV4N4 - 13.06.2010
double post, my bad
Re: When do I return? - TheInnocentOne - 13.06.2010
Yes, but the indentation is awful.
Learn to indent your code, it makes it much more readable and with 10k> lines of code it gets hard to read without it
Re: When do I return? -
NiiRV4N4 - 13.06.2010
Quote:
Originally Posted by TheInnocentOne
Yes, but the indentation is awful.
Learn to indent your code, it makes it much more readable and with 10k> lines of code it gets hard to read without it 
|
I indent the way I want to indent and the way I was taught to indent. It isn't your choice.
Re: When do I return? -
Sergei - 13.06.2010
@NiiRV4N4, on commands return when command is finished.
@TheInnocentOne, if you copy code from pawno it usually doesn't show up properly, so you need to make some manual changes if you want that it looks good on forum.