Function OnStoreLoad()
{
new
x = 0,
i,
s[64]
;
for(new xx = cache_get_row_count(); x < xx; x++)
{
i = Iter_Free(Stores);
Store[i][StoreID] = cache_get_field_content_int(x, "id");
Store[i][StoreX] = cache_get_field_content_float(x, "x");
Store[i][StoreY] = cache_get_field_content_float(x, "y");
Store[i][StoreZ] = cache_get_field_content_float(x, "z");
Store[i][StoreA] = cache_get_field_content_float(x, "angle");
Store[i][StoreInteriorID] = cache_get_field_content_int(x, "interiorid");
cache_get_field_content(x, "name", s);
format(Store[i][StoreName], 64, "%s", s);
Store[i][StoreMoney] = cache_get_field_content_int(x, "money");
Store[i][StoreMoneyPerDay] = cache_get_field_content_int(x, "mpd");
Store[i][StorePrice] = cache_get_field_content_int(x, "price");
Store[i][StoreLevel] = cache_get_field_content_int(x, "level");
Store[i][StoreIconID] = cache_get_field_content_int(x, "mapicon");
Store[i][StoreOwner] = cache_get_field_content_int(x, "owner");
Store[i][StoreIcon] = CreateDynamicMapIcon(Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], Store[i][StoreIconID], -1, 0, 0, .style = MAPICON_GLOBAL);
Store[i][StoreEnterPickup] = CreateDynamicPickup(1318, 1, Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], 0, 0, -1, 35.0);
new intid = IsInteriorExist(Store[i][StoreInteriorID]), label[256];
cache_get_field_content(x, "username", s);
if(Store[i][StorePrice] == 1337)
format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}The Government", Store[i][StoreName], Store[i][StoreID]);
else if(Store[i][StoreOwner] == 0)
format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}Unowned\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday", Store[i][StoreName], Store[i][StoreID], Store[i][StorePrice], Store[i][StoreLevel], Store[i][StoreMoneyPerDay]);
else
format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}%s\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday", Store[i][StoreName], Store[i][StoreID], s, Store[i][StorePrice], Store[i][StoreLevel], Store[i][StoreMoneyPerDay]);
Store[i][StoreStatus] = STORE_IDLE;
Store[i][StoreSafe] = CreateSafe(Interior[intid][InteriorSafeID], Store[i][StoreID]);
Store[i][StoreExitCP] = CreateDynamicCP(Interior[intid][InteriorX], Interior[intid][InteriorY], Interior[intid][InteriorZ], 1.0, Store[i][StoreID], Interior[intid][InteriorIntID]);
Store[i][StoreEnterLabel] = CreateDynamic3DTextLabel(label, -1, Store[i][StoreX], Store[i][StoreY], Store[i][StoreZ], 10.0, .worldid = 0, .interiorid = 0);
UpdateDynamic3DTextLabelText(Store[i][StoreEnterLabel], -1, label);
Store[i][StoreRobberyCP] = CreateSafeCP(Interior[intid][InteriorSafeID], Store[i][StoreID]);
Store[i][StoreRobberyLabel] = CreateRobberyLabel(Interior[intid][InteriorSafeID], Store[i][StoreID]);
Store[i][StoreActor] = CreateActor(Interior[intid][InteriorActorSkin], Interior[intid][InteriorActorX], Interior[intid][InteriorActorY], Interior[intid][InteriorActorZ], Interior[intid][InteriorActorA]);
switch(random(4))
{
case 0:
ApplyActorAnimation(Store[i][StoreActor], "PED", "roadcross", 4.1, 1, 1, 1, 1, 0);
case 1:
ApplyActorAnimation(Store[i][StoreActor], "PED", "roadcross_female", 4.1, 1, 1, 1, 1, 0);
case 2:
ApplyActorAnimation(Store[i][StoreActor], "PED","roadcross_gang", 4.1, 1, 1, 1, 1, 0);
case 3:
ApplyActorAnimation(Store[i][StoreActor], "PED","roadcross_old", 4.1, 1, 1, 1, 1, 0);
}
SetActorVirtualWorld(Store[i][StoreActor], Store[i][StoreID]);
Iter_Add(Stores, i);
}
return;
}
ReloadStore()
{
foreach(new i : Stores)
{
DestroyDynamicMapIcon(Store[i][StoreIcon]);
DeleteSafe(Store[i][StoreSafe]);
DestroyDynamicCP(Store[i][StoreExitCP]);
DestroyDynamicCP(Store[i][StoreRobberyCP]);
DestroyDynamic3DTextLabel(Store[i][StoreRobberyLabel]);
DestroyDynamic3DTextLabel(Store[i][StoreEnterLabel]);
DestroyDynamicPickup(Store[i][StoreEnterPickup]);
DestroyActor(Store[i][StoreActor]);
}
Iter_Clear(Stores);
mysql_tquery(connectionHandle, "SELECT * FROM `store`", "OnStoreLoad");
}
I think the problem is about your buy store cmd. Maybe it didn't update store owner's name.
Post your buy store cmd code. |
COMMAND:buystore(playerid, params[])
{
foreach(new i : Stores)
{
if(Store[i][StoreOwner] == pData[playerid][RealID])
return Message(playerid, COLOR_RED, "You can't buy more stores");
}
if(GetPlayerScore(playerid) >= 1000)
{
new i, bool:found = false;
if(sscanf(params, "d", i))
return Usage(playerid, "buystore [storeid]");
foreach(new x : Stores)
{
if(Store[x][StoreID] == i)
{
i = x;
found = true;
break;
}
}
if(!found)
return 1;
if(!Store[i][StoreOwner])
{
if(Store[i][StorePrice] == 1337)
return 1;
if(GetPlayerMoney(playerid) >= Store[i][StorePrice])
{
GivePlayerMoney(playerid, -Store[i][StorePrice]);
Store[i][StoreOwner] = pData[playerid][RealID];
Message(playerid, COLOR_GREEN, "You bought %s for $%m, use /storemenu while inside store to access store menu", Store[i][StoreName], Store[i][StorePrice]);
new label[256];
format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}%p\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday", Store[i][StoreName], Store[i][StoreID], playerid, Store[i][StorePrice], Store[i][StoreLevel], CountMoneyPerDay(i));
UpdateDynamic3DTextLabelText(Store[i][StoreEnterLabel], -1, label);
mysql_format(connectionHandle, label, 256, "UPDATE store SET owner = %d WHERE id = %d", pData[playerid][RealID], Store[i][StoreID]);
mysql_query(connectionHandle, label, false);
}
else
Message(playerid, COLOR_RED, "Not enough money to buy this store");
}
else
Message(playerid, COLOR_RED, "This store is owned");
}
else
Message(playerid, COLOR_RED, "You must have 1000 score or more as a requirement to buy any store");
return 1;
}
COMMAND:buystore(playerid, params[]) { foreach(new i : Stores) { if(Store[i][StoreOwner] == pData[playerid][RealID]) return Message(playerid, COLOR_RED, "You can't buy more stores"); } if(GetPlayerScore(playerid) >= 1000) { new i, bool:found = false; if(sscanf(params, "d", i)) return Usage(playerid, "buystore [storeid]"); foreach(new x : Stores) { if(Store[x][StoreID] == i) { i = x; found = true; break; } } if(!found) return 1; if(!Store[i][StoreOwner]) { if(Store[i][StorePrice] == 1337) return 1; if(GetPlayerMoney(playerid) >= Store[i][StorePrice]) { GivePlayerMoney(playerid, -Store[i][StorePrice]); Store[i][StoreOwner] = pData[playerid][RealID]; Message(playerid, COLOR_GREEN, "You bought %s for $%m, use /storemenu while inside store to access store menu", Store[i][StoreName], Store[i][StorePrice]); new label[256]; format(label, 256, "{FF0000}[%s]\n{FFFFFF}{FFFF66}ID: {FFFFFF}%d\n{FFFF66}Owner: {FFFFFF}%d\n{FFFF66}Price: {FFFFFF}$%m\n{FFFF66}Level: {FFFFFF}%d\n{FFFF66}$%m per gameday", Store[i][StoreName], Store[i][StoreID], playerid, Store[i][StorePrice], Store[i][StoreLevel], CountMoneyPerDay(i)); UpdateDynamic3DTextLabelText(Store[i][StoreEnterLabel], -1, label); mysql_format(connectionHandle, label, 256, "UPDATE store SET owner = %d WHERE id = %d", pData[playerid][RealID], Store[i][StoreID]); mysql_query(connectionHandle, label, false); } else Message(playerid, COLOR_RED, "Not enough money to buy this store"); } else Message(playerid, COLOR_RED, "This store is owned"); } else Message(playerid, COLOR_RED, "You must have 1000 score or more as a requirement to buy any store"); return 1; }