24.05.2014, 05:43
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case DIALOG_CHOOSE_WEAPON:
{
if !response *then return true;
switch(listitem)
{
case 0: gCurrentDuelWeaponID = 24;
case 1..3: gCurrentDuelWeaponID = 25+listitem;
case 4: gCurrentDuelWeaponID = 31;
case 5: gCurrentDuelWeaponID = 25;
}
format(str, sizeof(str), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you for a duel with "PREMIUM"%s"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid, getWeaponName(.id=gCurrentDuelWeaponID));
SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, str);
PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
}
}
return true;
}
getWeaponName(id)
{
new str[15];
switch(id)
{
case 24: str = "Desert Eagle";
case 25: str = "Shotgun";
case 26: str = "Sawn Off";
case 27: str = "Combat Shotgun";
case 28: str = "Micro SMG/UZI";
case 31: str = "M4";
}
return str;
}
CMD:duel (playerid, params[])
{
if gIsDuelActive == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"A duel is already active!");
if PlayerInfo[playerid][IsInDuel] == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You are already in a duel!");
if sscanf(params, "u", params[0]) *then return SendClientMessage(playerid, -1, ""RED"USAGE: "WHITE"/duel [ID]");
if params[0] == INVALID_PLAYER_ID *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"Invalid player ID!");
if PlayerInfo[params[0]][NoDuelRequests] == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player has duel requests disabled!");
if PlayerInfo[params[0]][IsWaiting] == 1 *then return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player is waiting for another duel!");
PlayerInfo[playerid][IsWaiting] = 1;
PlayerInfo[playerid][DuelTargetID] = params[0];
ShowPlayerDialog(playerid, DIALOG_CHOOSE_WEAPON, DIALOG_STYLE_LIST, ""PREMIUM"Choose weapon for duel:", "• Desert Eagle\n• Sawn Off Shotgun\n• Combat Shotgun\n• Micro SMG/Uzi\n• M4\n• Shotgun", "Select", "Cancel");
return 1;
}