Рекомендованные сообщения



12 posts in this topic

Здравствуйте, объясните пожалуйста. Как сделать сохранение аккаунтов после каждого действия игрока? MySQL

Edited by Данила

Share this post


Link to post
Share on other sites

@Данила команда saveacc есть?

 

Share this post


Link to post
Share on other sites
5 минут назад, arno37 сказал:

@Данила команда saveacc есть?

 

Да

Share this post


Link to post
Share on other sites
CMD:saveacc(playerid, params[])
{
	if(antiflood[playerid] > 0) return SendClientMessage(playerid, COLOR_WARNING,"Íå ôëóäè!");
    antiflood[playerid]++;
    if(PLAYER_DATA[playerid][data_LOGGED] == false) return SendClientMessage(playerid,COLOR_WARNING,"Âû íå àâòîðèçîâàíû íà ñåðâåðå!");
    if(PLAYER_DATA[playerid][data_ADMLVL] < 8) return true;
	SaveAcc();
	SendClientMessage(playerid, COLOR_GREY, "[Evence] Àêêàóíòû óñïåøíî ñîõðàíåíû!");
	return true;
}CMD:saveacc(playerid, params[])
{
	if(antiflood[playerid] > 0) return SendClientMessage(playerid, COLOR_WARNING,"Не флуди!");
    antiflood[playerid]++;
    if(PLAYER_DATA[playerid][data_LOGGED] == false) return SendClientMessage(playerid,COLOR_WARNING,"Вы не авторизованы на сервере!");
    if(PLAYER_DATA[playerid][data_ADMLVL] < 8) return true;
	SaveAcc();
	SendClientMessage(playerid, COLOR_GREY, "[Evence] Аккаунты успешно сохранены!");
	return true;
}
Спойлер

stock SaveAcc()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
	{
	    if(PLAYER_DATA[i][data_LOGGED] == false) continue;
		SavePlayerData(i);
	}
	return true;
}

 

Спойлер

