simple cmd to dcmd, help
#1

can someone make a dcmd command from this? please


pawn Код:
new cmd[128],idx;

    cmd = strtok(cmdtext, idx);
    if(!strcmp("/duel", cmd, true))
    {
        new id,tmp[3][80],w1,w2,string[128];

        tmp[0] = strtok(cmdtext, idx);
        tmp[1] = strtok(cmdtext, idx);
        tmp[2] = strtok(cmdtext, idx);
       
        id = strval(tmp[0]);
        w1 = strval(tmp[1]);
        w2 = strval(tmp[2]);
       
        if(InvitedDuel[playerid] == true)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");

        if(UsingArena == true)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");

        if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
           
        if(!strlen(tmp[1]) || !strlen(tmp[2]))
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
           
        if(!strlen(tmp[0]))
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");

        if(id == playerid)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");

        if(InvitedDuel[id] == true)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
           
        new name[24];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
        ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
        GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
        IdDuel[id] = playerid;
        wep1[id] = w1;
        wep2[id] = w2;
        SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
        return true;
    }
    return false;
}
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(duel,4,cmdtext);
    return 0;
}

dcmd_duel(playerid, params[])
{
    new id,tmp[3][80],w1,w2,string[128];
    new Index;
    tmp[0] = strtok(params, Index);
    tmp[1] = strtok(params, Index);
    tmp[2] = strtok(params, Index);
       
    id = strval(tmp[0]);
    w1 = strval(tmp[1]);
    w2 = strval(tmp[2]);
       
    if(InvitedDuel[playerid] == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");

    if(UsingArena == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");

    if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
           
    if(!strlen(tmp[1]) || !strlen(tmp[2]))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
           
    if(!strlen(tmp[0]))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");

    if(id == playerid)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");

    if(InvitedDuel[id] == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
           
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
    ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
    GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
    IdDuel[id] = playerid;
    wep1[id] = w1;
    wep2[id] = w2;
    SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
    return true;
}
EDIT: Better use ZCMD for better speeds
Reply
#3

Код:
error 047: array sizes do not match, or destination array is too small
 error 047: array sizes do not match, or destination array is too small
error 047: array sizes do not match, or destination array is too small
here:

pawn Код:
tmp[0] = strtok(params, Index);
    tmp[1] = strtok(params, Index);
    tmp[2] = strtok(params, Index);
Reply
#4

help please -_-
Reply
#5

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(duel,4,cmdtext);
    return 0;
}

dcmd_duel(playerid, params[])
{
    new id,w1,w2,string[128];
    new Index;
    new tmp[256], tmp2[256], tmp3[256];
    tmp = strtok(params, Index);
    tmp2 = strtok(params, Index);
    tmp3 = strtok(params, Index);
       
    id = strval(tmp);
    w1 = strval(tmp2);
    w2 = strval(tmp3);
       
    if(InvitedDuel[playerid] == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");

    if(UsingArena == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");

    if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
           
    if(!strlen(tmp2) || !strlen(tmp3))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
           
    if(!strlen(tmp))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");

    if(id == playerid)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");

    if(InvitedDuel[id] == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
           
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
    ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
    GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
    IdDuel[id] = playerid;
    wep1[id] = w1;
    wep2[id] = w2;
    SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
    return true;
}
Now?
Reply
#6

ty, now its okey, but when i type /pvp playerid weapon weapon, i get text:

Use /duel [id] [wep1] [wep2]
or, Use Valids Weapons IDs...

whats wrong?

i think that problem is here:

pawn Код:
IsValidWeapon(weaponid)
{
        new badWeapon[21] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 40, 44, 45, 46};
        for(new i=0; i <20; i++)
            if (weaponid == badWeapon[i])
                return false;
        return true;
}
Reply
#7

Quote:
Originally Posted by Mean
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    dcmd(duel,4,cmdtext);
    return 0;
}

dcmd_duel(playerid, params[])
{
    new id,tmp[3][80],w1,w2,string[128];
    new Index;
    tmp[0] = strtok(params, Index);
    tmp[1] = strtok(params, Index);
    tmp[2] = strtok(params, Index);
       
    id = strval(tmp[0]);
    w1 = strval(tmp[1]);
    w2 = strval(tmp[2]);
       
    if(InvitedDuel[playerid] == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Have you invited someone, wait Expire Invitation");

    if(UsingArena == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : At the time the Arena is Being Used");

    if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use Valids Weapons IDs");
           
    if(!strlen(tmp[1]) || !strlen(tmp[2]))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Use /duel [id] [wep1] [wep2]");
           
    if(!strlen(tmp[0]))
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You must enter the ID of the player following the Way (/duel [playerid])");

    if(id == playerid)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : You can not invite the Self");

    if(InvitedDuel[id] == true)
        return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Currently the player is in a Duel, wait..");
           
    new name[24];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "»»[DUEL]«« : %s This inviting you to a \n Duel Runing (Press Accept to Accept Duel)",name);
    ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accept", "No");
    GameTextForPlayer(id,"~r~DUE~w~LO !", 2500, 3);
    IdDuel[id] = playerid;
    wep1[id] = w1;
    wep2[id] = w2;
    SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
    return true;
}
EDIT: Better use ZCMD for better speeds
Using DCMD or ZCMD woudn't make any sence when you're still using strtok.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)