25.03.2009, 02:22
I'm making a /mutelist command that shows a list of all the players that are muted (Along with the name of the admin that muted them and the reason)
The /mutelist command works fine, except for one thing..

It shows the reason properly, but it wont show the admin name correctly (As you can see it changes each time i do the command)
As you can see from the code I'm using the set function to set the userdata variables to the admin name and reason
And heres the /mutelist command..
If anyone could help it would be greatly appreciated
cheers
The /mutelist command works fine, except for one thing..

It shows the reason properly, but it wont show the admin name correctly (As you can see it changes each time i do the command)
Код:
dcmd_mute1(playerid, cmdtext[])
{
new tmp[256], index;
new reason[256];
new string[256];
new pname[256];
//GetPlayerName(playerid, pname, 64);
tmp = strtok(cmdtext, index);
reason = strrest(cmdtext, index);
if (!strlen(tmp))
{
SendErrMsg(playerid, "Usage: /mute [id] [reason] (Optional)");
return 1;
}
new lookupid;
if(NameLookup(playerid,tmp,lookupid,1) != 1) return 1;
if (!IsPlayerConnected(lookupid))
{
SendErrMsg(playerid, "Player is not connected");
return 1;
}
if (IsPlayerMuted(lookupid))
{
SendErrMsg(playerid, "Player is already muted");
return 1;
}
format(pname, sizeof(pname), "%s", PlayerName(playerid));
if (!strlen(reason))
{
UserData[lookupid][pMuted] = 1;
format(string, sizeof(string), "Player %s (ID:%d) has been muted", PlayerName(lookupid), lookupid);
AdminMsg(string);
format(string, sizeof(string), "[muted] %s %d %s %d", PlayerName(lookupid), lookupid, PlayerName(playerid), playerid);
WriteEcho(string);
set(UserData[lookupid][pMuteName], pname);
set(UserData[lookupid][pMuteReason], "No reason given");
return 1;
}
UserData[lookupid][pMuted] = 1;
format(string, sizeof(string), "Player %s (ID:%d) has been muted: %s", PlayerName(lookupid), lookupid, reason);
AdminMsg(string);
format(string, sizeof(string), "[muted] %s %d %s %d %s", PlayerName(lookupid), lookupid, PlayerName(playerid), playerid, reason);
WriteEcho(string);
set(UserData[lookupid][pMuteName], pname);
set(UserData[lookupid][pMuteReason], reason);
format(string, sizeof(string), "Name is: %s", UserData[lookupid][pMuteName]);
SendMsg(playerid, string);
return 1;
}
And heres the /mutelist command..
Код:
dcmd_mutelist(playerid, cmdtext[])
{
#pragma unused cmdtext
new totalmutes;
new str[256];
if (GlobalData[gChatOff] == 1)
{
SendMsg(playerid, "All players are currently muted");
return 1;
}
SendMsg(playerid, "These players are muted:");
for (new i; i < MAX_PLAYERS; i++)
{
if (IsPlayerConnected(i))
{
if (IsPlayerMuted(i))
{
format(str, sizeof(str), "* %s (ID:%d) (%s) (%s)", PlayerName(i), i, UserData[i][pMuteName], UserData[i][pMuteReason]);
SendMsg(playerid, str);
totalmutes++;
}
}
}
if (totalmutes < 1)
{
SendMsg(playerid, "There are currently no muted players");
}
if (totalmutes > 0)
{
format(str, sizeof(str), "Total muted players: %d", totalmutes);
SendMsg(playerid, str);
}
return 1;
}
cheers