stock SavePlayerData(playerid)
{
	if(PLAYER_DATA[playerid][data_LOGGED] == true && IsPlayerConnected(playerid))
	{
	    new wind[3500], string[150];
		wind = "UPDATE `accounts` SET ";
		acc_int_strcat(wind, sizeof(wind), "logdate_day", PLAYER_DATA[playerid][data_LOGDATE_DAY]);
		acc_int_strcat(wind, sizeof(wind), "logdate_month", PLAYER_DATA[playerid][data_LOGDATE_MONTH]);
		acc_int_strcat(wind, sizeof(wind), "logdate_year", PLAYER_DATA[playerid][data_LOGDATE_YEAR]);
		acc_int_strcat(wind, sizeof(wind), "osnslot", PLAYER_DATA[playerid][data_OSNSLOT]);
		acc_int_strcat(wind, sizeof(wind), "skin1", PLAYER_DATA[playerid][data_SLOT1]);
		acc_int_strcat(wind, sizeof(wind), "skin2", PLAYER_DATA[playerid][data_SLOT2]);
		acc_int_strcat(wind, sizeof(wind), "skin3", PLAYER_DATA[playerid][data_SLOT3]);
		acc_int_strcat(wind, sizeof(wind), "skin4", PLAYER_DATA[playerid][data_SLOT4]);
		acc_int_strcat(wind, sizeof(wind), "skin5", PLAYER_DATA[playerid][data_SLOT5]);
		acc_int_strcat(wind, sizeof(wind), "skin6", PLAYER_DATA[playerid][data_SLOT6]);
		acc_int_strcat(wind, sizeof(wind), "kanistra", PLAYER_DATA[playerid][data_KANISTRA]);
		acc_int_strcat(wind, sizeof(wind), "mask", PLAYER_DATA[playerid][data_MASK]);
		acc_int_strcat(wind, sizeof(wind), "drink", PLAYER_DATA[playerid][data_DRINK]);
		acc_int_strcat(wind, sizeof(wind), "remka", PLAYER_DATA[playerid][data_REMKA]);
		acc_int_strcat(wind, sizeof(wind), "heals", PLAYER_DATA[playerid][data_HEALS]);
		acc_int_strcat(wind, sizeof(wind), "KUBINSKAYA", PLAYER_DATA[playerid][data_KUBINSKAYA]);
		acc_int_strcat(wind, sizeof(wind), "PRIMA", PLAYER_DATA[playerid][data_PRIMA]);
		acc_int_strcat(wind, sizeof(wind), "MARLBORO", PLAYER_DATA[playerid][data_MARLBORO]);
		acc_int_strcat(wind, sizeof(wind), "PARLAMENT", PLAYER_DATA[playerid][data_PARLAMENT]);
		acc_int_strcat(wind, sizeof(wind), "ZAJIGALKA", PLAYER_DATA[playerid][data_ZAJIGALKA]);
		acc_int_strcat(wind, sizeof(wind), "CHASY", PLAYER_DATA[playerid][data_CHASY]);
		acc_int_strcat(wind, sizeof(wind), "PLAY", PLAYER_DATA[playerid][data_PLAY]);
		acc_int_strcat(wind, sizeof(wind), "money", PLAYER_DATA[playerid][data_MONEY]);
		acc_int_strcat(wind, sizeof(wind), "lvl", PLAYER_DATA[playerid][data_LVL]);
		acc_int_strcat(wind, sizeof(wind), "exp", PLAYER_DATA[playerid][data_EXP]);
		acc_int_strcat(wind, sizeof(wind), "skinm", PLAYER_DATA[playerid][data_SKINM]);
		acc_int_strcat(wind, sizeof(wind), "jobin", PLAYER_DATA[playerid][data_JOBIN]);
		acc_int_strcat(wind, sizeof(wind), "golod", PLAYER_DATA[playerid][data_GOLOD]);
		acc_int_strcat(wind, sizeof(wind), "member", PLAYER_DATA[playerid][data_MEMBER]);
		acc_int_strcat(wind, sizeof(wind), "leader", PLAYER_DATA[playerid][data_LEADER]);
		acc_int_strcat(wind, sizeof(wind), "rank", PLAYER_DATA[playerid][data_RANK]);
		acc_int_strcat(wind, sizeof(wind), "admlvl", PLAYER_DATA[playerid][data_ADMLVL]);
		acc_str_strcat(wind, sizeof(wind), "login_ip", PLAYER_DATA[playerid][data_LOGIN_IP]);
		acc_str_strcat(wind, sizeof(wind), "BankUSD", PLAYER_DATA[playerid][pBankUSD]);
		acc_str_strcat(wind, sizeof(wind), "BankEUR", PLAYER_DATA[playerid][pBankEUR]);
		acc_str_strcat(wind, sizeof(wind), "SrokD", PLAYER_DATA[playerid][pSrokD]);
		acc_str_strcat(wind, sizeof(wind), "SummaD", PLAYER_DATA[playerid][pSummaD]);
		acc_str_strcat(wind, sizeof(wind), "SRKD", PLAYER_DATA[playerid][pSRKD]);
		acc_str_strcat(wind, sizeof(wind), "BTC", PLAYER_DATA[playerid][pBTC]);
		acc_str_strcat(wind, sizeof(wind), "Turmalin", PLAYER_DATA[playerid][Turmalin]);
		acc_str_strcat(wind, sizeof(wind), "Aleksandrit", PLAYER_DATA[playerid][Aleksandrit]);
		acc_str_strcat(wind, sizeof(wind), "Izumrud", PLAYER_DATA[playerid][Izumrud]);
		acc_str_strcat(wind, sizeof(wind), "Benitoit", PLAYER_DATA[playerid][Benitoit]);
		acc_str_strcat(wind, sizeof(wind), "Sapfir", PLAYER_DATA[playerid][Sapfir]);
		acc_str_strcat(wind, sizeof(wind), "CHOpal", PLAYER_DATA[playerid][CHOpal]);
		acc_str_strcat(wind, sizeof(wind), "Eremeevit", PLAYER_DATA[playerid][Eremeevit]);
		acc_str_strcat(wind, sizeof(wind), "Zoloto", PLAYER_DATA[playerid][Zoloto]);
		acc_str_strcat(wind, sizeof(wind), "Serebro", PLAYER_DATA[playerid][Serebro]);
		acc_str_strcat(wind, sizeof(wind), "KA", PLAYER_DATA[playerid][KA]);
		acc_str_strcat(wind, sizeof(wind), "PAR", PLAYER_DATA[playerid][PAR]);
		acc_str_strcat(wind, sizeof(wind), "Jadeit", PLAYER_DATA[playerid][Jadeit]);
		acc_str_strcat(wind, sizeof(wind), "Almaz", PLAYER_DATA[playerid][Almaz]);
		acc_str_strcat(wind, sizeof(wind), "Rubin", PLAYER_DATA[playerid][Rubin]);
		acc_str_strcat(wind, sizeof(wind), "NEFT", PLAYER_DATA[playerid][pNEFT]);
		acc_int_strcat(wind, sizeof(wind), "mute", PLAYER_DATA[playerid][data_MUTE]);
		acc_int_strcat(wind, sizeof(wind), "mutetime", PLAYER_DATA[playerid][data_MUTETIME]);
		acc_int_strcat(wind, sizeof(wind), "warn", PLAYER_DATA[playerid][data_WARN]);
		acc_int_strcat(wind, sizeof(wind), "awarn", PLAYER_DATA[playerid][data_aWARN]);
		acc_int_strcat(wind, sizeof(wind), "warntime", PLAYER_DATA[playerid][data_WARNTIME]);
		acc_int_strcat(wind, sizeof(wind), "salary", PLAYER_DATA[playerid][data_SALARY]);
		acc_int_strcat(wind, sizeof(wind), "bank", PLAYER_DATA[playerid][data_BANK]);
		acc_int_strcat(wind, sizeof(wind), "licb", PLAYER_DATA[playerid][data_LICB]);
		acc_int_strcat(wind, sizeof(wind), "licm", PLAYER_DATA[playerid][data_LICM]);
		acc_int_strcat(wind, sizeof(wind), "licv", PLAYER_DATA[playerid][data_LICV]);
		acc_int_strcat(wind, sizeof(wind), "licvodn", PLAYER_DATA[playerid][data_LICVODN]);
		acc_int_strcat(wind, sizeof(wind), "licg", PLAYER_DATA[playerid][data_LICG]);
		acc_int_strcat(wind, sizeof(wind), "licgun", PLAYER_DATA[playerid][data_LICGUN]);
		acc_int_strcat(wind, sizeof(wind), "Vozrast", PLAYER_DATA[playerid][Vozrast]);
		acc_int_strcat(wind, sizeof(wind), "time", PLAYER_DATA[playerid][data_TIME]);
		acc_int_strcat(wind, sizeof(wind), "car_1", PLAYER_DATA[playerid][data_CAR][0]);
		acc_int_strcat(wind, sizeof(wind), "carfuel_1", PLAYER_DATA[playerid][data_CARFUEL][0]);
		acc_int_strcat(wind, sizeof(wind), "car_color1_1", PLAYER_DATA[playerid][data_CAR_COLOR1][0]);
		acc_int_strcat(wind, sizeof(wind), "car_color2_1", PLAYER_DATA[playerid][data_CAR_COLOR2][0]);
		acc_int_strcat(wind, sizeof(wind), "car_2", PLAYER_DATA[playerid][data_CAR][1]);
		acc_int_strcat(wind, sizeof(wind), "carfuel_2", PLAYER_DATA[playerid][data_CARFUEL][1]);
		acc_int_strcat(wind, sizeof(wind), "car_color1_2", PLAYER_DATA[playerid][data_CAR_COLOR1][1]);
		acc_int_strcat(wind, sizeof(wind), "car_color2_2", PLAYER_DATA[playerid][data_CAR_COLOR2][1]);
		acc_int_strcat(wind, sizeof(wind), "car_3", PLAYER_DATA[playerid][data_CAR][2]);
		acc_int_strcat(wind, sizeof(wind), "carfuel_3", PLAYER_DATA[playerid][data_CARFUEL][2]);
		acc_int_strcat(wind, sizeof(wind), "car_color1_3", PLAYER_DATA[playerid][data_CAR_COLOR1][2]);
		acc_int_strcat(wind, sizeof(wind), "car_color2_3", PLAYER_DATA[playerid][data_CAR_COLOR2][2]);
		acc_int_strcat(wind, sizeof(wind), "vip", PLAYER_DATA[playerid][data_VIP]);
		acc_int_strcat(wind, sizeof(wind), "drugs", PLAYER_DATA[playerid][data_DRUGS]);
		acc_int_strcat(wind, sizeof(wind), "met", PLAYER_DATA[playerid][data_MET]);
		acc_int_strcat(wind, sizeof(wind), "wanted", PLAYER_DATA[playerid][data_WANTED]);
		acc_int_strcat(wind, sizeof(wind), "zakon", PLAYER_DATA[playerid][data_ZAKON]);
		acc_int_strcat(wind, sizeof(wind), "number", PLAYER_DATA[playerid][data_NUMBER]);
		acc_int_strcat(wind, sizeof(wind), "number_m", PLAYER_DATA[playerid][data_NUMBER_M]);
		acc_int_strcat(wind, sizeof(wind), "jail", PLAYER_DATA[playerid][data_JAIL]);
		acc_int_strcat(wind, sizeof(wind), "jailtime", PLAYER_DATA[playerid][data_JAILTIME]);
		acc_int_strcat(wind, sizeof(wind), "donate", PLAYER_DATA[playerid][data_DONATE]);
		acc_int_strcat(wind, sizeof(wind), "phone", PLAYER_DATA[playerid][data_PHONE]);
		acc_int_strcat(wind, sizeof(wind), "phonebook", PLAYER_DATA[playerid][data_PHONEBOOK]);
		acc_int_strcat(wind, sizeof(wind), "satiety", PLAYER_DATA[playerid][data_SATIETY]);
		acc_float_strcat(wind, sizeof(wind), "hp", PLAYER_DATA[playerid][data_HP]);
		acc_float_strcat(wind, sizeof(wind), "arm", PLAYER_DATA[playerid][data_ARM]);
		acc_int_strcat(wind, sizeof(wind), "spawn", PLAYER_DATA[playerid][data_SPAWN]);
		acc_int_strcat(wind, sizeof(wind), "hospital", PLAYER_DATA[playerid][data_HOSPITAL]);
		acc_int_strcat(wind, sizeof(wind), "pistol_skill", PLAYER_DATA[playerid][data_PISTOL]);
		acc_int_strcat(wind, sizeof(wind), "sdpistol_skill", PLAYER_DATA[playerid][data_SDPISTOL]);
		acc_int_strcat(wind, sizeof(wind), "deagle_skill", PLAYER_DATA[playerid][data_DEAGLE]);
		acc_int_strcat(wind, sizeof(wind), "shotgun_skill", PLAYER_DATA[playerid][data_SHOTGUN]);
		acc_int_strcat(wind, sizeof(wind), "mp5_skill", PLAYER_DATA[playerid][data_MP5]);
		acc_int_strcat(wind, sizeof(wind), "ak47_skill", PLAYER_DATA[playerid][data_AK47]);
		acc_int_strcat(wind, sizeof(wind), "rifle_skill", PLAYER_DATA[playerid][data_SNIPERRIFLE]);
		acc_int_strcat(wind, sizeof(wind), "job", PLAYER_DATA[playerid][data_JOB]);
		acc_int_strcat(wind, sizeof(wind), "house", PLAYER_DATA[playerid][data_HOUSE]);
		acc_int_strcat(wind, sizeof(wind), "business", PLAYER_DATA[playerid][data_BUSINESS]);
		acc_int_strcat(wind, sizeof(wind), "kv", PLAYER_DATA[playerid][data_KV]);
		acc_int_strcat(wind, sizeof(wind), "padik", PLAYER_DATA[playerid][data_PADIK]);
		acc_int_strcat(wind, sizeof(wind), "gun0", PLAYER_DATA[playerid][data_GUN][0]);
		acc_int_strcat(wind, sizeof(wind), "gun1", PLAYER_DATA[playerid][data_GUN][1]);
		acc_int_strcat(wind, sizeof(wind), "gun2", PLAYER_DATA[playerid][data_GUN][2]);
		acc_int_strcat(wind, sizeof(wind), "gun3", PLAYER_DATA[playerid][data_GUN][3]);
		acc_int_strcat(wind, sizeof(wind), "gun4", PLAYER_DATA[playerid][data_GUN][4]);
		acc_int_strcat(wind, sizeof(wind), "gun5", PLAYER_DATA[playerid][data_GUN][5]);
		acc_int_strcat(wind, sizeof(wind), "gun6", PLAYER_DATA[playerid][data_GUN][6]);
		acc_int_strcat(wind, sizeof(wind), "gun7", PLAYER_DATA[playerid][data_GUN][7]);
		acc_int_strcat(wind, sizeof(wind), "gun8", PLAYER_DATA[playerid][data_GUN][8]);
		acc_int_strcat(wind, sizeof(wind), "gun9", PLAYER_DATA[playerid][data_GUN][9]);
		acc_int_strcat(wind, sizeof(wind), "gun10", PLAYER_DATA[playerid][data_GUN][10]);
		acc_int_strcat(wind, sizeof(wind), "gun11", PLAYER_DATA[playerid][data_GUN][11]);
		acc_int_strcat(wind, sizeof(wind), "gun12", PLAYER_DATA[playerid][data_GUN][12]);
		acc_int_strcat(wind, sizeof(wind), "ammo0", PLAYER_DATA[playerid][data_AMMO][0]);
		acc_int_strcat(wind, sizeof(wind), "ammo1", PLAYER_DATA[playerid][data_AMMO][1]);
		acc_int_strcat(wind, sizeof(wind), "ammo2", PLAYER_DATA[playerid][data_AMMO][2]);
		acc_int_strcat(wind, sizeof(wind), "ammo3", PLAYER_DATA[playerid][data_AMMO][3]);
		acc_int_strcat(wind, sizeof(wind), "ammo4", PLAYER_DATA[playerid][data_AMMO][4]);
		acc_int_strcat(wind, sizeof(wind), "ammo5", PLAYER_DATA[playerid][data_AMMO][5]);
		acc_int_strcat(wind, sizeof(wind), "ammo6", PLAYER_DATA[playerid][data_AMMO][6]);
		acc_int_strcat(wind, sizeof(wind), "ammo7", PLAYER_DATA[playerid][data_AMMO][7]);
		acc_int_strcat(wind, sizeof(wind), "ammo8", PLAYER_DATA[playerid][data_AMMO][8]);
		acc_int_strcat(wind, sizeof(wind), "ammo9", PLAYER_DATA[playerid][data_AMMO][9]);
		acc_int_strcat(wind, sizeof(wind), "ammo10", PLAYER_DATA[playerid][data_AMMO][10]);
		acc_int_strcat(wind, sizeof(wind), "ammo11", PLAYER_DATA[playerid][data_AMMO][11]);
		acc_int_strcat(wind, sizeof(wind), "ammo12", PLAYER_DATA[playerid][data_AMMO][12]);
		acc_int_strcat(wind, sizeof(wind), "promocode", PLAYER_DATA[playerid][data_PROMOCODE]);
		strdel(wind, strlen(wind)-1, strlen(wind));
		format(string,sizeof(string)," WHERE `name` = '%s' LIMIT 1",PLAYER_DATA[playerid][data_NAME]);
		strcat(wind, string);
		mysql_function_query(dbHandle, wind, false, "", "");
	}
	return true;
}

 

 

