When do I return?
#1

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.
Reply
#2

nvm
Reply
#3

Err no, return does not do that.
Reply
#4

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
Reply
#5

Return when you want function to be ended. You don't need to return values if you don't need them, so doing
Код:
return;
at the end of the function will do the work.
Reply
#6

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
Код:
return;
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?
Reply
#7

double post, my bad
Reply
#8

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
Reply
#9

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.
Reply
#10

@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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)