global OOC? error help /togt
#1

Код:
new t_chat;
Код:
CMD:togt(playerid, params[])
{
    if (PlayerInfo[playerid][pAdmin] < 9)
	    return SendClientMessage(playerid, COLOR_RED, "You don't have permission to use this command.");

	if (!t_chat)
	{
	    SendClientMessageToAll(playerid, COLOR_RED, "[ADMIN]: %s [%d] has disabled talk chat.", GetName(playerid));
	    t_chat = true;
	}
	else
	{
	    SendClientMessageToAll(playerid, COLOR_GREEN, "[ADMIN]: %s [%d] has enabled talk chat.", GetName(playerid));
	    t_chat = false;
	}
	return 1;
}
Reply
#2

Use a boolean.
PHP код:
new bool:t_chat
PHP код:
CMD:togt(playeridparams[])
{
    if (
PlayerInfo[playerid][pAdmin] < 9)
        return 
SendClientMessage(playeridCOLOR_RED"You don't have permission to use this command.");
    if (
t_chat == true)
    {
       
SendClientMessageToAll(playeridCOLOR_RED"[ADMIN]: %s [%d] has disabled talk chat."GetName(playerid));
        
t_chat false;
    }
    else
    {
SendClientMessageToAll(playeridCOLOR_GREEN"[ADMIN]: %s [%d] has enabled talk chat."GetName(playerid));
        
t_chat true;
    }
    return 
1;

Reply
#3

2 Errors.

Quote:

SendClientMessageToAll(playerid, COLOR_RED, "[ADMIN]: %s [%d] has disabled talk chat.", GetName(playerid));

Quote:

SendClientMessageToAll(playerid, COLOR_GREEN, "[ADMIN]: %s [%d] has enabled talk chat.", GetName(playerid));

Reply
#4

What the errors?
Reply
#5

The playerid ofcourse, SendClientMessageToAll only have 2 arguments: color and message. So remove playerid, also you can't format the string like that.
Код:
CMD:togt(playerid, params[])
{
	new str[128];
    if (PlayerInfo[playerid][pAdmin] < 9)
	    return SendClientMessage(playerid, COLOR_RED, "You don't have permission to use this command.");

	if(!t_chat)
	{
		format(str, sizeof(str), "[ADMIN]: %s [%d] has disabled talk chat.", GetName(playerid), playerid); // is this mean to be "enabled"?
	    SendClientMessageToAll(COLOR_RED, str);
	    t_chat = true;
	}
	else
	{
		format(str, sizeof(str), "[ADMIN]: %s [%d] has enabled talk chat.", GetName(playerid), playerid); // is this mean to be "disabled"?
	    SendClientMessageToAll(COLOR_GREEN, str);
	    t_chat = false;
	}
	return 1;
}
Reply
#6

Lol, I didn't notice that. Use my code and edit it like @Robon said.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)