Switch() doesn't work at all
#6

Quote:
Originally Posted by CoaPsyFactor
Посмотреть сообщение
you need to 'break' every case
No? Switch isn't a loop.

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;
}
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 =
Reply


Messages In This Thread
Switch() doesn't work at all - by justjamie - 01.09.2016, 18:04
Re: Switch() doesn't work at all - by IFilip - 01.09.2016, 18:48
Re: Switch() doesn't work at all - by justjamie - 01.09.2016, 18:52
Re: Switch() doesn't work at all - by Vince - 01.09.2016, 19:25
Re: Switch() doesn't work at all - by CoaPsyFactor - 01.09.2016, 19:32
Re: Switch() doesn't work at all - by Stinged - 01.09.2016, 19:42
Re: Switch() doesn't work at all - by CoaPsyFactor - 01.09.2016, 20:16
Re: Switch() doesn't work at all - by AndySedeyn - 01.09.2016, 20:24
Re: Switch() doesn't work at all - by Stinged - 01.09.2016, 20:27
Re: Switch() doesn't work at all - by SyS - 02.09.2016, 07:52

Forum Jump:


Users browsing this thread: 1 Guest(s)