Quote:
Originally Posted by bigdaddy424
when dealing with fractional numbers you have to use a Float variables otherwise result will not be as expected
new Float:pi = 3.14
|
PHP Code:
public iSelect_Periodo(id)
{
if (!is_user_connected(id))
return PLUGIN_HANDLED;
new iCash = GetUserCash(id);
new iNameItem[32];
ArrayGetString(iArrayItemName, iNextShopItem[id], iNameItem, sizeof(iNameItem));
new iCostItem = GetArrayInfo(iNextShopItem[id], INFO_COST);
//new iMoedaItem = GetArrayInfo(iNextShopItem[id], INFO_MOEDA);
new szTitle[228];
formatex(szTitle, charsmax(szTitle), "\d%s Quantos dias você quer? ^n\r» \yCash:\d %i^n^n\w Item Selecionado:\y %s", PREFIXMENU, iCash, iNameItem);
new iMenu = menu_create(szTitle, "_iSelect_Periodo");
new iCheckCost[4][128], iCheckCost2[4][128];
new iDuration[4] = {1, 7, 30, 90};
for (new i = 0; i < 4; i++) {
new iCalCashPercent = CalculaDia(iCostItem, iDuration[i]);
iCheckCost[i][0] = GetUserCash(id) < iCalCashPercent ? 'd' : 'w';
iCheckCost2[i][0] = GetUserCash(id) < iCalCashPercent ? 'd' : 'r';
formatex(szTitle, charsmax(szTitle), "\%c %i Dias\%c [ Cash: %i ]", iCheckCost[i][0], iDuration[i], iCheckCost2[i][0], iCalCashPercent);
menu_additem(iMenu, szTitle, fmt("%d", i+1), 0);
}
menu_setprop(iMenu, MPROP_EXITNAME, "\d Cancelar Compra");
menu_display(id, iMenu, 0);
return PLUGIN_HANDLED;
}
I discovered something using if and for
in the original code if is used to calculate value
in the for I need to add inside the loop