Duel command problem
#10

pawn Код:
CMD:duel (playerid, params[])
{
    if(gIsDuelActive == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"A duel is already active!");
    if(PlayerInfo[playerid][IsInDuel]) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You are already in a duel!");
    new giveid;
    if(sscanf(params, "u", giveid)) return SendClientMessage(playerid, -1, ""RED"USAGE: "WHITE"/duel [ID]");
    if(giveid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"Invalid player ID!");
    if(PlayerInfo[giveid][NoDuelRequests] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player has duel requests disabled!");
    if(PlayerInfo[giveid][IsWaiting] == 1) return SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"The player is waiting for another duel!");
    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");
    PlayerInfo[playerid][IsWaiting] = 1;
    PlayerInfo[playerid][DuelTargetID] = giveid;
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_CHOOSE_WEAPON)
    {
        if(response)
        {
            new weapon, duelstr[128], gunname[32];
            switch(listitem)
            {
                case 0: weapon = 24;
                case 1: weapon = 26;
                case 2: weapon = 27;
                case 3: weapon = 28;
                case 4: weapon = 31;
                case 5: weapon = 25;
            }
            gCurrentDuelWeaponID = weapon;
            //I'm not sure if you're meant to be using a global variable for this, so I'll leave it for you to decide.
            GetWeaponName(weapon, gunname, sizeof(gunname));
            format(duelstr, sizeof(duelstr), ""RED"[DUEL] "LIGHTBLUE"%s(%d) has challenged you to a duel with a "PREMIUM"%s"LIGHTBLUE"! (Use /accept or /deny)", GetName(playerid), playerid, gunname);
            SendClientMessage(PlayerInfo[playerid][DuelTargetID], -1, duelstr);
            PlayerInfo[PlayerInfo[playerid][DuelTargetID]][IsWaiting] = 1;
        }
        return 1;
    }
    return 0; //OnDialogResponse should return 0, not 1.
}
Reply


Messages In This Thread
Duel command problem - by SyntaxQ - 24.05.2014, 04:21
Re: Duel command problem - by Stinged - 24.05.2014, 05:00
Re: Duel command problem - by SyntaxQ - 24.05.2014, 05:17
Re: Duel command problem - by JM_Millers - 24.05.2014, 05:26
Re: Duel command problem - by JM_Millers - 24.05.2014, 05:31
Re: Duel command problem - by JM_Millers - 24.05.2014, 05:43
Re: Duel command problem - by SyntaxQ - 24.05.2014, 05:55
Re: Duel command problem - by JM_Millers - 24.05.2014, 06:00
Re: Duel command problem - by JM_Millers - 24.05.2014, 06:03
Re: Duel command problem - by Threshold - 24.05.2014, 06:05

Forum Jump:


Users browsing this thread: 1 Guest(s)