Jump to content

Recommended Posts

Posted (edited)

Salut, am decis sa postez acest tutorial pentru ce incepatori(ca mine) o sa incerc sa explic cat mai bine

Prima data vom face dialog- urile pentru /buycrate si /opencrate o sa avem nevoie de ele mai tarziu

avem nevoie de culori:

#define COLOR_ERROR         0xC0241FFF
#define COLOR_GOLD          0xFFB95EFF

aici dialog-urile

enum
{
	DIALOG_OPENCRATE,
	DIALOG_BUYCRATE
};

acum mergem la enum pinfo pentru a enumera crate urile in sine si premium points

enum pInfo {
	pPremiumPoints,
	pCrateBasic,    //aici puteti inlocui voi numele la crate urile dorite ex : pCrateExtra dar va sugerez
	pCrateRare,		//sa lasati asa cum am pus eu pentru a nu avea probleme
	pCrateEpic,
	pCrateLegendary
};
new PlayerInfo[MAX_PLAYERS][pInfo];

acum vom face comenzile opencrate si buycrate

CMD:buycrate(playerid, params[]) return ShowPlayerDialog(playerid, DIALOG_BUYCRATE, DIALOG_STYLE_LIST, "Poti cumpara urmatoarele crate-uri:", "Basic Crate - 25 Premium Points\nRare Crate - 50 Premium Points\nEpic Crate - 100 PremiumPoints\nLegendary Crate - 200 Premium Points", "Buy", "Cancel");
CMD:opencrate(playerid, params[]) {
	ShowPlayerDialog(playerid, DIALOG_OPENCRATE, DIALOG_STYLE_LIST, "Deschide un crate!", "Basic Crate\nRare Crate\nEpic Crate\nLegendary Crate", "Open", "Cancel");
	cratestats(playerid); //aceasta este o functie pe care o sa o scriem imediat
	return 1;
}

acum sa trecem la functii

function cratestats(playerid) {
	new string[256], basic, rare, epic, legendary;
	basic = PlayerInfo[playerid][pCrateBasic];
	rare = PlayerInfo[playerid][pCrateRare];
	epic = PlayerInfo[playerid][pCrateEpic];
	legendary = PlayerInfo[playerid][pCrateLegendary];
	format(string, sizeof(string), "Crates: Basic: %d, Rare: %d, Epic: %d, Legendary: %d", basic, rare, epic, legendary);
	SCM(playerid, -1, string);
	return 1;
}

aceasta functie ne ajuta sa dan premiile la crates random

stock RandomChange( rare, most, probability )
{
    new NMB = random( probability ) ? most : rare;
    printf( "[RandomChange] generated the number: %d with( rare: %d, most: %d, probability: %d )", NMB, rare, most, probability );
    return NMB;
}
stock randomEx( const r_min, const r_max )
{
    new rand = random( r_max - r_min) + r_min;
    return rand;
}

aceste doua functii ne vor ajuta sa dam premiile de la crates random 

function opencrateb(playerid)
{
    new money = 100000 + random(3000000); //aici puteti schimba sumele 
    new pp = 2 + random(5); //si aici
    new fhp = 12 + random(20); // si aici
    PlayerInfo[playerid][pFreshPoints] += fhp; //eu am freshpoints voi puteti sa stergeti aceasta functie
    PlayerInfo[playerid][pPremiumPoints] += pp;
    new string[100];
    format(string, sizeof(string), "(Crate Info): Ai primit $ %d, %d Premium Points si %d Fresh Points pentru ca ai deschis un crate basic,", money, pp, fhp); //aici ne arata cat primim la deschidere adica premiul
    SCM(playerid, COLOR_YELLOW, string);
    return 1;
}

function opencrater(playerid)
{
    new money = 500000 + random(6000000); 
    new pp = 5 + random(10);
    new fhp = 20 + random(37);
    PlayerInfo[playerid][pFreshPoints] += fhp;
    PlayerInfo[playerid][pPremiumPoints] += pp;
    new string[100];
    format(string, sizeof(string), "(Crate Info): Ai primit $ %d, %d Premium Points si %d Fresh Points pentru ca ai deschis un crate basic,", money, pp, fhp); // il anuntam ca a prins un peste si cat costa acesta
    SCM(playerid, COLOR_YELLOW, string);
    return 1;
}

function opencratee(playerid)
{
    new money = 1000000 + random(10000000); 
    new pp = 10 + random(25);
    new fhp = 25 + random(50);
    PlayerInfo[playerid][pFreshPoints] += fhp;
    PlayerInfo[playerid][pPremiumPoints] += pp;
    new string[100];
    format(string, sizeof(string), "(Crate Info): Ai primit $ %d, %d Premium Points si %d Fresh Points pentru ca ai deschis un crate basic,", money, pp, fhp); // il anuntam ca a prins un peste si cat costa acesta
    SCM(playerid, COLOR_YELLOW, string);
    return 1;
}

