enum PlayerInfo
{
bool:Listening
}
new pInfo[MAX_PLAYERS][PlayerInfo];
CMD:listen(playerid, params[])
{
if(pInfo[playerid][Listening] == false)
{
pInfo[playerid][Listening] = true;
SendClientMessage(playerid, -1, "You have started listening to commands.");
}
else
{
pInfo[playerid][Listening] = false;
SendClientMessage(playerid, -1, "You have stopped listening to commands.");
}
return 1;
}
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if (!IsPlayerConnected2(playerid)) return 0;
new cstring[100],playerids[MAX_PLAYER_NAME];
GetPlayerName(playerid, playerids, sizeof(playerids));
format(cstring, sizeof(cstring), "[cmd] [%s]: %s", playerids, cmdtext);
foreach(new i: Player)
{
if(adminvariable >= 1 && Listen(i) == 1)
{
if(adminvariable <= adminvariable)
{
if(i != playerid) SendClientMessage(i, -1, cstring);
}
}
}
return 1;
}
forward Listen(playerid);
public Listen(playerid)
{
return pInfo[playerid][Listening];
}
here you go
PHP код:
|
E:\MY GAMES\GTA san andreas\PG\gamemodes\PG.pwn(712) : error 028: invalid subscript (not an array or too many subscripts): "pInfo" E:\MY GAMES\GTA san andreas\PG\gamemodes\PG.pwn(712) : error 001: expected token: ";", but found "]" E:\MY GAMES\GTA san andreas\PG\gamemodes\PG.pwn(712) : error 029: invalid expression, assumed zero E:\MY GAMES\GTA san andreas\PG\gamemodes\PG.pwn(712) : fatal error 107: too many error messages on one line
// Use your own enum, this is to explain only
enum pv
{
Name[MAX_PLAYER_NAME + 1],
AdminLevel
}
new P[MAX_PLAYERS][pv];
new bool:IsAdminListening;
//Get player name only once when connecting so you won't need to do it everytime
public OnPlayerConnect(playerid)
{
GetPlayerName(playerid, P[playerid][Name], MAX_PLAYER_NAME + 1);
return 1;
}
CMD:test(playerid, params[])
{
// Command
new str[128];
format(str, sizeof str, "%s(%d) used command /test", P[playerid][Name], playerid);
SendAdminMessage(str);
return 1;
}
// Repeat this for every command you want to track
// Or if you hate your users' privacy and wish to track em all, you can do
CMD:listen(playerid, params[])
{
if(P[playerid][AdminLevel] < 5)return 0; // Hide the CMD for non-admins
if(IsAdminListening == false){
IsAdminListening = true;
SendClientMessage(playerid, -1, "You are listening..");
}
if(IsAdminListening == true){
IsAdminListening = false;
SendClientMessage(playerid, -1, "You are listening no more.");
}
return 1;
}
public OnPlayerCommandReceived(playerid, cmdtext[])
{
if(IsAdminListening == true){
new str[128];
format(str, sizeof str, "%s(%d) used command /test", P[playerid][Name], playerid);
SendAdminMessage(str);
}
return 1;
}
// This is used to send Administrators the message
SendAdminMessage(str[])
{
foreach(Player, i){
if(P[i][AdminLevel] > 5){
SendClientMessage(i, -1, str);
}
}
}