02.01.2018, 08:35
I have this command for players to disable their global chat
OnPlayerText:
The problem is that the chat would still be enabled even after toggling the chat off
chattoggled as global var is used here
When /disablechat is used, it disables the chat. but when /togchat is used, it doesn't
PHP код:
CMD:togchat(playerid, params[])
{
switch(chattoggle[playerid])
{
case true: chattoggle[playerid] = false, SendClientMessage(playerid, 0x00FF00FF, "Chat enabled");
case false: chattoggle[playerid] = true, SendClientMessage(playerid, 0x00FF00FF, "Chat disabled");
}
return 1;
}
PHP код:
public OnPlayerText(playerid, text[])
{
if(!chattoggled)
{
return 0;
}
else
{
return 0;
}
if(chattoggle[playerid])
{
return 0;
}
else
{
return 1;
}
}
chattoggled as global var is used here
PHP код:
CMD:disablechat(playerid)
{
if(PlayerInfo[playerid][Admin] < 6) return SendClientMessage(playerid, 0xFF0000AA, "You're not authorized to use that command!");
if(chattoggled)
{
chattoggled = false;
SendClientMessageToAll(0x00FFFFFF, "AdmCmd: An administrator has disabled the chat");
}
else SendClientMessage(playerid, 0xFFFF00FF, "Chat is already disabled");
return 1;
}
CMD:enablechat(playerid)
{
if(PlayerInfo[playerid][Admin] < 6) return SendClientMessage(playerid, 0xFF0000AA, "You're not authorized to use that command!");
if(!chattoggled)
{
chattoggled = true;
SendClientMessageToAll(0x00FFFFFF, "AdmCmd: An administrator has enabled the chat");
}
else SendClientMessage(playerid, 0xFFFF00FF, "Chat is already enabled");
return 1;
}