function opencratel(playerid)
{
    new money = 10000000 + random(30000000); 
    new pp = 30 + random(65);
    new fhp = 50 + random(100);
    PlayerInfo[playerid][pFreshPoints] += fhp;
    PlayerInfo[playerid][pPremiumPoints] += pp;
    new string[100];
    format(string, sizeof(string), "(Crate Info): Ai primit $ %d, %d Premium Points si %d Fresh Points pentru ca ai deschis un crate basic,", money, pp, fhp); // il anuntam ca a prins un peste si cat costa acesta
    SCM(playerid, COLOR_YELLOW, string);
    return 1;
}

eu am pus opencratee sau asa acel "e" sau "b" fiind considerat b = basic, r= rare si tot asa

Va propun sa fiti foarte atenti cum am scris eu se poate sa fiu mici greseli de ex la acele // stergetile in gm dupa ce terminati cu codul

Bun, acum ca am facut functiile de deschidere a crate urilor haideti sa continuam prin asta:

la Public OnDialogResponse punem switch(dialogid)

adica:

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) 
{
	switch (dialogid)
	{
		
	}
}

si in acel switch dialogid punem:

case DIALOG_BUYCRATE:
        {
        	switch(listitem)
        	{
        		case 0: {
        			if(PlayerInfo[playerid][pCrateBasic] > 9) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu poti avea mai mult de 10 Crate uri 					 odata");
        			if(PlayerInfo[playerid][pPremiumPoints] < 25) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai destule Premium Points.");
        			else
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Ai cumparat basic Crate");
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Foloseste comanda /opencrate pentru a il deschide");
        			PlayerInfo[playerid][pCrateBasic] += 1;
        			PlayerInfo[playerid][pPremiumPoints] -= 25;
        			return 1;
        		}
        		case 1: {
        			if(PlayerInfo[playerid][pCrateRare] > 9) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu poti avea mai mult de 10 Crate uri 				    odata");
        			if(PlayerInfo[playerid][pPremiumPoints] < 50) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai destule Premium Points.");
        			else
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Ai cumparat Rare Crate");
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Foloseste comanda /opencrate pentru a il deschide");
        			PlayerInfo[playerid][pCrateRare] += 1;
        			PlayerInfo[playerid][pPremiumPoints] -= 50;
        			return 1;
        		}
        		case 2: {
        			if(PlayerInfo[playerid][pCrateEpic] > 9) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu poti avea mai mult de 10 Crate uri 					odata");
        			if(PlayerInfo[playerid][pPremiumPoints] < 100) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai destule Premium Points.");
        			else
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Ai cumparat Epic Crate");
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Foloseste comanda /opencrate pentru a il deschide");
        			PlayerInfo[playerid][pCrateEpic] += 1;
        			PlayerInfo[playerid][pPremiumPoints] -= 100;
        		}
        		case 3: {
					if(PlayerInfo[playerid][pCrateLegendary] > 9) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu poti avea mai mult de 10 Crate 					 uri odata");
        			if(PlayerInfo[playerid][pPremiumPoints] < 200) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai destule Premium Points.");
        			else
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Ai cumparat Legendary Crate");
        			SCM(playerid, COLOR_GOLD, "(SERVER):{FFFFFF} Foloseste comanda /opencrate pentru a il deschide");
        			PlayerInfo[playerid][pCrateLegendary] += 1;
        			PlayerInfo[playerid][pPremiumPoints] -= 200;
        		}
        	}
        }

salvarea in data vi o faceti singuri

acum sa facem dialog-ul pentru deschiderea crate urilor:

case DIALOG_OPENCRATE:
        {
        	switch(listitem)
        	{
        		case 0: {
        			if(PlayerInfo[playerid][pCrateBasic] < 1) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai un Basic Crate");
        			else opencrateb(playerid);
        			PlayerInfo[playerid][pCrateBasic] -= 1;
        			return 1;
        		}
        		case 1: {
        			if(PlayerInfo[playerid][pCrateBasic] < 1) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai un Basic Crate");
        			else opencrater(playerid);
        			PlayerInfo[playerid][pCrateRare] -= 1;
        			return 1;
        		}
        		case 2: {
        			if(PlayerInfo[playerid][pCrateBasic] < 1) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai un Basic Crate");
        			else opencratee(playerid);
        			PlayerInfo[playerid][pCrateEpic] -= 1;
        			return 1;
        		}
        		case 3: {
        			if(PlayerInfo[playerid][pCrateBasic] < 1) return SCM(playerid, COLOR_ERROR, "(Eroare):{FFFFFF} Nu ai un Basic Crate");
        			else opencratel(playerid);
        			PlayerInfo[playerid][pCrateLegendary] -= 1;
        			return 1;
        		}
        	}
        

SCRIETI MANUAL, COPY & PASTE NU ARE VALOARE

macar atat sa faceti 

ORICE EROARE MESAJ IN PRIVAT PE DISCORD SAU AICI UN REPLY SI VA AJUT

Edited by ImDariusHere

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.