Quote:
Originally Posted by Wizzard2H
Код:
//top of script
#include <a_samp>
#include <zcmd>
#include <sscanf>
new Mute[MAX_PLAYERS];
CMD:fakekick(playerid, params[])
{
new ID, targetid;
if (sscanf(params, "us[90]", ID)) return SendClientMessage(playerid, 0x1F36E0FF, "USAGE: /fakekick [Playerid/Name]");
if (!IsPlayerConnected(ID)) return SendClientMessage(playerid, 0xF50A0AFF, "NOTICE: Player not found.");
new string[128];
format(string,sizeof(string),"%s has been kicked by %s for ****** Hacks", PlayerName(ID), PlayerName(playerid));
SendClientMessageToAll(0xAA3333AA, string);
SendClientMessage(ID, 0xAA3333AA, "Server closed the connection.");
SendDeathMessage(INVALID_PLAYER_ID, playerid, 201);
SetPlayerVirtualWorld(playerid, 2);
Mute[targetid] = 1;
return 1;
}
public OnPlayerText(playerid, text[])
{
if(Mute[playerid] >= 1)
{
return 0;
}
return 1;
}
PlayerName(playerid)
{
new CName[24];
GetPlayerName(playerid, CName, 24);
return CName;
}
Haven't tested the code because wrote in 2 mins but should work.
|
You shouldn't post code written under 2 minutes and untested:
You're not using targetid:
PHP код:
new ID, targetid;
What is the 's' specifier doing there? How did you even get to 90 cells for it?
PHP код:
if (sscanf(params, "us[90]", ID))
You don't need 128 cells for that string. The maximum size of the formatted string is 85 characters.
PHP код:
new string[128];
This shouldn't be inside cmd_fakekick:
PHP код:
OnPlayerText(playerid, text[])
{
if(Mute[playerid] >= 1)
{
return 0;
}
For the sake of convenience (while it doesn't matter), you could declare mute as a boolean variable:
PHP код:
new bool:Mute[playerid]
And then use it as so:
PHP код:
Mute[playerid] = true;
PHP код:
Mute[playerid] = false;
From true to false and false to true:
PHP код:
Mute[playerid] = !Mute[playerid];
PHP код:
if(Mute[playerid]) // Player is muted
PHP код:
if(!Mute[playerid]) // Player is not muted