Loading shops from database
#2

I believe I've fixed the problem.

Код:
CMD:createshoppoint(playerid, params[])
{
	if (PlayerInfo[playerid][Admin] < 4) return Invalid_Admin(playerid);
	new string[128], Float:pos[3], query[128], header[128];
	if (sscanf(params, "s[128]", header)) return SendClientMessage(playerid, -1, SYNTAX"/createshoppoint <text>");
	if (strlen(header) < 3) return SendClientMessage(playerid, -1, "ERROR: Name is too short.");
	GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
	format(string, sizeof(string), "Attempting to create a new shop point...");
	SendClientMessage(playerid, -1, string);
	
	mysql_format(mysql, query, sizeof(query), "INSERT INTO `shops` (`ID`, `Header`, `PosX`, `PosY`, `PosZ`) VALUES (NULL, '%e', %f, %f, %f)", header, pos[0], pos[1], pos[2]);
	mysql_tquery(mysql, query, "OnCreateShop", "sfff", header, pos[0], pos[1], pos[2]);
	
	//LoadShops();
	
	format(string, sizeof(string), "%s has created a new shop.", PlayerInfo[playerid][Name]);
	SQL_Log("Shop", PlayerInfo[playerid][Name], "N/A", string);
	return 1;
}

forward OnCreateShop(header[], Float:posX, Float:posY, Float:posZ);
public OnCreateShop(header[], Float:posX, Float:posY, Float:posZ)
{
	new insertID, string[128];
	insertID = cache_insert_id();
	printf("insert ID: %i", insertID);
	ShopInfo[insertID][ID] = insertID;
	printf("shop ID: %i", ShopInfo[insertID][ID]);
	
	format(ShopInfo[insertID][Header], 128, header);
	
	format(string, sizeof(string), COL_GOLD"ID{FFFFFF}: %i - {FFD700}%s{FFFFFF}", ShopInfo[insertID][ID], ShopInfo[insertID][Header]);
    ShopInfo[insertID][Pos][0] = posX;
    ShopInfo[insertID][Pos][1] = posY;
    ShopInfo[insertID][Pos][2] = posZ;
    ShopInfo[insertID][Text] = CreateDynamic3DTextLabel(string, 0xFFD700FF, ShopInfo[insertID][Pos][0], ShopInfo[insertID][Pos][1], ShopInfo[insertID][Pos][2], 5.0);
    ShopInfo[insertID][Pickup] = CreateDynamicPickup(1254, 1, ShopInfo[insertID][Pos][0], ShopInfo[insertID][Pos][1], ShopInfo[insertID][Pos][2]);
	
	return 1;
}
Reply


Messages In This Thread
Loading shops from database - by MartinSwag - 26.10.2015, 17:34
Re: Loading shops from database - by MartinSwag - 26.10.2015, 18:02

Forum Jump:


Users browsing this thread: 1 Guest(s)