Jump to content

Sistema Duel version by Yudin


khain.dev

Recommended Posts

Salut, astazi o sa va invat cum sa faceti un sistem de duel intre doi jucatori,deci sa incepem! Daca o sa aveti intrebari le astept in comentarii
 
Citat

//Ne ducem in OnPlayerConnect
    DuelOffer[playerid] = -1;
    timeduel[playerid] = 11;  

 

Citat

//Creem comanda ("/duel")
CMD:duel(playerid, params[])
{
    new id, cash, string[400];
    if(GetPVarInt(playerid, "antifloodduel") > gettime())return SendClientMessage(playerid, -1, "Poti sa propui duel cu interval intr-un minut!");
    if(sscanf(params, "ii", id, cash))return SendClientMessage(playerid, -1, "Scrie: /duel [id jucator] [bani]");
    if(!ProxDetectorS(10, playerid, id))return SendClientMessage(playerid, -1, "Sunteti departe unul de altul!");
    if(DuelOffer[id] != -1)return SendClientMessage(playerid, -1, "Acest jucator deja a primit o cerere de duel!");
    if(DuelOffer[id] == playerid)return SendClientMessage(playerid, -1, "Deja ati propus acestui jucator!");
    if(cash < 1000 || cash > 10000)return SendClientMessage(playerid, -1, "Rata trebuie sa fie dinte 1.000$ pina 10.000$!");
    if(playerid == id)return SendClientMessage(playerid, -1, "Ati introdus ID-ul dvs.!");
    new bool: gun = false;
    new ammo, gunid;
    new ammo2, gunid2;
    for(new i; i < 13; i ++)
    {
        GetPlayerWeaponData(id, i, gunid, ammo);
        GetPlayerWeaponData(playerid, i, gunid2, ammo2);
        if(!gunid || !ammo) continue;
        if(!gunid2 || !ammo2) continue;
        gun = true;
        break;
    }
    if(!gun)return SendClientMessage(playerid, -1, "Dumneavoastra sau adversarul nu are arma!");
    SendClientMessage(playerid, -1, "Ai dat cerere acestui jucator de duel!");
    new Name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
    f("Jucatorul {FFD700}%s[%d] {ffffff}va propune un duel cu rata de{FFD700}%d${ffffff}!", Name, playerid, cash);
    ShowPlayerDialog(id, 3000, 0, "Duel", string, "Accept", "Close");
    DuelOffer[id] = playerid;
    DuelCash[id] = cash;
    DuelCash[playerid] = cash;
    DuelOffer[playerid] = id;
    return true;
}

Citat

//Ne ducem in OnPlayerDialogResponse
      case 1: ( voi introduceti alta,sar putea deja sa aveti un case cu acest numar )
        {
            new id = DuelOffer[playerid];
            if(!response)
            {
                SendClientMessage(id, -1, "Jucatorul a refuzat duelul cu dvs.!");
                SendClientMessage(playerid, -1, "Ai refuzat sa participi la duel!");
                DuelOffer[playerid] = -1;
                DuelOffer[id] = -1;
                DuelCash[id] = 0;
                DuelCash[playerid] = 0;
                return true;
            }
            if(!ProxDetectorS(10, playerid, id))
            {
                DuelOffer[playerid] = -1;
                DuelOffer[id] = -1;
                DuelCash[id] = 0;
                DuelCash[playerid] = 0;
                SendClientMessage(playerid, -1, "Sunteti departe unul de altul!");
                return true;
            }
            if(GetMoney(playerid) < DuelCash[playerid] || GetMoney(id) < DuelCash[playerid])
            {
                SendClientMessage(playerid, -1, "Acest jucatoru nu are destui bani!");
                                SendClientMessage(id, -1, "Acest jucator nu are destui bani!");
                DuelOffer[playerid] = -1;
                DuelOffer[id] = -1;
                DuelCash[id] = 0;
                DuelCash[playerid] = 0;
                return true;
            }
            SendClientMessage(playerid, -1, "Ati acceptat duelul,el se va incepe in timp de 10 secunde.");
            SendClientMessage(id, -1, "Jucatorul a acceptat duelul,duelul se va incepe in timp de 10 secunde.");
            DuelTimer[playerid] = SetTimerEx("DuelOn", 1000, true, "ii", playerid, id);
            SetPVarInt(playerid, "antifloodduel", gettime()+60);
            TogglePlayerControllable(playerid, 0);
            TogglePlayerControllable(id, 0);
        }

