How to make /listen
#1

Hey guys
I was want to make a command make you see the players typed commands like someone used /s and the admin can see the command
iam using Zcmd any idea for this command?
Reply
#2

Can someone helpme?
Reply
#3

here you go
PHP код:
enum PlayerInfo
{
     
bool:Listening
}
new 
pInfo[MAX_PLAYERS][PlayerInfo];

CMD:listen(playeridparams[])
{
    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(playeridcmdtext[])
{
    if (!
IsPlayerConnected2(playerid)) return 0;
    new 
cstring[100],playerids[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayeridssizeof(playerids));
    
format(cstringsizeof(cstring), "[cmd] [%s]: %s"playeridscmdtext);
    foreach(new 
iPlayer)
    {
        if(
adminvariable >= && Listen(i) == 1)
        {
            if(
adminvariable <= adminvariable)
            {
                  if(
!= playeridSendClientMessage(i, -1cstring);
            }
        }
    }
return 
1;
}
forward Listen(playerid);
public 
Listen(playerid)
{
    return 
pInfo[playerid][Listening];

Reply
#4

Quote:
Originally Posted by CaptainBoi
Посмотреть сообщение
here you go
PHP код:
enum PlayerInfo
{
     
bool:Listening
}
new 
pInfo[MAX_PLAYERS][PlayerInfo];
CMD:listen(playeridparams[])
{
    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(playeridcmdtext[])
{
    if (!
IsPlayerConnected2(playerid)) return 0;
    new 
cstring[100],playerids[MAX_PLAYER_NAME];
    
GetPlayerName(playeridplayeridssizeof(playerids));
    
format(cstringsizeof(cstring), "[cmd] [%s]: %s"playeridscmdtext);
    foreach(new 
iPlayer)
    {
        if(
adminvariable >= && Listen(i) == 1)
        {
            if(
adminvariable <= adminvariable)
            {
                  if(
!= playeridSendClientMessage(i, -1cstring);
            }
        }
    }
return 
1;
}
forward Listen(playerid);
public 
Listen(playerid)
{
    return 
pInfo[playerid][Listening];

Thanks bu i got 4 errors
Код:
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
Reply
#5

change them with your admin variables
Reply
#6

PHP код:
// 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(playeridP[playerid][Name], MAX_PLAYER_NAME 1); 
    return 
1;
}
CMD:test(playeridparams[])
{
    
// Command 
    
new str[128];
    
format(strsizeof 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(playeridparams[])
{
        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(playeridcmdtext[])
{
    if(
IsAdminListening == true){
    new 
str[128];
    
format(strsizeof 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(
Playeri){
        if(
P[i][AdminLevel] > 5){
            
SendClientMessage(i, -1str);
        }
    }

Edit: I should learn to read every post before posting myself.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)