Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load all the rows from the database
- stock Business_LoadTableRows()
- {
- mysql_iquery_s(
- str_format(
- "SELECT `b`.`*`, `u`.`NAME` AS `owner_name` \
- FROM `business_data` b \
- LEFT JOIN `users` u \
- ON `b`.`owner_id` = `u`.`ID` \
- WHERE \
- `b`.`deleted` = '0'",
- )
- );
- new rows = cache_get_row_count();
- if(rows) {
- // Loop through all the rows
- for(new i = 0; i < rows; i++) {
- new Map: data = map_new();
- // Sets the current database id
- new BusinessDBID: dbid;
- dbid = BusinessDBID: cache_get_field_content_int(i, "id");
- Business_SetDatabaseID(data, dbid);
- // Sets the name
- new name[BUSINESS_MAX_NAME];
- cache_get_field_content(i, "name", name);
- Business_SetName(data, name);
- // Sets the type
- new BusinessType: type;
- type = BusinessType: cache_get_field_content_int(i, "type");
- Business_SetType(data, type);
- // Sets the subtype
- new BusinessSubtype: subtype;
- subtype = BusinessSubtype: cache_get_field_content_int(i, "subtype");
- Business_SetSubtype(data, subtype);
- // Sets the owners id
- new PlayerDBID: owner_dbid;
- owner_dbid = PlayerDBID: cache_get_field_content_int(i, "owner_id");
- Business_SetOwnerDatabaseID(data, owner_dbid);
- // Sets the owners name
- if(owner_dbid != 0) {
- new owner_name[MAX_PLAYERS];
- cache_get_field_content(i, "owner_name", owner_name);
- Business_SetOwnerName(data, owner_name);
- }
- // Sets the price amount
- new price;
- price = cache_get_field_content_int(i, "price");
- Business_SetPrice(data, price);
- // Sets the stock amount
- new stock_amt;
- stock_amt = cache_get_field_content_int(i, "stock");
- Business_SetStock(data, stock_amt);
- // Sets the money
- new money;
- money = cache_get_field_content_int(i, "money");
- Business_SetMoney(data, money);
- // Sets the tax amount
- new tax_amt;
- tax_amt = cache_get_field_content_int(i, "tax");
- Business_SetTax(data, tax_amt);
- // Sets the security level
- new security_level;
- security_level = cache_get_field_content_int(i, "security_level");
- Business_SetSecurityLevel(data, security_level);
- // Sets the entrance position
- new
- Float: entrance_x,
- Float: entrance_y,
- Float: entrance_z,
- Float: entrance_a,
- entrance_int
- ;
- entrance_x = cache_get_field_content_float(i, "entrance_x");
- entrance_y = cache_get_field_content_float(i, "entrance_y");
- entrance_z = cache_get_field_content_float(i, "entrance_z");
- entrance_a = cache_get_field_content_float(i, "entrance_a");
- entrance_int = cache_get_field_content_int(i, "entrance_int");
- Business_SetEntrancePosition(
- data,
- entrance_x,
- entrance_y,
- entrance_z,
- entrance_a,
- entrance_int,
- 0
- );
- // Sets the exit position
- new
- Float: exit_x,
- Float: exit_y,
- Float: exit_z,
- Float: exit_a,
- exit_int,
- exit_vw
- ;
- exit_x = cache_get_field_content_float(i, "exit_x");
- exit_y = cache_get_field_content_float(i, "exit_y");
- exit_z = cache_get_field_content_float(i, "exit_z");
- exit_a = cache_get_field_content_float(i, "exit_a");
- exit_int = cache_get_field_content_int(i, "exit_int");
- exit_vw = VW_GetFreeID();
- Business_SetExitPosition(
- data,
- exit_x,
- exit_y,
- exit_z,
- exit_a,
- exit_int,
- exit_vw
- );
- // Create a new instance
- new BusinessIndex: index;
- Business_CreateInstance(index, data);
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement