17.12.2010, 23:38
Hey, ill made a fast admin menu, but the "Kick" and the "Mute" is bugged i dont know why...
I dont know how to explain the bug, buy if you add the code to a filterscript, then you can test it by yourself
P.S: Please tell me what i did wrong... So i can learn of my fails :P
I dont know how to explain the bug, buy if you add the code to a filterscript, then you can test it by yourself
P.S: Please tell me what i did wrong... So i can learn of my fails :P
pawn Код:
#include <a_samp>
new tmp[128], adminPlayer[20], Mute[MAX_PLAYERS];
forward Unmute(playerid);
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
if(IsPlayerAdmin(playerid))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Admin Menu", "Kick\nMute\nSet Player Score\nGive Player Money\nCrash Player", "Select", "Cancel");
new id = strval(tmp);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFF0000FF,"Invalid ID");
adminPlayer[playerid] = clickedplayerid;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
if(!response)return SendClientMessage(playerid, 0xFF303EAA,"Error: You have cancelled.");
{
if(listitem == 0) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Kick Menu", "Why do you want to kick him?", "Kick", "Cancel");
else if(listitem == 1) return ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Mute Menu", "Why do you want to mute him?\n(Will be Auto-Unmuted)", "Mute", "Cancel");
else if(listitem == 2) return ShowPlayerDialog(playerid, 4, DIALOG_STYLE_INPUT, "Score Menu", "Enter the new score (numbers)", "Ok", "Cancel");
else if(listitem == 3) return ShowPlayerDialog(playerid, 5, DIALOG_STYLE_INPUT, "Money Menu","Enter how much money you want to give/take from him","ok","Cancel");
else if(listitem == 4) return ShowPlayerDialog(playerid, 6, DIALOG_STYLE_MSGBOX, "Crash Menu", "Do you really want to crash that player?", "Yes", "No");
}
}
//Kick--------------------------------------------------------------------------
if(dialogid == 2)
{
if(response)
{
new playerwhogotkicked[MAX_PLAYER_NAME], string[128];
GetPlayerName(adminPlayer[playerid], playerwhogotkicked, sizeof(playerwhogotkicked));
format(string, sizeof(string), "**(ADMIN KICK)** %s(%d) %s",playerwhogotkicked, playerid, inputtext);
SendClientMessageToAll(0xFF7F0EFF, string);
adminPlayer[playerid] = 0;
Kick(adminPlayer[playerid]);
adminPlayer[playerid] = 0;
} return SendClientMessage(playerid, 0xFF303EAA, "Error: You have cancelled.");
}
//Mute
else if(dialogid == 3)
{
if(response)
{
new playerwhogotmuted[MAX_PLAYER_NAME], string[128];
GetPlayerName(adminPlayer[playerid], playerwhogotmuted, sizeof(playerwhogotmuted));
format(string, sizeof(string), "Admin Mute: %s(%d) %s",playerwhogotmuted, playerid, inputtext);
SendClientMessageToAll(0xFF7F0EFF, string);
adminPlayer[playerid] = 0;
//Mute
Mute[adminPlayer[playerid]] = 1;
adminPlayer[playerid] = 0;
//Timer
SetTimerEx("Unmute",120000,0,"i",adminPlayer[playerid]);
} else return SendClientMessage(playerid, 0xFF303EAA, "Error: You have cancelled.");
}
//Set Player Score--------------------------------------------------------------
else if(dialogid == 4)
{
if(response)
{
if(strlen(inputtext) > 8) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: Your new name was too long. Max: 8 characters");
GetPlayerScore(playerid); SetPlayerScore(adminPlayer[playerid],strval(inputtext));
adminPlayer[playerid] = 0;
} return SendClientMessage(playerid, 0xFF303EAA, "Error: You have cancelled the Score Menu.");
}
//Give Player Money-------------------------------------------------------------
else if(dialogid == 5)
{
if(response)
{
if(strlen(inputtext) > 8) return SendClientMessage(playerid, 0xFFFFFFFF, "ERROR: Your new name was too long. Max: 8 characters");
GetPlayerMoney(playerid); GivePlayerMoney(adminPlayer[playerid],strval(inputtext));
adminPlayer[playerid] = 0;
} return SendClientMessage(playerid, 0xFF303EAA, "Error: You have cancelled the Money Menu.");
}
//Crash Player------------------------------------------------------------------
else if(dialogid == 6)
{
if(response)
{
CrashPlayer(adminPlayer[playerid]);
adminPlayer[playerid] = 0;
} return SendClientMessage(playerid, 0xFF303EAA, "Error: You have cancelled.");
}
return 1;
}
//Mute
public OnPlayerText(playerid, text[])
{
if(Mute[playerid] == 1)
{
SendClientMessage(playerid, 0x007F0EFF, "You Are Muted. You Cannot Chat");
return 0;
}
return 1;
}
//Mute
public OnPlayerDisconnect(playerid, reason)
{
Mute[playerid] = 0;
return 1;
}
//Mute
public Unmute(playerid)
{
new playerwhogotmuted[MAX_PLAYER_NAME], string[128];
GetPlayerName(adminPlayer[playerid], playerwhogotmuted, sizeof(playerwhogotmuted));
format(string, sizeof(string), "Admin Unmute: %s(%d) Read /rules 'n' /commands",playerwhogotmuted, playerid);
SendClientMessageToAll(0xFF7F0EFF, string);
Mute[adminPlayer[playerid]] = 0;
adminPlayer[playerid] = 0;
}
//Crash
stock CrashPlayer(playerid)
{
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 1000, 0);
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 2000, 1);
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 3000, 2);
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 4000, 3);
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 5000, 4);
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 6000, 5);
GameTextForPlayer(playerid, "•¤¶§!$$%&'()*+,-./01~!@#$^&*()_-+={[}]:;'<,>.?/", 7000, 6);
return 1;
}