COMMAND:ahouse(playerid,params[])
{
if(!Player[playerid][Authed] || Player[playerid][Admin] < 4) return SendClientError(playerid, "You are not authorised to use this command.");
new Params[3][20], Params3[120], query[400],string[200],zone[100];
if(sscanf(params, "s[120]", string)) return SendClientUsage(playerid, "/ahouse [ Create / Interior ]");
sscanf(string, "s[20]s[20]s[120]", Params[0], Params[1],Params3);
if(!strcmp(Params[0], "create", true))
{
new Float:px,Float:py,Float:pz;
GetPlayerPos(playerid,px,py,pz);
GetZone(px,py,pz,zone);
format(query,sizeof(query),"INSERT INTO houses (hOwner,hLocation,hX,hY,hZ) VALUES ('%s','%s','%f','%f','%f')",Name(playerid),zone,px,py,pz);
mysql_tquery(connection,query,"CreateHouse","i",playerid);
}
if(!strcmp(Params[0], "interior", true))
{
new houseid = strval(Params[1]);
new intid = strval(Params3);
if(!houseid) return SendClientUsage(playerid, "/ahouse [HouseID] [InteriorID]");
if(!intid) return SendClientUsage(playerid, "/ahouse [HouseID] [InteriorID]");
new query3[200];
switch(intid)
{
case 1:
{
House[houseid][hIntX] = 140.17;
House[houseid][hIntY] = 1366.07;
House[houseid][hIntZ] = 1083.65;
House[houseid][hInterior] = 5;
format(query3,sizeof(query3),"UPDATE houses SET hIntX='%i'AND hIntY='%i' AND hIntZ='%i' AND hInterior'%i' WHERE id ='%i'",House[houseid][hIntX],House[houseid][hIntY],House[houseid][hIntZ],House[houseid][hInterior],houseid);
mysql_tquery(connection,query3,"");
}
case 2:
{
House[houseid][hIntX] = 2324.53;
House[houseid][hIntY] = -1149.54;
House[houseid][hIntZ] = 1050.71;
House[houseid][hInterior] = 12;
format(query3,sizeof(query3),"UPDATE houses SET hIntX='%i'AND hIntY='%i' AND hIntZ='%i' AND hInterior'%i' WHERE id ='%i'",House[houseid][hIntX],House[houseid][hIntY],House[houseid][hIntZ],House[houseid][hInterior],houseid);
mysql_tquery(connection,query3,"");
}
default:
{
SendStaffMessage(playerid,"This interior ID is not in use yet.");
return 1;
}
}
}
SendStaffMessage(playerid,"This houses interior has been updated.");
return 1;
}
Try creating "debug" with prints in switch and out to see where code get "stopped".
|
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;
}
No? Switch isn't a loop.
pawn Код:
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 = |
var test = function () { var a = 1, b = 'Nothing'; switch (a) { case 1: b = 'One'; case 2: b = 'Two'; default: b = 'Unknown'; } return b; } test();
of course you have to break or return each case, as it will fall through to next....
if u know how paste this code in browsers js console and see what happens Код:
var test = function () { var a = 1, b = 'Nothing'; switch (a) { case 1: b = 'One'; case 2: b = 'Two'; default: b = 'Unknown'; } return b; } test(); |
new a = 1, b[8] = "Nothing";
switch (a)
{
case 1:
b = "One";
case 2:
b = "Two";
default:
b = "Unknown";
}
print(b);
of course you have to break or return each case, as it will fall through to next....
if u know how paste this code in browsers js console and see what happens Код:
var test = function () { var a = 1, b = 'Nothing'; switch (a) { case 1: b = 'One'; case 2: b = 'Two'; default: b = 'Unknown'; } return b; } test(); |