pawn Код:
new PlayerBlocked[MAX_PLAYERS];
pawn Код:
if(strcmp(cmd, "/block", true) == 0)
{
new tmp[20], id;
tmp = strtok(cmdtext, index);
if(!IsPlayerAdmin(playerid)) return 0;
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /block [ID]");
id = strval(tmp);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Player is not connected");
if(id == playerid) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You cannot use this command on yourself");
if(IsPlayerAdmin(id)) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You cannot use this command on other admins");
if(PlayerBlocked[id] == 1) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Player is already blocked");
PlayerBlocked[id] = 1;
SendClientMessage(id, COLOR_RED, "You have been blocked");
new message[128], blockedname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
GetPlayerName(id, blockedname, sizeof(blockedname));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(message,sizeof(message), "%s has been blocked by admin %s", blockedname, adminname);
for(new i; i<MAX_PLAYERS; i++) {
if(IsPlayerAdmin(i)) {
SendClientMessage(i, COLOR_RED, message);
}
}
return 1;
}
pawn Код:
if(strcmp(cmd, "/unblock", true) == 0)
{
new tmp[20], id;
tmp = strtok(cmdtext, index);
if(!IsPlayerAdmin(playerid)) return 0;
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_ERROR, "USAGE: /unblock [ID]");
id = strval(tmp);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Player is not connected");
if(id == playerid) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You cannot use this command on yourself");
if(IsPlayerAdmin(id)) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You cannot use this command on other admins");
if(PlayerBlocked[id] == 0) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: Player is already unblocked");
PlayerBlocked[id] = 0;
SendClientMessage(id, COLOR_GREEN, "You have been unblocked");
new message[128], blockedname[MAX_PLAYER_NAME], adminname[MAX_PLAYER_NAME];
GetPlayerName(id, blockedname, sizeof(blockedname));
GetPlayerName(playerid, adminname, sizeof(adminname));
format(message,sizeof(message), "%s has been unblocked by admin %s", blockedname, adminname);
for(new i; i<MAX_PLAYERS; i++) {
if(IsPlayerAdmin(i)) {
SendClientMessage(i, COLOR_RED, message);
}
}
return 1;
}
pawn Код:
public OnPlayerText(playerid, text[])
{
if(PlayerBlocked[playerid] == 1) return SendClientMessage(playerid, COLOR_ERROR, "ERROR: You cannot talk whilst blocked");
return 1;
}