12.12.2010, 13:23
Okay, I tried to make a dynamic house system but it failed it does save in to the Database.
The Code
The Code to Load the Houses
The Code
pawn Код:
command(house, playerid, params[])
{
GetPlayerPos(playerid, X, Y, Z);
if(pStats[playerid][pAdminLevel] < 3)
{
return SendClientMessage(playerid, COLOR_GREY, ADMIN_CMD_ERROR);
}
else
{
CreatePickup(1273, 1, X, Y, Z, 0);
SendClientMessage(playerid, COLOR_GREY, "[MYSQL DEBUG:] House Created");
}
format(Query, sizeof(Query), "INSERT INTO `Houses` (HPickupID, hExteriorX, hExteriorY, hExteriorZ) VALUES(%d, %f, %f, %f, %f)", HPickupID, hExteriorX, hExteriorY, hExteriorZ);
mysql_query(Query);
return 1;
}
pawn Код:
stock InitHouses()
{
new index;
mysql_query("SELECT * FROM `House`");
mysql_store_result();
for(new i = 0; i < MAX_HOUSES; i++)
{
if(mysql_num_rows() > 0)
{
while(mysql_fetch_row(Query))
{
sscanf(Query, "e<p<|>ddfffd>", House[index]);
CreatePickup(1, 1, House[i][hExteriorX], House[i][hExteriorY], House[i][hExteriorZ], 0);
index++;
}
}
if(strcmp(House[i][hOwner], "Nobody", true) == 0)
{
House[i][LockStatus] = 0;
House[i][HPickupID] = CreatePickup(1273, 1, House[i][hExteriorX], House[i][hExteriorY], House[i][hExteriorZ], 0);
}
else
{
House[i][HPickupID] = CreatePickup(1272, 1, House[i][hExteriorX], House[i][hExteriorY], House[i][hExteriorZ], 0);
}
}
mysql_free_result();
print("/n");
printf("SERVER: Loaded %d MySQL Houses successfully.", index);
return 1;
}