14.04.2014, 10:26
pawn Код:
#define MAX_HOUSES 200
pawn Код:
strcat(query2, "CREATE TABLE IF NOT EXISTS `Houses` (`HouseID` INT(4) NOT NULL AUTO_INCREMENT, `Address` VARCHAR(30), `Price` INT(8), `EnterX` float, `EnterY` float, `EnterZ` float, `ExitX` float, `ExitY` float, `ExitZ` float,");
strcat(query2, "PRIMARY KEY (`HouseID`))");
mysql_function_query(g_Handle, query2, false, "SendQuery", "");
pawn Код:
enum hInfo
{
hHouseID,
hAddress[32],
hPrice,
hPickup,
Text3D:hText,
Float:hEnterPos[3],
Float:hExitPos[3]
}
pawn Код:
new HouseInfo[MAX_HOUSES][hInfo];
pawn Код:
static houseid = 1;
pawn Код:
CMD:createhouse(playerid, params[])
{
new string[128], query[300], Float:pos[3];
if(!IsPlayerLoggedIn(playerid))
{
SendClientMessage(playerid, -1, "You are restricted from using commands until you log in.");
return 1;
}
if(PlayerInfo[playerid][pAdminLevel] < 1)
{
SendClientMessage(playerid, -1, "You do not have the authority to use this command.");
return 1;
}
if(!AdminDuty[playerid])
{
SendClientMessage(playerid, -1, "You are not on duty as an Administrator (/aduty).");
return 1;
}
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
HouseInfo[houseid][hHouseID] = houseid;
format(HouseInfo[houseid][hAddress], 32, "1 San Fierro Way");
HouseInfo[houseid][hPrice] = 200000;
HouseInfo[houseid][hEnterPos][0] = pos[0];
HouseInfo[houseid][hEnterPos][1] = pos[1];
HouseInfo[houseid][hEnterPos][2] = pos[2];
HouseInfo[houseid][hPickup] = CreateDynamicPickup(1273, 1, pos[0], pos[1], pos[2], -1, -1, -1, 30.0);
format(string, sizeof(string), "House ID: %d\nAddress: %s\nPrice: $%d", houseid, HouseInfo[houseid][hAddress], HouseInfo[houseid][hPrice]);
HouseInfo[houseid][hText] = CreateDynamic3DTextLabel(string, COLOR_WHITE, pos[0], pos[1], pos[2]+0.3, 15);
format(string, sizeof(string), "You have created House ID %d.", houseid);
SendClientMessage(playerid, -1, string);
houseid++;
format(query, sizeof(query), "INSERT INTO `Houses` (`HouseID`, `Address`, `Price`, `EnterX`, `EnterY`, `EnterZ`) VALUES (%d, \'%s\', %d, %.1f, %.1f, %.1f)",
HouseInfo[houseid][hHouseID],
HouseInfo[houseid][hAddress],
HouseInfo[houseid][hPrice],
HouseInfo[houseid][hEnterPos][0],
HouseInfo[houseid][hEnterPos][1],
HouseInfo[houseid][hEnterPos][2]
);
mysql_function_query(g_Handle, query, false, "SendQuery", "d", playerid);
return 1;
}
