01.09.2016, 19:42
No? Switch isn't a loop.
I had nothing to do so I re-scripted your command.
Start organizing and start saving memory.
I also fixed your queries. You were using %i for floats, and there's a place where you were updating without using a =
pawn Код:
COMMAND:ahouse(playerid,params[])
{
if (!Player[playerid][Authed] || Player[playerid][Admin] < 4)
return SendClientError(playerid, "You are not authorised to use this command.");
if (isnull(params))
return SendClientUsage(playerid, "/ahouse [ Create / Interior ]");
if (!strcmp(params, "create", true, 6))
{
if (params[6] != ' ' && params[6] != '\0')
return SendClientUsage(playerid, "/ahouse [ Create / Interior ]");
new Float: px, Float: py, Float: pz, zone[240];
GetPlayerPos(playerid, px, py, pz);
GetZone(px, py, pz, zone);
format(zone, sizeof(zone), "INSERT INTO houses (hOwner,hLocation,hX,hY,hZ) VALUES ('%s','%s','%f','%f','%f')", Name(playerid), zone, px, py, pz);
mysql_tquery(connection, zone, "CreateHouse", "i", playerid);
}
else if (!strcmp(params, "interior", true, 8))
{
if (params[8] != ' ' && params[8] != '\0')
return SendClientUsage(playerid, "/ahouse interior [HouseID] [InteriorID]");
new houseid, intid;
if (sscanf(params[8], "dd", houseid, intid))
return return SendClientUsage(playerid, "/ahouse interior [HouseID] [InteriorID]");
new query[147];
switch (intid)
{
case 1:
{
House[houseid][hIntX] = 140.17;
House[houseid][hIntY] = 1366.07;
House[houseid][hIntZ] = 1083.65;
House[houseid][hInterior] = 5;
format(query, sizeof(query),"UPDATE houses SET hIntX='%f'AND hIntY='%f' AND hIntZ='%f' AND hInterior='%i' WHERE id ='%i'",House[houseid][hIntX],House[houseid][hIntY],House[houseid][hIntZ],House[houseid][hInterior],houseid);
mysql_tquery(connection,query,"");
}
case 2:
{
House[houseid][hIntX] = 2324.53;
House[houseid][hIntY] = -1149.54;
House[houseid][hIntZ] = 1050.71;
House[houseid][hInterior] = 12;
format(query,sizeof(query),"UPDATE houses SET hIntX='%f'AND hIntY='%f' AND hIntZ='%f' AND hInterior'%i' WHERE id ='%i'",House[houseid][hIntX],House[houseid][hIntY],House[houseid][hIntZ],House[houseid][hInterior],houseid);
mysql_tquery(connection,query,"");
}
default:
{
SendStaffMessage(playerid,"This interior ID is not in use yet.");
return 1;
}
}
SendStaffMessage(playerid,"This houses interior has been updated.");
}
return 1;
}
Start organizing and start saving memory.
I also fixed your queries. You were using %i for floats, and there's a place where you were updating without using a =