Jump to content
  • 0

Probleme case


PuRiSaNu

Question

Buna ziua, am si eu o problema cu casele si am zis sa ma sfatuiesc si cu voi daca pot rezolva ceva cu acest sistem inainte sa il refac, poate cineva va sti o solutie si nu voi mai fi nevoit sa il refac, problema este in felul urmator.

daca un player cumpara o casa in baza de date nu isi face update sa apara cine a cumparat casa, si dupa restart server il da de la casa dar casa nu mai este a nimanui apare de vanzare....

stock SaveHouse()
{
 new query[2596], str[190];
    for(new i = 1; i < MaxHouse+1; i++)
    {
        format(query,sizeof(query),"UPDATE `house` SET ");
        format(str, sizeof(str), "owner = '%s' ,", House[i][hVladelec]); strcat(query, str);
        format(str, sizeof(str), "class = '%s' ,", House[i][hClass]); strcat(query, str);
        format(str, sizeof(str), "prod = '%d' ,", House[i][hProd]); strcat(query, str);
        format(str, sizeof(str), "enterX = '%f' ,", House[i][hEnterX]); strcat(query, str);
        format(str, sizeof(str), "enterY = '%f' ,", House[i][hEnterY]); strcat(query, str);
        format(str, sizeof(str), "enterZ = '%f' ,", House[i][hEnterZ]); strcat(query, str);
        format(str, sizeof(str), "vhodX = '%f' ,", House[i][hVhodX]); strcat(query, str);
        format(str, sizeof(str), "vhodY = '%f' ,", House[i][hVhodY]); strcat(query, str);
        format(str, sizeof(str), "vhodZ = '%f' ,", House[i][hVhodZ]); strcat(query, str);
        format(str, sizeof(str), "exitX = '%f' ,", House[i][hExitX]); strcat(query, str);
        format(str, sizeof(str), "exitY = '%f' ,", House[i][hExitY]); strcat(query, str);
        format(str, sizeof(str), "exitZ = '%f' ,", House[i][hExitZ]); strcat(query, str);
        format(str, sizeof(str), "angle = '%f' ,", House[i][hAngle]); strcat(query, str);
        format(str, sizeof(str), "interior = '%d' ,", House[i][hInt]); strcat(query, str);
        format(str, sizeof(str), "world = '%d' ,", House[i][hWord]); strcat(query, str);
        format(str, sizeof(str), "number = '%d' ,", House[i][hNomer]); strcat(query, str);
        format(str, sizeof(str), "zamok = '%d' ,", House[i][hZamok]); strcat(query, str);
        format(str, sizeof(str), "cabinet = '%d' ,", House[i][hShkaf]); strcat(query, str);
        format(str, sizeof(str), "Aptek = '%d' ,", House[i][hAptek]); strcat(query, str);
        format(str, sizeof(str), "cost = '%d' ,", House[i][hCena]); strcat(query, str);
        format(str, sizeof(str), "Safe = '%d' ,", House[i][hSafe]); strcat(query, str);
        format(str, sizeof(str), "cabinetfX = '%f' ,", House[i][hCShkafX]); strcat(query, str);
        format(str, sizeof(str), "cabinetfY = '%f' ,", House[i][hCShkafY]); strcat(query, str);
        format(str, sizeof(str), "cabinetfZ = '%f' ,", House[i][hCShkafZ]); strcat(query, str);
        format(str, sizeof(str), "cabinet_rotX = '%f' ,", House[i][hChkRotX]); strcat(query, str);
        format(str, sizeof(str), "cabinet_rotY = '%f' ,", House[i][hChkRotY]); strcat(query, str);
        format(str, sizeof(str), "hcreated_intid = '%d' ,", House[i][hcreated_intid]); strcat(query, str);
        format(str, sizeof(str), "gas = '%d' ,", House[i][hGas]); strcat(query, str);
        format(str, sizeof(str), "improve_whouse = '%d' ,", House[i][hWhouseSize]); strcat(query, str);

        for(new k; k < 8; k++)
        {
            format(str, sizeof(str), "skin_%d = '%d' ,", k, HOUSE_SKIN[i][k]); strcat(query, str);
        }
        format(str, sizeof(str), "cabinet_rotZ = '%f' ,", House[i][hChkRotZ]); strcat(query, str);
        format(str, sizeof(str), "credit_electro = '%d' ,", House[i][hDolgElectro]); strcat(query, str);
        format(str, sizeof(str), "credit_meria = '%d' ,", House[i][hDolgMeria]); strcat(query, str);
        format(str, sizeof(str), "dost_meria = '%d' ,", House[i][hDostavkaMeria]); strcat(query, str);
        format(str, sizeof(str), "dost_electro = '%d' ,", House[i][hDostavkaElectro]); strcat(query, str);

        for(new k  = 1;k<INVENT_MAX_SLOTS_X*INVENT_MAX_SLOTS_Y+1;k++)
        {
            if(k < INVENT_MAX_SLOTS_X*INVENT_MAX_SLOTS_Y)
            {
                format(str, sizeof(str), "object_%d = '%d,%d,%s', ",
                k,
                INVENT_OBJECT_HOUSE[i][k][o_ID],
                INVENT_OBJECT_HOUSE[i][k][o_ammount],
                INVENT_OBJECT_HOUSE[i][k][o_param]);
                strcat(query, str);
            }
            else
            {
                format(str, sizeof(str), "object_%d = '%d,%d,%s' ",
                k,
                INVENT_OBJECT_HOUSE[i][k][o_ID],
                INVENT_OBJECT_HOUSE[i][k][o_ammount],
                INVENT_OBJECT_HOUSE[i][k][o_param]);
                strcat(query, str);
            }
        }

        format(str, sizeof(str), "WHERE `number` = '%d'", House[i][hNomer]); strcat(query, str);
        //print(query);
        mysql_function_query(MySQL_DATA[connectionHandle], query, false, "", "");
        DestroyDynamicObject(House[i][hShkafObject]);
        DestroyDynamic3DTextLabel(House[i][hShkafText]);
    }
}

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
Just now, PuRiSaNu said:

Buna ziua, am si eu o problema cu casele si am zis sa ma sfatuiesc si cu voi daca pot rezolva ceva cu acest sistem inainte sa il refac, poate cineva va sti o solutie si nu voi mai fi nevoit sa il refac, problema este in felul urmator.

daca un player cumpara o casa in baza de date nu isi face update sa apara cine a cumparat casa, si dupa restart server il da de la casa dar casa nu mai este a nimanui apare de vanzare....

stock SaveHouse()
{
 new query[2596], str[190];
    for(new i = 1; i < MaxHouse+1; i++)
    {
        format(query,sizeof(query),"UPDATE `house` SET ");
        format(str, sizeof(str), "owner = '%s' ,", House[i][hVladelec]); strcat(query, str);
        format(str, sizeof(str), "class = '%s' ,", House[i][hClass]); strcat(query, str);
        format(str, sizeof(str), "prod = '%d' ,", House[i][hProd]); strcat(query, str);
        format(str, sizeof(str), "enterX = '%f' ,", House[i][hEnterX]); strcat(query, str);
        format(str, sizeof(str), "enterY = '%f' ,", House[i][hEnterY]); strcat(query, str);
        format(str, sizeof(str), "enterZ = '%f' ,", House[i][hEnterZ]); strcat(query, str);
        format(str, sizeof(str), "vhodX = '%f' ,", House[i][hVhodX]); strcat(query, str);
        format(str, sizeof(str), "vhodY = '%f' ,", House[i][hVhodY]); strcat(query, str);
        format(str, sizeof(str), "vhodZ = '%f' ,", House[i][hVhodZ]); strcat(query, str);
        format(str, sizeof(str), "exitX = '%f' ,", House[i][hExitX]); strcat(query, str);
        format(str, sizeof(str), "exitY = '%f' ,", House[i][hExitY]); strcat(query, str);
        format(str, sizeof(str), "exitZ = '%f' ,", House[i][hExitZ]); strcat(query, str);
        format(str, sizeof(str), "angle = '%f' ,", House[i][hAngle]); strcat(query, str);
        format(str, sizeof(str), "interior = '%d' ,", House[i][hInt]); strcat(query, str);
        format(str, sizeof(str), "world = '%d' ,", House[i][hWord]); strcat(query, str);
        format(str, sizeof(str), "number = '%d' ,", House[i][hNomer]); strcat(query, str);
        format(str, sizeof(str), "zamok = '%d' ,", House[i][hZamok]); strcat(query, str);
        format(str, sizeof(str), "cabinet = '%d' ,", House[i][hShkaf]); strcat(query, str);
        format(str, sizeof(str), "Aptek = '%d' ,", House[i][hAptek]); strcat(query, str);
        format(str, sizeof(str), "cost = '%d' ,", House[i][hCena]); strcat(query, str);
        format(str, sizeof(str), "Safe = '%d' ,", House[i][hSafe]); strcat(query, str);
        format(str, sizeof(str), "cabinetfX = '%f' ,", House[i][hCShkafX]); strcat(query, str);
        format(str, sizeof(str), "cabinetfY = '%f' ,", House[i][hCShkafY]); strcat(query, str);
        format(str, sizeof(str), "cabinetfZ = '%f' ,", House[i][hCShkafZ]); strcat(query, str);
        format(str, sizeof(str), "cabinet_rotX = '%f' ,", House[i][hChkRotX]); strcat(query, str);
        format(str, sizeof(str), "cabinet_rotY = '%f' ,", House[i][hChkRotY]); strcat(query, str);
        format(str, sizeof(str), "hcreated_intid = '%d' ,", House[i][hcreated_intid]); strcat(query, str);
        format(str, sizeof(str), "gas = '%d' ,", House[i][hGas]); strcat(query, str);
        format(str, sizeof(str), "improve_whouse = '%d' ,", House[i][hWhouseSize]); strcat(query, str);

        for(new k; k < 8; k++)
        {
            format(str, sizeof(str), "skin_%d = '%d' ,", k, HOUSE_SKIN[i][k]); strcat(query, str);
        }
        format(str, sizeof(str), "cabinet_rotZ = '%f' ,", House[i][hChkRotZ]); strcat(query, str);
        format(str, sizeof(str), "credit_electro = '%d' ,", House[i][hDolgElectro]); strcat(query, str);
        format(str, sizeof(str), "credit_meria = '%d' ,", House[i][hDolgMeria]); strcat(query, str);
        format(str, sizeof(str), "dost_meria = '%d' ,", House[i][hDostavkaMeria]); strcat(query, str);
        format(str, sizeof(str), "dost_electro = '%d' ,", House[i][hDostavkaElectro]); strcat(query, str);

        for(new k  = 1;k<INVENT_MAX_SLOTS_X*INVENT_MAX_SLOTS_Y+1;k++)
        {
            if(k < INVENT_MAX_SLOTS_X*INVENT_MAX_SLOTS_Y)
            {
                format(str, sizeof(str), "object_%d = '%d,%d,%s', ",
                k,
                INVENT_OBJECT_HOUSE[i][k][o_ID],
                INVENT_OBJECT_HOUSE[i][k][o_ammount],
                INVENT_OBJECT_HOUSE[i][k][o_param]);
                strcat(query, str);
            }
            else
            {
                format(str, sizeof(str), "object_%d = '%d,%d,%s' ",
                k,
                INVENT_OBJECT_HOUSE[i][k][o_ID],
                INVENT_OBJECT_HOUSE[i][k][o_ammount],
                INVENT_OBJECT_HOUSE[i][k][o_param]);
                strcat(query, str);
            }
        }

        format(str, sizeof(str), "WHERE `number` = '%d'", House[i][hNomer]); strcat(query, str);
        //print(query);
        mysql_function_query(MySQL_DATA[connectionHandle], query, false, "", "");
        DestroyDynamicObject(House[i][hShkafObject]);
        DestroyDynamic3DTextLabel(House[i][hShkafText]);
    }
}

 

format(query,sizeof(query),"UPDATE `house` SET ");// tu aici nu faci nimic, este scrisa degeaba.
format(query,sizeof(query),"UPDATE `house` SET %s", str);//asa e bine

 

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

  • 0
Just now, PuRiSaNu said:

acum nu se mai compileaza, ramane asa 

Edit.

Vina mea am sters o functie fara sa imi dau seama daia nu mergea, dar tot nu se salveaza casele

stock SaveHouse()
{
 	new query[2596], str[190];
    for(new i = 1; i < MaxHouse+1; i++)
    {
        format(query,sizeof(query),"UPDATE `house` SET %s", str);
        format(str, sizeof(str), "owner = '%s' ,", House[i][hVladelec]); strcat(query, str);
        format(str, sizeof(str), "class = '%s' ,", House[i][hClass]); strcat(query, str);
        format(str, sizeof(str), "prod = '%d' ,", House[i][hProd]); strcat(query, str);
        format(str, sizeof(str), "enterX = '%f' ,", House[i][hEnterX]); strcat(query, str);
        format(str, sizeof(str), "enterY = '%f' ,", House[i][hEnterY]); strcat(query, str);
        format(str, sizeof(str), "enterZ = '%f' ,", House[i][hEnterZ]); strcat(query, str);
        format(str, sizeof(str), "vhodX = '%f' ,", House[i][hVhodX]); strcat(query, str);
        format(str, sizeof(str), "vhodY = '%f' ,", House[i][hVhodY]); strcat(query, str);
        format(str, sizeof(str), "vhodZ = '%f' ,", House[i][hVhodZ]); strcat(query, str);
        format(str, sizeof(str), "exitX = '%f' ,", House[i][hExitX]); strcat(query, str);
        format(str, sizeof(str), "exitY = '%f' ,", House[i][hExitY]); strcat(query, str);
        format(str, sizeof(str), "exitZ = '%f' ,", House[i][hExitZ]); strcat(query, str);
        format(str, sizeof(str), "angle = '%f' ,", House[i][hAngle]); strcat(query, str);
        format(str, sizeof(str), "interior = '%d' ,", House[i][hInt]); strcat(query, str);
        format(str, sizeof(str), "world = '%d' ,", House[i][hWord]); strcat(query, str);
        format(str, sizeof(str), "number = '%d' ,", House[i][hNomer]); strcat(query, str);
        format(str, sizeof(str), "zamok = '%d' ,", House[i][hZamok]); strcat(query, str);
        format(str, sizeof(str), "cabinet = '%d' ,", House[i][hShkaf]); strcat(query, str);
        format(str, sizeof(str), "Aptek = '%d' ,", House[i][hAptek]); strcat(query, str);
        format(str, sizeof(str), "cost = '%d' ,", House[i][hCena]); strcat(query, str);
        format(str, sizeof(str), "Safe = '%d' ,", House[i][hSafe]); strcat(query, str);
        format(str, sizeof(str), "cabinetfX = '%f' ,", House[i][hCShkafX]); strcat(query, str);
        format(str, sizeof(str), "cabinetfY = '%f' ,", House[i][hCShkafY]); strcat(query, str);
        format(str, sizeof(str), "cabinetfZ = '%f' ,", House[i][hCShkafZ]); strcat(query, str);
        format(str, sizeof(str), "cabinet_rotX = '%f' ,", House[i][hChkRotX]); strcat(query, str);
        format(str, sizeof(str), "cabinet_rotY = '%f' ,", House[i][hChkRotY]); strcat(query, str);
        format(str, sizeof(str), "hcreated_intid = '%d' ,", House[i][hcreated_intid]); strcat(query, str);
        format(str, sizeof(str), "gas = '%d' ,", House[i][hGas]); strcat(query, str);
        format(str, sizeof(str), "improve_whouse = '%d' ,", House[i][hWhouseSize]); strcat(query, str);

        for(new k; k < 8; k++)
        {
            format(str, sizeof(str), "skin_%d = '%d' ,", k, HOUSE_SKIN[i][k]); strcat(query, str);
        }
        format(str, sizeof(str), "cabinet_rotZ = '%f' ,", House[i][hChkRotZ]); strcat(query, str);
        format(str, sizeof(str), "credit_electro = '%d' ,", House[i][hDolgElectro]); strcat(query, str);
        format(str, sizeof(str), "credit_meria = '%d' ,", House[i][hDolgMeria]); strcat(query, str);
        format(str, sizeof(str), "dost_meria = '%d' ,", House[i][hDostavkaMeria]); strcat(query, str);
        format(str, sizeof(str), "dost_electro = '%d' ,", House[i][hDostavkaElectro]); strcat(query, str);

        for(new k  = 1;k<INVENT_MAX_SLOTS_X*INVENT_MAX_SLOTS_Y+1;k++)
        {
            if(k < INVENT_MAX_SLOTS_X*INVENT_MAX_SLOTS_Y)
            {
                format(str, sizeof(str), "object_%d = '%d,%d,%s', ",
                k,
                INVENT_OBJECT_HOUSE[i][k][o_ID],
                INVENT_OBJECT_HOUSE[i][k][o_ammount],
                INVENT_OBJECT_HOUSE[i][k][o_param]);
                strcat(query, str);
            }
            else
            {
                format(str, sizeof(str), "object_%d = '%d,%d,%s' ",
                k,
                INVENT_OBJECT_HOUSE[i][k][o_ID],
                INVENT_OBJECT_HOUSE[i][k][o_ammount],
                INVENT_OBJECT_HOUSE[i][k][o_param]);
                strcat(query, str);
            }
        }

        format(str, sizeof(str), "WHERE `number` = '%d'", House[i][hNomer]); strcat(query, str);
        //print(query);
        mysql_pquery(/*handle*/,query, "", "");//inlcuiesti aici handle cu variabila care o ai tu la conexiune
        DestroyDynamicObject(House[i][hShkafObject]);
        DestroyDynamic3DTextLabel(House[i][hShkafText]);
    }
}

incearca asa

  • Upvote 1

**********************************

Servicii Scripting de calitate:

*********************************

Future Project: ExpertGame

*********************************

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.