Share this post


Link to post
Share on other sites
orward SaveAcc();
public SaveAcc()
{
 	foreach(new i: Player)
	{
		if(PlayerLogged[i] == false) continue;
		SaveAccount(i);
	}
	return 1;
}

@Данила я тебе могу дать от своего мода команду она у меня рабочая по пробуй может получится

cmd:saveacc(playerid, params[])
{
	if(PI[playerid][pAdmin] < ADM_GRAND) return 1;
	else if(AdminLogged[playerid] == false) return SendClientMessage(playerid, COLOR_GREY, YouAreNotLoggedInAsAdmin);
	SaveAcc();
	SendClientMessage(playerid, COLOR_GREY, ""cDA"Âû óñïåøíî ñîõðàíèëè âñå àêêàóíòû");
	return 1;
}

 

Edited by arno37

Share this post


Link to post
Share on other sites

@arno37 Псс парень, то что код у тебя в моде работает, не значит что и будет у него... Как могут переменные не совпасть и тд и тп

Share this post


Link to post
Share on other sites

@MuhammadPawn Так объясните мне. Как сделать сохранение аккаунтов после каждого действия игрока.

Share this post


Link to post
Share on other sites

@Данила после каждого действия игрока обновлять данные в базе / файлах 

для удобства можно создать какую-нибудь функцию, в которую передавать лишь ID игрока, название поля и новые данные. 

 

