HeyHoo,
Ich hab mir gestern Abend ein Haussystem zusammengestellt, und dieses grad getestet.
Leider musste Ich feststellen, dass das Haus nicht geladen wird.
Hier ist alles, was zum Haussystem gehört:
#define MAX_HAEUSER 25
enum HausDaten
{
hID,
Float:hPosX,
Float:hPosY,
Float:hPosZ,
hPickup,
Text3D:hLabel,
hBesitzer[24],
hPreis,
hLevel,
hBought
}
new HausInfo[MAX_HAEUSER][HausDaten];
enum HausDaten
{
hID,
Float:hPosX,
Float:hPosY,
Float:hPosZ,
hPickup,
Text3D:hLabel,
hBesitzer[24],
hPreis,
hLevel,
hBought
}
new HausInfo[MAX_HAEUSER][HausDaten];
stock CreateHouse(Float:X,Float:Y,Float:Z,Level,Price)
{
for(new i=1;i<MAX_HAEUSER;i++)
{
new query[1024];
format(query,sizeof(query),"INSERT INTO `haeuser` (`PosX`, `PosY`, `PosZ`, `Level`, `Preis`, `Besitzer`, `Bought`) VALUES ('%f', '%f', '%f', '%d', '%d', 'Niemand', '0')",X,Y,Z,Level,Price);
mysql_query(query);
return LoadHouse(i);
}
return 1;
}
{
for(new i=1;i<MAX_HAEUSER;i++)
{
new query[1024];
format(query,sizeof(query),"INSERT INTO `haeuser` (`PosX`, `PosY`, `PosZ`, `Level`, `Preis`, `Besitzer`, `Bought`) VALUES ('%f', '%f', '%f', '%d', '%d', 'Niemand', '0')",X,Y,Z,Level,Price);
mysql_query(query);
return LoadHouse(i);
}
return 1;
}
stock LoadHouse(HouseID)
{
new str[128];
HausInfo[HouseID][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[HouseID][hID]);
format(HausInfo[HouseID][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]));
HausInfo[HouseID][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPickup] = CreatePickup(1239,1,HausInfo[HouseID][hPosZ],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],0);
if(HausInfo[HouseID][hBought] == 0)
{
format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[HouseID][hLevel],HausInfo[HouseID][hPreis]);
}
else
{
format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[HouseID][hBesitzer]);
}
HausInfo[HouseID][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[HouseID][hPosX],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],7,0);
return 1;
}
{
new str[128];
HausInfo[HouseID][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[HouseID][hID]);
format(HausInfo[HouseID][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[HouseID][hID]));
HausInfo[HouseID][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[HouseID][hID]);
HausInfo[HouseID][hPickup] = CreatePickup(1239,1,HausInfo[HouseID][hPosZ],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],0);
if(HausInfo[HouseID][hBought] == 0)
{
format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[HouseID][hLevel],HausInfo[HouseID][hPreis]);
}
else
{
format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[HouseID][hBesitzer]);
}
HausInfo[HouseID][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[HouseID][hPosX],HausInfo[HouseID][hPosY],HausInfo[HouseID][hPosZ],7,0);
return 1;
}
stock LoadAllHouses()
{
for(new i=1;i<MAX_HAEUSER;i++)
{
new str[128];
HausInfo[i][hID] = GetMySQLint("haeuser", "ID", "ID", HausInfo[i][hID]);
HausInfo[i][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[i][hID]);
HausInfo[i][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[i][hID]);
HausInfo[i][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[i][hID]);
HausInfo[i][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[i][hID]);
HausInfo[i][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[i][hID]);
format(HausInfo[i][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[i][hID]));
HausInfo[i][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[i][hID]);
HausInfo[i][hPickup] = CreatePickup(1239,1,HausInfo[i][hPosZ],HausInfo[i][hPosY],HausInfo[i][hPosZ],0);
if(HausInfo[i][hBought] == 0)
{
format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[i][hLevel],HausInfo[i][hPreis]);
}
else
{
format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[i][hBesitzer]);
}
HausInfo[i][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[i][hPosX],HausInfo[i][hPosY],HausInfo[i][hPosZ],7,0);
}
return 1;
}
{
for(new i=1;i<MAX_HAEUSER;i++)
{
new str[128];
HausInfo[i][hID] = GetMySQLint("haeuser", "ID", "ID", HausInfo[i][hID]);
HausInfo[i][hPosX] = GetMySQLfloat("haeuser", "PosX", "ID", HausInfo[i][hID]);
HausInfo[i][hPosY] = GetMySQLfloat("haeuser", "PosY", "ID", HausInfo[i][hID]);
HausInfo[i][hPosZ] = GetMySQLfloat("haeuser", "PosZ", "ID", HausInfo[i][hID]);
HausInfo[i][hLevel] = GetMySQLint("haeuser", "Level", "ID", HausInfo[i][hID]);
HausInfo[i][hPreis] = GetMySQLint("haeuser", "Preis", "ID", HausInfo[i][hID]);
format(HausInfo[i][hBesitzer],24,"%s",GetMySQLstring("haeuser", "PosZ", "ID", HausInfo[i][hID]));
HausInfo[i][hBought] = GetMySQLint("haeuser", "Bought", "ID", HausInfo[i][hID]);
HausInfo[i][hPickup] = CreatePickup(1239,1,HausInfo[i][hPosZ],HausInfo[i][hPosY],HausInfo[i][hPosZ],0);
if(HausInfo[i][hBought] == 0)
{
format(str,sizeof(str),"Dieses Haus ist zu verkaufen!\nLevel: %d\nPreis: %d€",HausInfo[i][hLevel],HausInfo[i][hPreis]);
}
else
{
format(str,sizeof(str),"Besitzer: %s\nZimmer mieten - /rentroom(n.I.)",HausInfo[i][hBesitzer]);
}
HausInfo[i][hLabel]=Create3DTextLabel(str,COLOR_RED,HausInfo[i][hPosX],HausInfo[i][hPosY],HausInfo[i][hPosZ],7,0);
}
return 1;
}
stock SaveHouse(HouseID)
{
SetMySQLfloat("haeuser", "PosX", HausInfo[HouseID][hPosX], "ID", HausInfo[HouseID][hID]);
SetMySQLfloat("haeuser", "PosY", HausInfo[HouseID][hPosY], "ID", HausInfo[HouseID][hID]);
SetMySQLfloat("haeuser", "PosZ", HausInfo[HouseID][hPosZ], "ID", HausInfo[HouseID][hID]);
SetMySQLint("haeuser", "Level", HausInfo[HouseID][hLevel], "ID", HausInfo[HouseID][hID]);
SetMySQLint("haeuser", "Preis", HausInfo[HouseID][hPreis], "ID", HausInfo[HouseID][hID]);
SetMySQLstring("haeuser", "Besitzer", HausInfo[HouseID][hBesitzer], "ID", HausInfo[HouseID][hID]);
SetMySQLint("haeuser", "Bought", HausInfo[HouseID][hBought], "ID", HausInfo[HouseID][hID]);
return 1;
}
{
SetMySQLfloat("haeuser", "PosX", HausInfo[HouseID][hPosX], "ID", HausInfo[HouseID][hID]);
SetMySQLfloat("haeuser", "PosY", HausInfo[HouseID][hPosY], "ID", HausInfo[HouseID][hID]);
SetMySQLfloat("haeuser", "PosZ", HausInfo[HouseID][hPosZ], "ID", HausInfo[HouseID][hID]);
SetMySQLint("haeuser", "Level", HausInfo[HouseID][hLevel], "ID", HausInfo[HouseID][hID]);
SetMySQLint("haeuser", "Preis", HausInfo[HouseID][hPreis], "ID", HausInfo[HouseID][hID]);
SetMySQLstring("haeuser", "Besitzer", HausInfo[HouseID][hBesitzer], "ID", HausInfo[HouseID][hID]);
SetMySQLint("haeuser", "Bought", HausInfo[HouseID][hBought], "ID", HausInfo[HouseID][hID]);
return 1;
}
stock SaveAllHouse()
{
for(new i=1;i<MAX_HAEUSER;i++)
{
SetMySQLfloat("haeuser", "PosX", HausInfo[HouseID][hPosX], "ID", HausInfo[i][hID]);
SetMySQLfloat("haeuser", "PosY", HausInfo[HouseID][hPosY], "ID", HausInfo[i][hID]);
SetMySQLfloat("haeuser", "PosZ", HausInfo[HouseID][hPosZ], "ID", HausInfo[i][hID]);
SetMySQLint("haeuser", "Level", HausInfo[HouseID][hLevel], "ID", HausInfo[i][hID]);
SetMySQLint("haeuser", "Preis", HausInfo[HouseID][hPrice], "ID", HausInfo[i][hID]);
SetMySQLstring("haeuser", "Besitzer", HausInfo[HouseID][hBesitzer], "ID", HausInfo[i][hID]);
SetMySQLint("haeuser", "Bought", HausInfo[HouseID][hBought], "ID", HausInfo[i][hID]);
}
return 1;
}
{
for(new i=1;i<MAX_HAEUSER;i++)
{
SetMySQLfloat("haeuser", "PosX", HausInfo[HouseID][hPosX], "ID", HausInfo[i][hID]);
SetMySQLfloat("haeuser", "PosY", HausInfo[HouseID][hPosY], "ID", HausInfo[i][hID]);
SetMySQLfloat("haeuser", "PosZ", HausInfo[HouseID][hPosZ], "ID", HausInfo[i][hID]);
SetMySQLint("haeuser", "Level", HausInfo[HouseID][hLevel], "ID", HausInfo[i][hID]);
SetMySQLint("haeuser", "Preis", HausInfo[HouseID][hPrice], "ID", HausInfo[i][hID]);
SetMySQLstring("haeuser", "Besitzer", HausInfo[HouseID][hBesitzer], "ID", HausInfo[i][hID]);
SetMySQLint("haeuser", "Bought", HausInfo[HouseID][hBought], "ID", HausInfo[i][hID]);
}
return 1;
}
stock KillHouse(HouseID)
{
SaveHouse(HouseID);
DestroyPickup(HausInfo[HouseID][hPickup]);
Delete3DTextLabel(HausInfo[HouseID][hLabel]);
return 1;
}
{
SaveHouse(HouseID);
DestroyPickup(HausInfo[HouseID][hPickup]);
Delete3DTextLabel(HausInfo[HouseID][hLabel]);
return 1;
}
ocmd:buyhouse(playerid,params[])
{
if(!isPlayerAFK(playerid))
{
if(SpielerInfo[playerid][pHaus] == 0)
{
for(new i=1;i<MAX_HAEUSER;i++)
{
if(IsPlayerInRangeOfPoint(playerid,3,HausInfo[i][hPosX],HausInfo[i][hPosY],HausInfo[i][hPosZ]))
{
if(HausInfo[i][hBought] == 1)return SCM(playerid,COLOR_LIGHTRED,"Dieses Haus ist nicht zu verkaufen!");
if(HausInfo[i][hBought] == 0)
{
if(SpielerInfo[playerid][pLevel] < HausInfo[i][hLevel])return SCM(playerid,COLOR_LIGHTRED,"Dein Level reicht nicht aus, um dieses Haus zu kaufen!");
if(SpielerInfo[playerid][pGeld] < HausInfo[i][hPreis])return SCM(playerid,COLOR_LIGHTRED,"Dein Geld reicht nicht aus, um dieses Haus zu kaufen!");
if(strcmp(HausInfo[i][hBesitzer],"Niemand",true))
format(HausInfo[i][hBesitzer],24,"%s",PlayerName(playerid));
HausInfo[i][hBought] = 1;
SpielerInfo[playerid][pGeld] -= HausInfo[i][hPreis];
SpielerInfo[playerid][pHaus] = 1;
SpielerInfo[playerid][pHausKey] = i;
SavePlayer(playerid);
KillHouse(i);
LoadHouse(i);
SCM(playerid,COLOR_LIGHTGREEN,"Du hast dir das Haus erfolgreich gekauft!");
return 1;
}
}
}
}
else
{
SCM(playerid,COLOR_LIGHTRED,"Du besitzt bereits ein Haus!");
}
}
return 1;
}
{
if(!isPlayerAFK(playerid))
{
if(SpielerInfo[playerid][pHaus] == 0)
{
for(new i=1;i<MAX_HAEUSER;i++)
{
if(IsPlayerInRangeOfPoint(playerid,3,HausInfo[i][hPosX],HausInfo[i][hPosY],HausInfo[i][hPosZ]))
{
if(HausInfo[i][hBought] == 1)return SCM(playerid,COLOR_LIGHTRED,"Dieses Haus ist nicht zu verkaufen!");
if(HausInfo[i][hBought] == 0)
{
if(SpielerInfo[playerid][pLevel] < HausInfo[i][hLevel])return SCM(playerid,COLOR_LIGHTRED,"Dein Level reicht nicht aus, um dieses Haus zu kaufen!");
if(SpielerInfo[playerid][pGeld] < HausInfo[i][hPreis])return SCM(playerid,COLOR_LIGHTRED,"Dein Geld reicht nicht aus, um dieses Haus zu kaufen!");
if(strcmp(HausInfo[i][hBesitzer],"Niemand",true))
format(HausInfo[i][hBesitzer],24,"%s",PlayerName(playerid));
HausInfo[i][hBought] = 1;
SpielerInfo[playerid][pGeld] -= HausInfo[i][hPreis];
SpielerInfo[playerid][pHaus] = 1;
SpielerInfo[playerid][pHausKey] = i;
SavePlayer(playerid);
KillHouse(i);
LoadHouse(i);
SCM(playerid,COLOR_LIGHTGREEN,"Du hast dir das Haus erfolgreich gekauft!");
return 1;
}
}
}
}
else
{
SCM(playerid,COLOR_LIGHTRED,"Du besitzt bereits ein Haus!");
}
}
return 1;
}
ocmd:createhouse(playerid,params[])
{
if(!isPlayerAFK(playerid))
{
new p,l;
if(sscanf(params,"ii",p,l))return SCM(playerid,COLOR_GREY,"Benutze: /createhouse [Preis] [Level]");
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
CreateHouse(X,Y,Z,l,p);
SCM(playerid,COLOR_LIGHTGREEN,"Du hast das Haus erfolgreich erstellt!");
}
}
return 1;
}
{
if(!isPlayerAFK(playerid))
{
new p,l;
if(sscanf(params,"ii",p,l))return SCM(playerid,COLOR_GREY,"Benutze: /createhouse [Preis] [Level]");
{
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
CreateHouse(X,Y,Z,l,p);
SCM(playerid,COLOR_LIGHTGREEN,"Du hast das Haus erfolgreich erstellt!");
}
}
return 1;
}
Ich bekomme die msg, dass ein Haus ertellt wird, ebenso, wird alles in die Datenbank eingetragen.
Nur geladen wird es nicht...
lg