Help with my Name Colour Script?
#4

Command method

pawn Код:
CMD:nc(playerid, arg[])
{
    if(!strcmp(arg, "blue", true)) { SetPlayerColor(playerid, COLOR_BLUE); }
    else if(!strcmp(arg, "grey", true)) { SetPlayerColor(playerid, COLOR_GREY); }
    else if(!strcmp(arg, "green", true)) { SetPlayerColor(playerid, COLOR_GREEN); }
    else if(!strcmp(arg, "purple", true)) { SetPlayerColor(playerid, COLOR_PURPLE); }
    else if(!strcmp(arg, "cyan", true)) { SetPlayerColor(playerid, COLOR_CYAN); }
    else if(!strcmp(arg, "pink", true)) { SetPlayerColor(playerid, COLOR_PINK); }
    else if(!strcmp(arg, "lime", true)) { SetPlayerColor(playerid, COLOR_LIME); }
    else if(!strcmp(arg, "red", true)) { SetPlayerColor(playerid, COLOR_RED); }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "Change the colour of your name by doing /nc [desired colour]");
        SendClientMessage(playerid, COLOR_WHITE, "List of colours:");
        SendClientMessage(playerid, COLOR_BLUE, "Blue");
        SendClientMessage(playerid, COLOR_GREY, "Grey");
        SendClientMessage(playerid, COLOR_GREEN, "Green");
        SendClientMessage(playerid, COLOR_PURPLE, "Purple");
        SendClientMessage(playerid, COLOR_CYAN, "Cyan");
        SendClientMessage(playerid, COLOR_PINK, "Pink");
        SendClientMessage(playerid, COLOR_LIME, "Lime");
        SendClientMessage(playerid, COLOR_RED, "Red");
        return 1;
    }
    SendClientMessage(playerid, COLOR_WHITE, "Name colour changed!");
    return 1;
}
@LeeXian99 I disagree with doing this

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(response)
    {
        switch(dialogid)
        {
If you do that then you might have another switch(dialogid) when reponse is 0, this is not good it means the code would be separated from where response is 1 that could be a pain in the ass to work with it should really be the following code convention to prevent potentially hundreds of lines between areas of code that should be grouped for readability. But if I was using dialogs I would use y_inline and y_dialog anyways

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        if(response)
        {
        }
        else
        {
        }
        {
That is a far better practice.
Reply


Messages In This Thread
Help with my Name Colour Script? - by CrystalMethod - 21.04.2013, 04:47
AW: Help with my Name Colour Script? - by [AK]Nazgul - 21.04.2013, 05:06
Re: Help with my Name Colour Script? - by LeeXian99 - 21.04.2013, 05:45
Re: Help with my Name Colour Script? - by Pottus - 21.04.2013, 05:59
Re: Help with my Name Colour Script? - by kalanerik99 - 21.04.2013, 08:48
Re: Help with my Name Colour Script? - by Parker_Daley - 21.04.2013, 08:54
Re: Help with my Name Colour Script? - by LeeXian99 - 21.04.2013, 08:58
Re: Help with my Name Colour Script? - by Guest123 - 21.04.2013, 09:05
Re: Help with my Name Colour Script? - by Guest123 - 21.04.2013, 09:19
Re: Help with my Name Colour Script? - by CrystalMethod - 21.04.2013, 16:03

Forum Jump:


Users browsing this thread: 1 Guest(s)