SA-MP Forums Archive
global OOC? error help /togt - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: global OOC? error help /togt (/showthread.php?tid=597717)



global OOC? error help /togt - Tween73 - 03.01.2016

Код:
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;
}



Re: global OOC? error help /togt - saffierr - 03.01.2016

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;




Re: global OOC? error help /togt - Tween73 - 03.01.2016

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));




Re: global OOC? error help /togt - ReDKiiL - 04.01.2016

What the errors?


Re: global OOC? error help /togt - RoboN1X - 04.01.2016

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;
}



Re: global OOC? error help /togt - saffierr - 04.01.2016

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