Woah! My CMDS are not working!
#8

Quote:
Originally Posted by Enforcer501
Посмотреть сообщение
There's nothing wrong with his returns that I know of.
They will work but are not needed and out of place that is what is wrong. It messes up your program flow too take the following statement.

You tell me what makes more sense in practice.

This way.
pawn Код:
SomeCheck()
{
    if(a == 1)
    {
        DoSomeThing();
        return 1;
    }
    DoSomeThingElse();
    return 1;
}
Or This way

pawn Код:
SomeCheck()
{
    if(a == 1)
    {
        DoSomething();
    }
    else
    {
        DoSomethingElse();
    }
    return 1;
}
I don't know about you but the second makes more sense our functions are in alignment now instead of being offset by the return; in readability terms this is much better. Secondly there is only one return 1; it is the last function call in the scope of this function and will always be called once.

Quote:
Originally Posted by Enforcer501
Посмотреть сообщение
Read the comments.
return 1; // This is to prevent the code from further executing.
This is a bad reason;

This is how it should look.
pawn Код:
CMD:adminroof(playerid)
{
    if(IsPlayerInRangeOfPoint(playerid, 3.0, 1847.7333,-1761.9608,13.5469))
    {
        SetPlayerPos(playerid, 1889.0286,-1782.9777,25.7911);//Naar boven
        SetPlayerInterior(playerid, 0);
        SendClientMessage(playerid, COLOR_GREEN, "*You use the elevator to get on the roof*");
    }
    else SendClientMessage(playerid,0xFFFFFF00,"DEBUG: Not in range!"); //If the IsPlayerInRangeOfPoint check fails,
    return 1;
}
Your only going to return 1; so the command processor knows the command was successful.
Reply


Messages In This Thread
Woah! My CMDS are not working! - by Songason - 18.06.2013, 14:09
Re: Woah! My CMDS are not working! - by Littlehelper - 18.06.2013, 14:12
AW: Woah! My CMDS are not working! - by Blackazur - 18.06.2013, 14:14
Re: AW: Woah! My CMDS are not working! - by Songason - 18.06.2013, 14:15
Re: Woah! My CMDS are not working! - by Enforcer501 - 18.06.2013, 14:31
Re: Woah! My CMDS are not working! - by Pottus - 18.06.2013, 14:42
Re: Woah! My CMDS are not working! - by Enforcer501 - 18.06.2013, 14:49
Re: Woah! My CMDS are not working! - by Pottus - 18.06.2013, 14:56

Forum Jump:


Users browsing this thread: 4 Guest(s)