Unreachable Code!
#6

one rule i never break, is:
Код:
if (you write an "if" in your script)
{
	fuckin' indent. your TAB key is not that [        ] fat to be ignored.
}
mkay, with some exceptions, like code which will never be touched anymore - its easier to end with 1 line when collapsing callbacks/other nested lines
look at a simple toggle command, the 1st 3rd line got the { bracket at the end. bad practise, but you get the point, when you see the "fake" collapsed code (in fact: how it looks to me)...
the full thing:
pawn Код:
CMD:insert(playerid,cmdtext[]){
    InsertMode=1-InsertMode;
    switch(InsertMode){
        case 0:
        {
            SendClientMessage(playerid,MSGCMDS_COLOR,"Insertion Mode {ffaaaa}disabled");
        }
        case 1:
        {
            SendClientMessage(playerid,MSGCMDS_COLOR,"Insertion Mode {aaffaa}enabled");
        }
    }
    return 1;
}
collapsed the switch-line (imagine a + symbol indicating a collapsed line, so the [ only is ok here:
pawn Код:
CMD:insert(playerid,cmdtext[]){
    InsertMode=1-InsertMode;
    switch(InsertMode){ //nested, collapsed stuff inside
    return 1;
}
i promise, if you nest each single line, and indent your code, you will never fail at such shit again.

edit: oh, here's your code, i changed "nothing" except swapping 2 lines and copying 1 hehe
pawn Код:
CMD:setringtone(playerid, params[])
{
    new
    value,
    str[295],
    string[295],
    pname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
    if(PlayerInfo[playerid][pWrestler] >= 1)
    {
        if(sscanf(params, "s", value))
        {
            SendClientMessage(playerid, -1, "Syntax: /setringtone [url/ringotne]");
            SendClientMessage(playerid, -1, "For Example: http://YOUR_URL_OF_THE_SONG");
            PlayerInfo[playerid][pRingTone] = value; //<<< fixed
            return true;//this line could be deleted for now, below is another one. but if theres some stuff you want to be done incase the wrestler- or value-check fails, that line should stay.
        }
    }
    return true;
}
edit2:
may i ask what the ringtones are? numerical values or strings for streaming audio? or both? since the value is a single cell, its a good idea to change the sscanf specifier from "s" to "d" maybe? what if the player inputs a string? then the value is indeed a string:
pawn Код:
value[128]
.. and makes the specifier change obsolete.. argh
Reply


Messages In This Thread
Unreachable Code! - by Youice - 24.06.2012, 16:48
Re: Unreachable Code! - by Euan Hughes - 24.06.2012, 16:54
Re: Unreachable Code! - by Youice - 24.06.2012, 17:29
Re: Unreachable Code! - by Badger(new) - 24.06.2012, 21:43
Re: Unreachable Code! - by Kindred - 24.06.2012, 21:50
Re: Unreachable Code! - by Babul - 24.06.2012, 22:19
Re: Unreachable Code! - by Youice - 25.06.2012, 12:03

Forum Jump:


Users browsing this thread: 1 Guest(s)