Need help - Globalchat. -
Striker_Moe - 13.09.2009
Okay guys
At the top I got
Код:
new globalchat[MAX_PLAYERS];
Then, as admin commands, these two:
if(strcmp(cmd, "/enablegc", true) == 0)
{
if (AccountInfo[playerid][AdminLevel] > 1 || IsPlayerAdmin(playerid))
{
globalchat[playerid] = 1;
}
else SendClientMessage(playerid, RED, "Youґre not the needed admin level.");
return 1;
}
if(strcmp(cmd, "/disablegc", true) == 0)
{
if (AccountInfo[playerid][AdminLevel] > 1 || IsPlayerAdmin(playerid))
{
globalchat[playerid] = 0;
}
else SendClientMessage(playerid, RED, "Youґre not the needed admin level.");
return 1;
}
How can I make a command like /g [text] now? Its meant to chat global, but only when admins enabled the global chat.
Re: Need help - Globalchat. -
Backwardsman97 - 13.09.2009
For one thing, you should make the global chat variable a boolean operator since it's only gonna be set to 0 or 1. There's no need to have an array of 200 if it's for something global like that. This should work. I normally don't use strtok and I didn't compile this so...
pawn Код:
new bool:globalchat;
if(!strcmp(cmd, "/enablegc", true))
{
if (AccountInfo[playerid][AdminLevel] > 1 || IsPlayerAdmin(playerid))
{
globalchat = true;
}
else return SendClientMessage(playerid, RED, "Youґre not the needed admin level.");
}
if(!strcmp(cmd, "/disablegc", true))
{
if (AccountInfo[playerid][AdminLevel] > 1 || IsPlayerAdmin(playerid))
{
globalchat = false;
}
else return SendClientMessage(playerid, RED, "Youґre not the needed admin level.");
}
if(!strcmp(cmd, "/g", true))
{
if(!globalchat)
{
SendClientMessage(playerid,RED,"Global chat is not currently enabled.");
return 1;
}
new tmp[128];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,RED,"Usage: /g [text]");
return 1;
}
new string[128],name[24];
GetPlayerName(playerid,name,24);
format(string,128,"[Global Chat]-%s: %s",name,tmp);
SendClientMessageToAll(COLOR,string);
return 1;
}
Re: Need help - Globalchat. -
Striker_Moe - 13.09.2009
Okay, but now I got a little problem - somehow when you write "shdajkldnasjkbdnajkdnask" its getting displayed, but if you write "Okay, you now can talk on /g" it only displays the "Okay,"
Re: Need help - Globalchat. -
Nero_3D - 13.09.2009
pawn Код:
if(!strcmp(cmd, "/g", true))
{
if(!globalchat)
return SendClientMessage(playerid,RED,"Global chat is not currently enabled.");
while(cmdtext[idx] == 32) idx++;
if(cmdtext[idx] == EOS)
return SendClientMessage(playerid,RED,"Usage: /g [text]");
new string[128];
GetPlayerName(playerid,string,MAX_PLAYER_NAME);
format(string,128,"[Global Chat]-%s: %s",string,cmdtext[idx]);
return SendClientMessageToAll(COLOR,string);
}