Sorry to say this, but this filterscript has alot of faulths...
First of all, the indentation is really quite bad.
Second off, you're creating variables at the top of commands when not needed.
pawn Код:
CMD:mute(playerid, params[])
{
new targetid, minutes, reason[128], string[128];
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
new name2[MAX_PLAYER_NAME];
GetPlayerName(targetid, name2, sizeof(name));
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
if(muted[targetid] == true) return SendClientMessage(playerid, COLOR_RED, "Player is already muted");
if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "/mute (id) (minutes) (reason)");
format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", name, name2, minutes, reason);
SendClientMessageToAll(COLOR_RED, string);
mutetimer = SetTimerEx("Unmute", minutes*60000, false, "i", targetid);
muted[targetid] = true;
return 1;
}
You could easily optimise this, you're creating the variables at the top, therefore it will create the variables even if something went wrong.
Like if the targetid isn't connected, the player isn't admin, the targetid is already muted or if you didn't insert a targetid.
It will still create the variables, it would be way better to create the variables as the functions in the command gets executed, not the stuff that checks and cancels the command.
Like this:
pawn Код:
CMD:mute(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "You can't use this command");
new targetid;
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_RED, "Player is not connected to the server");
if(muted[targetid] == true) return SendClientMessage(playerid, COLOR_RED, "Player is already muted");
new minutes, reason[128];
if(sscanf(params,"uis[128]", targetid, minutes, reason)) return SendClientMessage(playerid, COLOR_RED, "/mute (id) (minutes) (reason)");
new string[128], name[MAX_PLAYER_NAME], name2[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
GetPlayerName(targetid, name2, sizeof(name));
format(string, sizeof(string), "Administrator %s muted %s for %d minutes: %s", name, name2, minutes, reason);
SendClientMessageToAll(COLOR_RED, string);
mutetimer = SetTimerEx("Unmute", minutes*60000, false, "i", targetid);
muted[targetid] = true;
return 1;
}
Also fixed your indentation, but this way would be more optimised.
You could also optimise your script because you're using "else" when it's not needed.
Example:
pawn Код:
CMD:pms(playerid, params[])
{
if(pm[playerid] == false)
{
pm[playerid] = true;
SendClientMessage(playerid,0xEE128960,"Private Messages unblocked! You can receive messages from other players");
}
else
{
pm[playerid] = false;
SendClientMessage(playerid, 0xEE128960,"Private Messages blocked! You will no longer receive messages from other players");
}
return 1;
}
Using a switch in these occasions would be much better, and more optimised.
pawn Код:
CMD:pms(playerid, params[])
{
switch(pm[playerid])
{
case false:
{
pm[playerid] = true;
SendClientMessage(playerid,0xEE128960,"Private Messages unblocked! You can receive messages from other players");
}
case true:
{
pm[playerid] = false;
SendClientMessage(playerid, 0xEE128960,"Private Messages blocked! You will no longer receive messages from other players");
}
}
return 1;
}