/messageon and /messageoff
#5

Why using 2 commands? Why not use 1 command that toggle's it on or off by using a variable. In my opinion it would be more effective.


Here an example:
pawn Код:
//Somewhere at the beginning of the script
new ShowMessages[MAX_PLAYERS];


//under OnPlayerConnect
ShowMessages[playerid] = 1;


//under OnPlayerCommand
if(strcmp(cmd, "/togglemessage", true) == 0)
{
    if(IsPlayerConnected(playerid))
    {
        if(ShowMessages[playerid] == 1)
        {
            ShowMessages[playerid] = 0;
            SendClientMessage(playerid, COLOR_WHITE, "You have {00FFFF}Disabled {FFFFFF}the messages, Type /togglemessage again to toggle it."); //Not sure if both colours are correct :P just a guess.
            return 1;
        }
        if(ShowMessages[playerid] == 0)
        {
            ShowMessages[playerid] = 1;
            SendClientMessage(playerid, COLOR_WHITE, "You have {FFFF00}Enabled{FFFFFF} the messages, Type /togglemessage again to toggle it."); //Not sure if both colours are correct :P just a guess.
            return 1;
        }
    }
    return 1;
}


And in every of your teleport commands, add the codes that is shown below.
pawn Код:
if(ShowMessages[playerid] == 1)
{
SendClientMessage(playerid, 0x........, "You have been teleported to ...");
}
There is no need to add (view codes below), because it there isnt any codes needed when ShowMessages is false (ShowMessages == 0).
pawn Код:
if(ShowMessages[playerid] == 0)
{
    //Add Pawno Codes
}

This seems very complecated but once you get it its very simple, but I hope this helps.

Regards,
Rolyy
Reply


Messages In This Thread
/messageon and /messageoff - by ]B4E[kengston - 08.07.2011, 11:32
Re: /messageon and /messageoff - by Basicz - 08.07.2011, 11:46
Re: /messageon and /messageoff - by ]B4E[kengston - 08.07.2011, 11:52
Re: /messageon and /messageoff - by Basicz - 08.07.2011, 12:06
Re: /messageon and /messageoff - by Rolyy - 08.07.2011, 14:44

Forum Jump:


Users browsing this thread: 1 Guest(s)