21.05.2015, 17:51
So, I'm trying to load mb locations from the MySQL db and then when it's time to create mb in a random location, it chooses a random location from the mb locations which are loaded from the database.
Load MB from db
Mb creating
I tried printing the randombag, but it keeps randomizing at 0.
Load MB from db
Код:
public loadMBs()
{
print("loading moneybags initialized");
for(new i = 0; i < cache_get_row_count(mysql); ++i)
{
cache_get_field_content(i, "mbloc", MBInfo[i][mbloc], mysql,128);
MBInfo[i][mbX] = cache_get_field_content_float(i, "mbX", mysql);
MBInfo[i][mbY] = cache_get_field_content_float(i, "mbY", mysql);
MBInfo[i][mbZ] = cache_get_field_content_float(i, "mbZ", mysql);
totalMoneyBags++;
}
printf("%d moneybags loaded!", totalMoneyBags);
mbTimer[1] = SetTimer("MoneyBag", 300000, true);
return 1;
}
Код:
new randombag = random(sizeof(totalMoneyBags));
printf("%d", randombag);
MoneyBagPos[0] = MBInfo[randombag][mbX];
MoneyBagPos[1] = MBInfo[randombag][mbY];
MoneyBagPos[2] = MBInfo[randombag][mbZ];
MBInfo[randombag][mbactive] = 1;


