12.03.2011, 14:23
I made a system to load pickups from a mysql database to make stores. It refuses to work.
BT: I did put LoadSQLShops(); under ongamemode init.
BT: I did put LoadSQLShops(); under ongamemode init.
pawn Код:
forward LoadSQLShops(pickupid);
enum StoreInfo
{
Float:sX,
Float:sY,
Float:sZ
}
new sInfo[MAX_PICKUPS][StoreInfo];
COMMAND:addstore(playerid,params[])
{
new query[100];
new
Float: X,
Float: Y,
Float: Z;
GetPlayerPos(playerid, X, Y, Z);
format(query, sizeof(query), "INSERT INTO `stores` (`X`, `Y`, `Z`) VALUES ('%d', '%d', '%d');",X, Y, Z);
mysql_query(query);
return 1;
}
stock LoadSQLShops(pickupid)
{
mysql_query("SELECT * FROM `stores`");
mysql_store_result();
new Query[256], X, Y, Z;
if(mysql_num_rows() > 0)
{
while(mysql_fetch_field(Query, "|"))
{
sscanf(Query, "p<|>fff", X, Y, Z);
new store = CreatePickup(1274,23,X, Y, Z);
sInfo[pickupid][sX] = X;
sInfo[pickupid][sY] = Y;
sInfo[pickupid][sZ] = X;
}
{
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == store)
{
SendClientMessage(playerid, COLOR_YELLOW, "Shops are under construction!");
}
return 1;
}