Bom estou fazendo o salvamento das casas no ppc_trucking..
Comando..
Log:
PHP Code:
HouseFile_Save(HouseID)
{
new Query[300], vid;
mysql_format(mysql, Query, sizeof(Query), "UPDATE `Casas` SET `Nome`='%d', `X`=%.1f, `Y`=%.1f, `Z`=%.1f,`Level`='%d', `MaxLevel`='%d', `Preço`=%d, `Dono`=%s, `Insurance`=%d, `Comprada`=%d WHERE `ID`='%d'",
AHouseData[HouseID][HouseName],
AHouseData[HouseID][HouseX],
AHouseData[HouseID][HouseY],
AHouseData[HouseID][HouseZ],
AHouseData[HouseID][HouseLevel],
AHouseData[HouseID][HouseMaxLevel],
AHouseData[HouseID][HousePrice],
AHouseData[HouseID][Owner],
AHouseData[HouseID][Insurance],
AHouseData[HouseID][Owned],
IDCasa);
mysql_pquery(mysql, Query);
if (AHouseData[HouseID][Owned] == true) // Check if the house is owned
{
mysql_format(mysql, Query, sizeof(Query), "UPDATE `Casas` SET `Comprada`=Sim");
mysql_pquery(mysql, Query);
}
else
{
mysql_format(mysql, Query, sizeof(Query), "UPDATE `Casas` SET `Comprada`=Sim");
mysql_pquery(mysql, Query);
}
for (new CarSlot; CarSlot < 10; CarSlot++)
{
if (AHouseData[HouseID][VehicleIDs][CarSlot] != 0)
{
vid = AHouseData[HouseID][VehicleIDs][CarSlot];
mysql_format(mysql, Query, sizeof(Query), "UPDATE `Casas` SET `Modelo`='%d', `Fuel`='%d', `Paint`='%d', `Spoiler`='%d', `Hood`='%d', `Roof`='%d', `SideSkirt`='%d', `Lamps`='%d',`Nitro`='%d', `Exhaust`='%d', `Wheels`='%d', `Stereo`='%d', `Susp`='%d', `Fbump`='%d', `Tbump`='%d', `Fvent`='%d', `Tvent`='%d', `Cor1`='%d', `Cor2`='%d', `PosX`=%.1f, `PosY`=%.1f, `PosZ`=%.1f,`Angle`=%.1f, `Multado`=%d WHERE `ID`='%d'",
AVehicleData[vid][Model],
AVehicleData[vid][Fuel],
AVehicleData[vid][PaintJob],
AVehicleData[vid][Components][0],
AVehicleData[vid][Components][1],
AVehicleData[vid][Components][2],
AVehicleData[vid][Components][3],
AVehicleData[vid][Components][4],
AVehicleData[vid][Components][5],
AVehicleData[vid][Components][6],
AVehicleData[vid][Components][7],
AVehicleData[vid][Components][8],
AVehicleData[vid][Components][9],
AVehicleData[vid][Components][10],
AVehicleData[vid][Components][11],
AVehicleData[vid][Components][12],
AVehicleData[vid][Components][13],
AVehicleData[vid][Color1],
AVehicleData[vid][Color2],
AVehicleData[vid][SpawnX],
AVehicleData[vid][SpawnY],
AVehicleData[vid][SpawnZ],
AVehicleData[vid][SpawnRot],
AVehicleData[vid][NeonObjectModel],
AVehicleData[vid][Clamped],
IDCasa);
mysql_pquery(mysql, Query);
}
}
return 1;
}
PHP Code:
COMMAND:createhouse(playerid, params[])
{
// Setup local variables
new HPrice, MaxLevel, HouseID;
// Send the command to all admins so they can see it
SendAdminText(playerid, "/createhouse", params);
// Check if the player has logged in
if (APlayerData[playerid][LoggedIn] == true)
{
// Check if the player's admin-level is at least 5
if (APlayerData[playerid][PlayerLevel] >= 0)
{
// Check if the player isn't inside a vehicle
if (GetPlayerVehicleSeat(playerid) == -1)
{
if (sscanf(params, "ii", HPrice, MaxLevel)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/createhouse <price> <maxlevel (1-10)>\"");
else
{
// Check if the player entered a proper maxlevel
if ((MaxLevel >= 1) && (MaxLevel <= 10))
{
// Find the first free HouseID
for (HouseID = 1; HouseID < MAX_HOUSES; HouseID++)
if (AHouseData[HouseID][PickupID] == 0) // Check if an empty house-index has been found (PickupID is 0)
break; // Stop searching, the first free HouseID has been found now
// Check if the house-limit hasn't been reached yet
if (HouseID < MAX_HOUSES)
{
// Setup some local variables
new Float:x, Float:y, Float:z, Msg[128];
// Get the player's position
GetPlayerPos(playerid, x, y, z);
// Set some default data
AHouseData[HouseID][HouseX] = x;
AHouseData[HouseID][HouseY] = y;
AHouseData[HouseID][HouseZ] = z;
AHouseData[HouseID][HouseLevel] = 1;
AHouseData[HouseID][HouseMaxLevel] = MaxLevel;
AHouseData[HouseID][HousePrice] = HPrice;
AHouseData[HouseID][Owned] = false;
// Add the pickup and 3DText at the location of the house-entrance (where the player is standing when he creates the house)
House_CreateEntrance(HouseID);
// Save the house
HouseFile_Save(HouseID);
// Inform the player that he created a new house
format(Msg, 128, "{00FF00}You've succesfully created house {FF00FF}%i{00FF00}", HouseID);
SendClientMessage(playerid, 0xFFFFFFFF, Msg);
new Query[200];
mysql_format(mysql, Query, sizeof(Query), "INSERT INTO `Casas`(`ID`, `X`,`Y`,`Z`,`Level`,`MaxLevel`,`Preço`,`Comprada`) VALUES (%d, %.1f, %.1f, %.1f, '%d', '%d', '%d', '%d')", IDCasa, AHouseData[HouseID][HouseX] = x, AHouseData[HouseID][HouseX] = y,AHouseData[HouseID][HouseX] = z, AHouseData[HouseID][HouseLevel] = 1,AHouseData[HouseID][HouseMaxLevel] = MaxLevel, AHouseData[HouseID][HousePrice] = HPrice, AHouseData[HouseID][Owned] = false);
mysql_pquery(mysql, Query);
IDCasa++;
}
else
SendClientMessage(playerid, 0xFF0000FF, "The maximum amount of houses has been reached");
}
else
SendClientMessage(playerid, 0xFF0000FF, "You have to use a max-level from 1 to 10");
}
}
else
SendClientMessage(playerid, 0xFF0000FF, "You can't be inside a vehicle to create a house");
}
}
else
return 0;
// Let the server know that this was a valid command
return 1;
}
PHP Code:
[12:28:35] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Sim' in 'field list'
[12:28:35] [ERROR] CMySQLQuery::Execute[] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' `Insurance`=0, `Comprada`=0 WHERE `ID`='0'' at line 1
[12:28:39] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Sim' in 'field list'
[12:28:39] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Luis' in 'field list'
[12:28:40] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Sim' in 'field list'
[12:28:40] [ERROR] CMySQLQuery::Execute[] - (error #1054) Unknown column 'Luis' in 'field list'
Aucun commentaire:
Enregistrer un commentaire