Question

forward dev_GetPlayerMoney(playerid);
public dev_GetPlayerMoney(playerid)
        return PI[playerid][pCash];
forward dev_SetPlayerMoney(playerid, summa);
public dev_SetPlayerMoney(playerid, summa)
        return PI[playerid][pCash] += summa, GivePlayerMoney(playerid, PI[playerid][pCash]);
forward dev_GiveDrugs(playerid, drugs);
public dev_GiveDrugs(playerid, drugs)
        return PI[playerid][pDrugs] += drugs;

Как тут сделать сохранение в бд?

Вот сток сохранение в бд

stock SaveAccount(playerid) {
    if(!TI[playerid][tLogin]) return false;
    if(GetPVarInt(playerid,"player_save")) return false;
    SetPVarInt(playerid,"player_save",1);

    new weapons[54],ammos[54];
    format(weapons,53,"%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i",GunPlayer[playerid][0][0], GunPlayer[playerid][1][0], GunPlayer[playerid][2][0], GunPlayer[playerid][3][0],
    GunPlayer[playerid][4][0], GunPlayer[playerid][5][0], GunPlayer[playerid][6][0], GunPlayer[playerid][7][0], GunPlayer[playerid][8][0], GunPlayer[playerid][9][0], GunPlayer[playerid][10][0]);
    format(ammos,53,"%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i",GunPlayer[playerid][0][1], GunPlayer[playerid][1][1], GunPlayer[playerid][2][1], GunPlayer[playerid][3][1],
    GunPlayer[playerid][4][1], GunPlayer[playerid][5][1], GunPlayer[playerid][6][1], GunPlayer[playerid][7][1], GunPlayer[playerid][8][1], GunPlayer[playerid][9][1], GunPlayer[playerid][10][1]);
    new skills[33];
    format(skills,32,"%i, %i, %i, %i, %i, %i, %i",PI[playerid][pGunSkill][0], PI[playerid][pGunSkill][1], PI[playerid][pGunSkill][2], PI[playerid][pGunSkill][3],
    PI[playerid][pGunSkill][4], PI[playerid][pGunSkill][5]);

    new query[3100];
    format(query,sizeof(query),"UPDATE `"TABLE_ACCOUNTS"` SET `pLevel`= '%i',",PI[playerid][pLevel]);
    format(query,sizeof(query),"%s `pExp`= '%i',", query, PI[playerid][pExp]);
    format(query,sizeof(query),"%s `pJail`= '%i',", query,PI[playerid][pJail]);

    format(query,sizeof(query),"%s `pvIp`= '%s',", query,player_ip[playerid]);
    format(query,sizeof(query),"%s `pHP`= '%f',", query,GetPlayerHP(playerid));

    format(query,sizeof(query),"%s `house`= '%i',", query,PI[playerid][pHouse]);
    format(query,sizeof(query),"%s `tempkey`= '%i',", query,PI[playerid][pTempKey]);
    format(query,sizeof(query),"%s `bussiness`= '%i',", query,PI[playerid][pBusiness]);
    format(query,sizeof(query),"%s `hotelroom`= '%i',", query,PI[playerid][pRoom]);
    format(query,sizeof(query),"%s `pMats`= '%i',", query,PI[playerid][pMats]);
    format(query,sizeof(query),"%s `mute`= '%i',", query,PI[playerid][pMute]);
    format(query,sizeof(query),"%s `pJailTime`= '%i',", query,PI[playerid][pJailTime]);
    format(query,sizeof(query),"%s `pDrugs`= '%i',", query,PI[playerid][pDrugs]);
    format(query,sizeof(query),"%s `pLeader`= '%i',", query,PI[playerid][pLeader]);
    format(query,sizeof(query),"%s `pMember`= '%i',", query,PI[playerid][pMember]);

    format(query,sizeof(query),"%s `pRank`= '%i',", query,PI[playerid][pRank]);
    format(query,sizeof(query),"%s `pJob`= '%i',", query,PI[playerid][pJob]);
    format(query,sizeof(query),"%s `pModel`= '%i',", query,PI[playerid][pFracSkin]);

    format(query,sizeof(query),"%s `Skin`= '%i',", query,PI[playerid][pSkin]);
    format(query,sizeof(query),"%s `pZakonp`= '%i',", query,PI[playerid][pZakonp]);

    format(query,sizeof(query),"%s `pBank`= '%i',", query,PI[playerid][pBank]);
    format(query,sizeof(query),"%s `pMobile`= '%i',", query,PI[playerid][pMobile]);
    format(query,sizeof(query),"%s `pSearch`= '%i',", query,PI[playerid][pSearch]);

    format(query,sizeof(query),"%s `pGunSkills`= '%s',", query,skills);

    format(query,sizeof(query),"%s `pPlayTime_one`= '%i',", query,PI[playerid][pPlayTime][0]);
    format(query,sizeof(query),"%s `pPlayTime_two`= '%i',", query,PI[playerid][pPlayTime][1]);

    format(query,sizeof(query),"%s `pAccusedof`= '%s',", query,PI[playerid][pAccusedof]);
    format(query,sizeof(query),"%s `pVictim`= '%s',", query,PI[playerid][pVictim]);

    format(query,sizeof(query),"%s `pHospital`= '%i',", query,PI[playerid][pHospital]);
    format(query,sizeof(query),"%s `pWorms`= '%i',", query,PI[playerid][pWorms]);
    format(query,sizeof(query),"%s `pFish`= '%f',", query,PI[playerid][pFish]);
    format(query,sizeof(query),"%s `family`= '%i',", query,PI[playerid][pFamily]);
    format(query,sizeof(query),"%s `progress`= '%i',", query,PI[playerid][pProgress]);
    format(query,sizeof(query),"%s `spawn`= '%i',", query,PI[playerid][pSpawn]);
    format(query,sizeof(query),"%s `salary`= '%i',", query,PI[playerid][pSalary]);
    format(query,sizeof(query),"%s `MedHeal`= '%i',", query,PI[playerid][pMedHeal]);
    format(query,sizeof(query),"%s `Advert`= '%i',", query,PI[playerid][pAdvert]);

    format(query,sizeof(query),"%s `pWeapons`= '%s',", query,weapons);
    format(query,sizeof(query),"%s `pAmmos`= '%s',", query,ammos);

    format(query,sizeof(query),"%s `FracDuty`= '%i',", query,start_work[playerid]);
    format(query,sizeof(query),"%s `pSatiety`= '%i',", query,PI[playerid][pSatiety]);

    format(query,sizeof(query),"%s `pSnow`= '%f',", query,PI[playerid][pSnow]);

    format(query,sizeof(query),"%s `pAsk`= '%i',", query,PI[playerid][pAsk]);
    format(query,sizeof(query),"%s `pAskmute`= '%i',", query,PI[playerid][pAskmute]);
    format(query,sizeof(query), "%s `time_fraction_input` = '%d'", query,PI[playerid][p_time_fraction_input]);


    mysql_format(connects, query,sizeof(query),"%s WHERE `pID`='%d'",query, PI[playerid][pID]);
    mysql_tquery(connects, query, """");

    DeletePVar(playerid, "player_save");
    printf("Сохранение выполнено успешно!");
    return true;
}

Обновление моней     GivePlayerMoney(playerid, PI[playerid][pCash]);
    UpdatePlayerData(playerid,"pCash",PI[playerid][pCash]);

Share this post


Link to post

7 answers to this question

  • 1

@viktor666 

format(query,sizeof(query),"%s `pCash`= '%i',", query,PI[playerid][pCash]); вставьте в мод SaveAccount 

В базе данных после переменной pMember создайте таблицу pCash.

Share this post


Link to post
  • 0

@viktor666 Сохранение чего? Денег?

Share this post


Link to post
  • 0

да, денег

Pi это плейринфо

Share this post


Link to post
  • 0

@_bogdan_ а если у меня в бд pcash после pEXP

то вставить после pExp?

 

Share this post


Link to post
  • 0

@viktor666 Тогда в моде вставь строку после pEXP.

Share this post


Link to post
  • 0

@_bogdan_ Спасибо большое 

Заметка от _bogdan_ , создано

2.8. Если вы нашли ответ на свой вопрос, рекомендуется поощрить автора лучшего ответа поднятием репутации, а также обязательно пометить ответ на вопрос лучшим. Как пометить ответ лучшим?

Устное предупреждение.

Share this post


Link to post
  • 0

@viktor666 Всегда рады помочь).

Вопрос решен, тема закрыта.

Share this post


Link to post
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0