Share this post


Link to post
Share on other sites

@DEST А подробнее можно?

Share this post


Link to post
Share on other sites

Да проще уже сразу OnPlayerUpdate всунуть сохранения (вызывается при получение пакетов от игрока)

P.S: Эт рофл 

Если хочешь после покупки к примеру да сохранять акк, то придётся много в коде лазить и вставлять сохранения 

Share this post


Link to post
Share on other sites

@Данила что-то типо такой функции: 

Спойлер

stock UpdatePlayerField(playerid, const field[], const data[]) 
{
	new str[53 - 6 + MAX_PLAYER_NAME + MAX_PLAYER_DBFIELD + MAX_PLAYER_DBDATA + 1]; 
  	mysql_format(dbHandle, str, sizeof str, "UPDATE `accounts` SET `%s` = '%s' WHERE `name` = '%s'", field, data, PLAYER_DATA[playerid][data_NAME]); 
  	mysql_function_query(dbHandle, str, false, "", ""); 
  	return true; 
}

 

Соответственно, в начале мода объявите константы: 

Спойлер

const MAX_PLAYER_DBFIELD = 40; /*Максимальный размер названия поля в базе с игроками*/
const MAX_PLAYER_DBDATA = 40; /*Максимальный размер содержимого поля в базе с игроками*/

 

