(hier noch mal der aktuelle code im überblick)
Code
forward OnShopsLoad();
public OnShopsLoad()
{
new num_rows;
cache_get_row_count(num_rows);
if(!num_rows)return 1;
for(new i; i<sizeof(ShopInfo); i++)
{
new id=getFreeShopID();
cache_get_value_name_int(i, "shopid", ShopInfo[id][shopid]);
cache_get_value_name_float(i, "h_enterx", ShopInfo[id][h_enterx]);
cache_get_value_name_float(i, "h_entery", ShopInfo[id][h_entery]);
cache_get_value_name_float(i, "h_enterz", ShopInfo[id][h_enterz]);
cache_get_value_name_float(i, "h_exitx", ShopInfo[id][h_exitx]);
cache_get_value_name_float(i, "h_exity", ShopInfo[id][h_exity]);
cache_get_value_name_float(i, "h_exitz", ShopInfo[id][h_exitz]);
cache_get_value_name_int(i, "robtime", ShopInfo[id][robtime]);
cache_get_value_name_int(i, "owned", ShopInfo[id][owned]);
cache_get_value_name_int(i, "interior", ShopInfo[id][interior]);
cache_get_value_name(i, "owner", ShopInfo[id][owner], MAX_PLAYER_NAME);
updateHaus(id);
}
return 1;
}
ocmd:createshop(playerid,params[])
{
new Float:xc, Float:yc, Float:zc,query[256];
GetPlayerPos(playerid, xc, yc, zc);
new id = getFreeShopID();
MakeShop[playerid] = id;
ShopInfo[id][h_enterx]=xc;
ShopInfo[id][h_entery]=yc;
ShopInfo[id][h_enterz]=zc;
ShopInfo[id][interior]=0;
strmid(ShopInfo[id][owner], "", 0, MAX_PLAYER_NAME, MAX_PLAYER_NAME);
format(query, sizeof(query),"INSERT INTO `Houses` (h_enterx, h_entery, h_enterz, owner, interior) VALUES ('%f', '%f', '%f', '""', '1')", xc, yc, zc);
mysql_pquery(handle, query, "OnHausCreated", "i", id);
printf(query);
return 1;
}
forward OnHausCreated(id);
public OnHausCreated(id)
{
//hopInfo[id][shopid]=cache_insert_id();
ABroadCast(-1,"Sehr gut, bitte gehe nun zum Ausgang und mache /shopasugang.");
return 1;
}
ocmd:shopausgang(playerid,params[])
{
//new id = pShopID;
new Float:xc, Float:yc, Float:zc,query[256];
GetPlayerPos(playerid, xc, yc, zc);
ShopInfo[MakeShop[playerid]][h_exitx] = xc;
ShopInfo[MakeShop[playerid]][h_exity] = yc;
ShopInfo[MakeShop[playerid]][h_exitz] = zc;
/* ShopInfo[id][h_exitx]=xc;
ShopInfo[id][h_exity]=yc;
ShopInfo[id][h_exitz]=zc;*/
ShopInfo[MakeShop[playerid]][interior] = GetPlayerInterior(playerid);
//ShopInfo[id][interior]=GetPlayerInterior(playerid);
//format(query, sizeof(query),"INSERT INTO `Houses` (h_exitx, h_exity, h_exitz, interior) VALUES ('%f', '%f', '%f', '%d')", xc, yc, zc,ShopInfo[id][interior]);
//mysql_format(handle, query, sizeof(query), "UPDATE `Houses` SET `h_exitx` = '%f', `h_exity` = '%f', ´h_exitz´ = '%f',`interior` = '%d' WHERE ´shopid´ = '%d'", xc, yc, zc,ShopInfo[MakeShop[playerid]][interior],MakeShop[playerid]);
mysql_format(handle, query, sizeof(query), "UPDATE Houses SET h_exitx = '%f', h_exity = '%f', h_exitz = '%f', interior = '%d' WHERE shopid = '%d'", xc, yc, zc,ShopInfo[MakeShop[playerid]][interior],ShopInfo[MakeShop[playerid]][shopid]);
mysql_pquery(handle, query, "ShopFinished", "i", MakeShop[playerid]);
printf(query);
return 1;
}
forward ShopFinished(id);
public ShopFinished(id)
{
ABroadCast(-1,"Der Shop wurde erfolgreich erstellt.");
ShopInfo[id][shopid]=cache_insert_id();
updateHaus(id);
return 1;
}
updateHaus(id)
{
new string[128];
if(ShopInfo[id][spickup])
{
DestroyPickup(ShopInfo[id][spickup]);
}
if(ShopInfo[id][stext])
{
Delete3DTextLabel(ShopInfo[id][stext]);
}
if(!strlen(ShopInfo[id][owner]))
{
ShopInfo[id][spickup]=CreatePickup(1273, 1, ShopInfo[id][h_enterx], ShopInfo[id][h_entery], ShopInfo[id][h_entery], -1);
format(string,sizeof(string), "Zum Verkauf\nKosten: %i$\n/hauskaufen", ShopInfo[id][price]);
ShopInfo[id][stext]=Create3DTextLabel(string, -1, ShopInfo[id][h_enterx], ShopInfo[id][h_entery], ShopInfo[id][h_enterz], 10, 0, 1);
}
else
{
ShopInfo[id][spickup]=CreatePickup(1239, 1, ShopInfo[id][h_enterx], ShopInfo[id][h_entery], ShopInfo[id][h_enterz], -1);
format(string,sizeof(string), "Besitzer: %s\n/enter", ShopInfo[id][owner]);
ShopInfo[id][stext]=Create3DTextLabel(string, -1, ShopInfo[id][h_enterx], ShopInfo[id][h_entery], ShopInfo[id][h_enterz], 10, 0, 1);
}
return 1;
}
getFreeShopID()
{
for(new i=0; i<sizeof(ShopInfo); i++)
{
if(ShopInfo[i][shopid]==-1) return ABroadCast(0xFF0000FF, "Error: Maximale Anzahl an Shops erreicht.");
}
return 0;
}
Alles anzeigen
Jetzt wird ShopFinished nicht mehr aufgerufen