Citat

//in orice loc al modului chiar si la sfirsit
forward DuelOn(playerid, id);
public DuelOn(playerid, id)
{
    new string[50];
    timeduel[playerid]--;
    f("~g~Duel: %d", timeduel[playerid]);
    GameTextForPlayer(playerid, string, 1000, 3);
    GameTextForPlayer(id, string, 1000, 3);
    if(timeduel[playerid] <= 0)
    {
        if(!IsPlayerConnected[id] || !IsPlayerConnected[playerid])
        {
            SendClientMessage(id, -1, "Unul din jucatori a iesit!");
            SendClientMessage(playerid, -1, "Unul din jucatori a iesit!");
            KillTimer(DuelTimer[playerid]);
            timeduel[playerid] = 11;
            DuelOffer[playerid] = -1;
            DuelOffer[id] = -1;
            DuelCash[id] = 0;
            DuelCash[playerid] = 0;
            return false;
        }
        KillTimer(DuelTimer[playerid]);
        timeduel[playerid] = 11;
        SendClientMessage(playerid, -1, "Duelul a inceput!");
        SendClientMessage(id, -1, "Duelul a inceput!");
        TogglePlayerControllable(id, 1);
        TogglePlayerControllable(playerid, 1);
    }
    return true;
}  

Citat

//Ne ducem in OnPlayerDeath
    if(DuelOffer[playerid] == killerid && DuelOffer[killerid] == playerid)
    {
        SendClientMessage(playerid, -1, "Ati pierdut in duel!");
        f("Felicitari! Ai cistigat in duel si ai primit %d$.", DuelCash[playerid]);
        SendClientMessage(killerid, -1, string);
        GivePlayerMoney(killerid, DuelCash[playerid]);
        GivePlayerMoney(playerid, -DuelCash[playerid]);
        DuelOffer[playerid] = -1;
        DuelOffer[killerid] = -1;
        DuelCash[killerid] = 0;
        DuelCash[playerid] = 0;
    }  

//Ne ducem in OnPlayerDisconnect
    if(DuelOffer[playerid] != -1)
    {
        new id = DuelOffer[playerid];
        SendClientMessage(id, -1, "Jucatorul a iesit!");
        KillTimer(DuelTimer[playerid]);
        timeduel[playerid] = 11;
        DuelOffer[playerid] = -1;
        DuelOffer[id] = -1;
        DuelCash[id] = 0;
        DuelCash[playerid] = 0;
    }  

//
#define f(              format(string, sizeof(string),

stock ProxDetectorS(Float:radi, playerid, targetid, spec = 0)
{
    new Float:p[3];
    if(!IsPlayerConnected(playerid)) return false;
    if(!IsPlayerConnected(targetid)) return false;
    if(!spec)
    {
        if(GetPlayerState(playerid) == 9) return false;
        if(GetPlayerState(targetid) == 9) return false;
    }
    if(!GetPlayerPos(targetid, p[0], p[1], p[2])) return false;
    if(!IsPlayerInRangeOfPoint(playerid, radi, p[0], p[1], p[2])) return false;
    return true;
}  

Mersi de atentie,astept macar un "+" de staruinta ?

Edited by #Yudin
  • Like 1
  • Upvote 1
[ Anti Flood Pack ] / Click [ Pugb SA:MP ] Click / [ TD Autorizatie ] Click
[ Created dm zone ] Click / [ Salvare vreme si timp ] Click [ Statistica a serverului ] Click
[ Sistema duel ] Click [ TD Registrare/Autorizatie ] Click [ Sistema kill/killed by ] Click
[ Sistema data si ora Click /  [ GM Anticheat ] Click   /  [ Schimbarea mersului ] Click
[ Save Camera ] Click  [ Sitema Concurs ] Click [ Projector pentru elicopter ] Click /
[ DM Zona ] Click / [ Folosirea textelor lungi ] Click / [Khain RPG] Click  / Antisobeit Click
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.