Использовать примерно так: 

Спойлер

/* код какого-то действия игрока */
UpdatePlayerField(playerid, "столбец", "Новое значение"); 

 

 

Share this post


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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • Radmiz
      By Radmiz
          if(pickupid == sadpick){         if(GetPVarInt(playerid,"Sadov") == 0) {             SetPVarInt(playerid,"Sadov", 1);             SetPlayerSkin(playerid, 73);             SetPlayerCheckpoint(playerid,2157.0464,-1707.6362,15.0859,3.0);               SendClientMessage(playerid,0x00ff39,"Âû óñòðîèëèñü íà ðàáîòó ñàäîâíèêà");               SendClientMessage(playerid,0xfeff00,"Çà 1 ïîñàæàíûé êóñò âàì áóäóò ïëàòèòü ïî 345$");         }         else {             PI[playerid][pCash] += GetPVarInt(playerid,"SadovM")*345;             SetPlayerSkin(playerid,PI[playerid][pSkin]);             ClearAnimations(playerid);             DeletePVar(playerid,"Sadov");             DeletePVar(playerid,"SadovM");             DeletePVar(playerid,"SadovW");             SendClientMessage(playerid,0xff0000,"Âû óâîëèëèñü ñ ðàáîòû ñàäîâíèêà");             DisablePlayerCheckpoint(playerid);  
      я хз что за иероглифы