[HELP]Duel system
#1

hi I found this fs, I translated it and I've changed. Now I would like to know how to put weapons in the form of name instead of id

Код:
#include <a_samp>



#define DIALOG_DUEL 24245
new
    bool:InvitedDuel[MAX_PLAYERS],
    IdDuel[MAX_PLAYERS],
    wep1[MAX_PLAYERS],
    wep2[MAX_PLAYERS],
    bool:UsingArena,
    Counting = 5,
    CountDueling[5][5] ={"~r~1","~b~2","~p~3","~y~4","~g~5"}
;
forward ExecuteCount(playerid,pid);
public ExecuteCount(playerid,pid)
{
    if (Counting > 0)
    {
        GameTextForPlayer(playerid,CountDueling[Counting-1], 2500, 3);
        GameTextForPlayer(pid,CountDueling[Counting-1], 1000, 3);
        Counting--;
        SetTimerEx("GoDuel",1000,false,"ii",playerid,pid);
    }
    else
    {
        GameTextForPlayer(playerid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
        GameTextForPlayer(pid,"~>~~g~Go~w~Go~r~Go~b~Go~<~", 2500, 3);
        Counting = 5;
        TogglePlayerControllable(playerid,true);
        TogglePlayerControllable(pid,true);
    }
    return true;
}


public OnPlayerCommandText(playerid, cmdtext[])
{
    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]«« : Richiesta inviata. Aspetta che l'utente accetti");

        if(UsingArena == true)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Al momento l'arena и in uso");

        if(!IsValidWeapon(w1) || !IsValidWeapon(w2))
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Usa /duel [id] [weap1][weap2]");

        if(!strlen(tmp[1]) || !strlen(tmp[2]))
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Usa /duel [id] [wep1] [wep2]");

        if(!strlen(tmp[0]))
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Inserisci l'id del player che vuoi sfidare (/duel [playerid])");

        if(id == playerid)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Non puoi mandare una richiesta a te stesso");

        if(InvitedDuel[id] == true)
            return SendClientMessage(playerid,0xF41917AA,"»»[DUEL]«« : Il player и occupato.. Attendi un pт");

        new name[24];
        GetPlayerName(playerid, name, sizeof(name));
        format(string, sizeof(string), "»»[DUEL]«« : %s ti ha invitato \n Duello (Premi accetta per giocare)",name);
        ShowPlayerDialog(id,DIALOG_DUEL,DIALOG_STYLE_MSGBOX,"»»[DUEL]«« :",string,"Accetta", "No");
        GameTextForPlayer(id,"~r~DUE~w~L !", 2500, 3);
        IdDuel[id] = playerid;
        wep1[id] = w1;
        wep2[id] = w2;
        SetTimerEx("ExpireDuel",15000,false,"ii",id,playerid);
        return true;
    }
    return false;
}


forward GoDuel(playerid,pid,w1,w2);
public GoDuel(playerid,pid,w1,w2)
{


    //-> Go To  X1 <-//
    SetPlayerPos(playerid,938,-2977,138);
    SetPlayerPos(pid,1040,-2893,138);
    SetPlayerArmour(playerid,100);
    SetPlayerArmour(pid,100);
    SetPlayerHealth(playerid,100);
    SetPlayerHealth(pid,100);

    GivePlayerWeapon(playerid,w1,5000);
    GivePlayerWeapon(playerid,w2,5000);
    GivePlayerWeapon(pid,w1,5000);
    GivePlayerWeapon(pid,w2,5000);
    
    SetPlayerVirtualWorld(playerid, 10);
    SetPlayerVirtualWorld(pid, 10);
    
    InvitedDuel[playerid] = true;
    InvitedDuel[pid] = true;
    TogglePlayerControllable(playerid,false);
    TogglePlayerControllable(pid,false);
    ExecuteCount(playerid,pid);
    return true;
}


forward ExpireDuel(playerid,pid);
public ExpireDuel(playerid,pid)
{
    if(UsingArena == false)
    {
        SendClientMessage(pid,0x1DF6F6AA,"»»[DUEL]«« : Richiesta rifiutata");
        SendClientMessage(playerid,0x1DF6F6AA,"»»[DUEL]«« : Richiesta rifiutata automaticamente");
        InvitedDuel[pid] = false;
        InvitedDuel[playerid] = false;
        IdDuel[playerid] = playerid;
        IdDuel[pid] = pid;
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerVirtualWorld(pid, 0);
    }
    return true;
}


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_DUEL)
    {
        if(!response) return ExpireDuel(playerid,IdDuel[playerid]);
        if(response)
        {
            UsingArena = true;
            new name[MAX_PLAYER_NAME], string[44];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "»»[DUEL]«« : %s ha accettato.",name);
            SendClientMessage(IdDuel[playerid],0xF6F600AA,string);
            SendClientMessage(playerid,0xF6F600AA,"»»[DUEL]«« : Hai accettato la richiesta.");
            SetTimerEx("GoDuel",8000,false,"ii",playerid,IdDuel[playerid],wep1[playerid],wep2[playerid]);
        }
        return true;
    }
    return true;
}

public OnPlayerDisconnect(playerid,reason)
{
    if(InvitedDuel[playerid] == true)
    {
        for(new killerid; killerid < MAX_PLAYERS; killerid++) if(IsPlayerConnected(killerid) && InvitedDuel[killerid] == true)
        {
            new Float:healthkiller;
            new namekiller[24],namedeather[24],string[44];
            GetPlayerName(killerid, namekiller, 24);
            GetPlayerName(playerid, namedeather, 24);
            GetPlayerHealth(killerid,healthkiller);
            format(string, sizeof(string), "»»[DUEL]«« : %s ha vinto il duello contro %s con %0.0f di Armour ed Health",namekiller,namedeather,healthkiller);
            SendClientMessageToAll(0xF600F6AA, string);
            InvitedDuel[killerid] = false;
            InvitedDuel[playerid] = false;
            IdDuel[playerid] = playerid;
            IdDuel[killerid] = killerid;
            UsingArena = false;
            healthkiller = 0;
            SpawnPlayer(killerid);
            SetPlayerVirtualWorld(playerid, 0);
            SetPlayerVirtualWorld(killerid, 0);
        }
    }
    return true;
}
public OnPlayerDeath(playerid, killerid, reason)
{
    if(InvitedDuel[killerid] == true)
    {
        new Float:healthkiller;
        new namekiller[24],namedeather[24],string[44];
        GetPlayerName(killerid, namekiller, 24);
        GetPlayerName(playerid, namedeather, 24);
        GetPlayerHealth(killerid,healthkiller);
        format(string, sizeof(string), "»»[DUEL]«« : %s ha vinto il duello contro %s con %0.0f di Armour ed Health",namekiller,namedeather,healthkiller);
        SendClientMessageToAll(0xF600F6AA, string);
        InvitedDuel[killerid] = false;
        InvitedDuel[playerid] = false;
        IdDuel[playerid] = playerid;
        IdDuel[killerid] = killerid;
        UsingArena = false;
        healthkiller = 0;
        SpawnPlayer(killerid);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerVirtualWorld(killerid, 0);

    }
    return true;
}

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


Forum Jump:


Users browsing this thread: 1 Guest(s)