Duel command help
#3

Use sscanf, it'll make your life easier.

pawn Код:
CMD:duel(playerid, params[])
{
    new id, weapon;
    if(sscanf(params, "ud", id, weapon)) return SendClientMessage(playerid, red, "USAGE: /duel [ID] [Weapon].");
 
    if(!IsPlayerConnected(id))return SendClientMessage(playerid, red, "Player is not connected.");
    if(DND[id] == 1)return SendClientMessage(playerid, red, "Player is in DND mode.");
    if(PlayerInfo[playerid][Jailed] == 1) return SendClientMessage(playerid, red, "You're jailed and can't send duel requests.");
    if(PlayerInfo[id][Jailed] == 1) return SendClientMessage(playerid, red, "Target is jailed, you can't send him duel requests.");
    if(PlayerInfo[id][OnDuty] == 1)return SendClientMessage(playerid, red, "Player is on admin duty.");
    if(playerid == id)return SendClientMessage(playerid, red, "You cannot duel yourself!");
    if(dueling[id] == 1)return SendClientMessage(playerid, red, "Player is already dueling!");
           
    new wepid = GetWeaponIDFromName(wep);

    if(wepid == -1)return SendClientMessage(playerid, red, "That weapon doesn't exist.");

    if(wepid == 38)return SendClientMessage(playerid, red, "You cannot duel with a minigun!");

    if(wepid == 44)return SendClientMessage(playerid, red, "You cannot duel with this weapon!");

    if(wepid == 45)return SendClientMessage(playerid, red, "You cannot duel with this weapon!");

    if(wepid == 43)return SendClientMessage(playerid, red, "You cannot duel with a camera!");

    if(wepid == 0)return SendClientMessage(playerid, red, "Invalid weapon!");
   
    DuelInfo[id][playa] = playerid;
    DuelInfo[id][weapon] = wepid;
    new playermsg[128];
    new string[128];
    format(playermsg, 255, "%s has requested to duel %s. Weapon: %s.",PlayerName2(playerid),PlayerName2(id),wep);
    SendClientMessage(playerid, COLOR_YELLOW, playermsg);
    SendClientMessage(id, COLOR_YELLOW, playermsg);
    ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"Duel",string,"Accept","Ignore");
    return 1;
}
EDIT:

You could also make your code more efficient by doing things like this:

pawn Код:
if(wepid == 38 || wepid == 44  || wepid == 45 || wepid == 43)return SendClientMessage(playerid, red, "You cannot duel with this weapon!");
Reply


Messages In This Thread
Duel command help - by Ryz - 16.10.2014, 17:38
Re: Duel command help - by Sawalha - 16.10.2014, 18:35
Re: Duel command help - by TakeiT - 17.10.2014, 00:50
Re: Duel command help - by Ryz - 17.10.2014, 03:37
Re: Duel command help - by TakeiT - 17.10.2014, 03:55
Re: Duel command help - by Ryz - 17.10.2014, 03:58
Re: Duel command help - by Ryz - 17.10.2014, 17:36

Forum Jump:


Users browsing this thread: 1 Guest(s)