Jump to content
  • 0

Rata la giftbox


AlexStorm

Question

Problema intalnita (descriere): Salut. Am facut o comanda /getgift. Aceasta comanda ofera random un cadou la un player. O suma de bani, droguri, artificii, materiale etc. Faza e ca eu vreau sa pun si puncte premium sa se castige. Dar vreau sa pice foarte rar. Cum as putea face sa fac o rata.. Adica sa fie sansa 5 la suta de exemplu. Daca ma folosesc de functia random.. se castiga in prostie puncte premium.
Ero(area / rile) / warning-(ul / urile): ---
Liniile de cod / sursa / script-ul(obligatoriu):

new gift = random(3);
					if(gift == 0)
					{
					    new giftbox_minmoney = assetVariables[3][aAssetValue];
					    new giftbox_maxmoney = assetVariables[4][aAssetValue];

						new money = giftbox_minmoney + random(giftbox_maxmoney);

						playerVariables[playerid][pCash] += money;
						Update(playerid, pCashx);
						GivePlayerCash(playerid, money);
						
						format(szMessage, sizeof(szMessage), "* %s won %s from the giftbox.", GetName(playerid), NumberFormat(money));
						nearByMessage(playerid, COLOR_YELLOW, szMessage);
						mysql_format(handle, szLargeString, sizeof(szLargeString), "INSERT INTO playerlogs (text, type, ID) VALUES('%e', 'giftbox', '%d')", szMessage, playerVariables[playerid][pID]);
						mysql_query(handle, szLargeString);
					}
					if(gift == 1)
					{
					    new giftbox_minmats = assetVariables[6][aAssetValue];
					    new giftbox_maxmats = assetVariables[5][aAssetValue];

						new money = giftbox_minmats + random(giftbox_maxmats);

						
						playerVariables[playerid][pMaterials] += money;
			        	Update(playerid, pMaterialsx);

						format(szMessage, sizeof(szMessage), "* %s won %s materials from the giftbox.", GetName(playerid), NumberFormat(money));
						nearByMessage(playerid, COLOR_YELLOW, szMessage);
						mysql_format(handle, szLargeString, sizeof(szLargeString), "INSERT INTO playerlogs (text, type, ID) VALUES('%e', 'giftbox', '%d')", szMessage, playerVariables[playerid][pID]);
						mysql_query(handle, szLargeString);
					}
     				if(gift == 2)
					{
						new money = 15 + random(30);

						playerVariables[playerid][pFireworks] += money;
			        	Update(playerid, pFireworksx);

						format(szMessage, sizeof(szMessage), "* %s won %s fireworks from the giftbox.", GetName(playerid), NumberFormat(money));
						nearByMessage(playerid, COLOR_YELLOW, szMessage);
						mysql_format(handle, szLargeString, sizeof(szLargeString), "INSERT INTO playerlogs (text, type, ID) VALUES('%e', 'giftbox', '%d')", szMessage, playerVariables[playerid][pID]);
						mysql_query(handle, szLargeString);
					}


Imagini / Video (optional): ---
Ati incercat sa rezolvati singur?: Eu am incercat folosind functia random.. dar sunt curios sa imi spuneti voi daca exista alta functie mai buna.

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Guest
This topic is now closed to further replies.
×
×
  • 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.