Duel command help
#1

Hey i have made duel system but he always shows one msg 'You cannot duel yourself!'

I show you cmd cods

pawn Код:
CMD:duel(playerid, params[]) {
    new tmp[256], tmp2[256], Index;     tmp = strtok(params,Index), tmp2 = strtok(params,Index);
            if(!strlen(params)) return SendClientMessage(playerid, red, "USAGE: /duel [ID] [Weapon].");
            if(!strlen(tmp2)) return SendClientMessage(playerid, red, "USAGE: /duel [ID] [Weapon].");

    new id;
    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 wep[30];
    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;
}
Reply
#2

You forgot to:
pawn Код:
id = strval(tmp);
Assign the "id" variable to "tmp" value.
Reply
#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
#4

Compiles easy with this cods

pawn Код:
new id, wep[30];
    if(sscanf(params, "us[30]", id, wep ))return SendClientMessage(playerid, red, "USAGE: /duel [ID] [Weapon].");
I will check with 4 players
Reply
#5

Quote:
Originally Posted by Ryz
Посмотреть сообщение
Compiles easy with this cods

pawn Код:
new id, wep[30];
    if(sscanf(params, "us[30]", id, wep ))return SendClientMessage(playerid, red, "USAGE: /duel [ID] [Weapon].");
I will check with 4 players
Why do you have weapon as a string, but you use it as an integer?
Reply
#6

Quote:
Originally Posted by TakeiT
Посмотреть сообщение
Why do you have weapon as a string, but you use it as an integer?
i seen tutorial somewhere

This will work or no?
Reply
#7

Duel system not shows dialog this one

pawn Код:
ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"Duel",string,"Accept","Ignore");
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)