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



12 posts in this topic

Я нашёл систему пробега очень сырную и доделал её и пробег идёт,в БД сохраняет, а после рестарта сервера садишься в машину и пробег снова 0, помогите, чтот тут не так сделал

Сис-ма пробега

 

new Float:Probeg[MAX_VEHICLES] = 0.0;
new ProbegVeh[MAX_VEHICLES];
forward ToProbeg(playerid);

 Название в БД Cprobeg

 

SetTimer("ToProbeg",1000, true); таймер обновления паблика

сам паблик

public ToProbeg(playerid)
{
    new string[256];
    if(!IsPlayerInAnyVehicle(playerid)) return 1;
    new Float:sp = GetVehicleSpeed(GetPlayerVehicleID(playerid));
    new Float:l = (sp/2)/1000;
    Probeg[GetPlayerVehicleID(playerid)] += l;
    ProbegVeh[GetPlayerVehicleID(playerid)] = ProbegVeh[GetPVarInt(playerid, "PlayerCar")];
    GameTextForPlayer(playerid,string, 1500, 3);
    return 1;
}

 

ну и в carpass отображение пробега

 

SendMes(params[0], COLOR_ORANGE, "[ {FFFFFF}пробег: {63BD4E}%i KM]",ProbegVeh[GetPlayerVehicleID(playerid )]);

 

Share this post


Link to post
Share on other sites

Я там поправил и пробег идёт, сохраняет,после рестарта всё ещё в БД есть цифра пробега, но как сажусь в машину становится 0 и заново начинаешь накатывать

Share this post


Link to post
Share on other sites

@MuRzok а код загрузки из БД есть? 

Share this post


Link to post
Share on other sites

@DEST 

это в stock SaveAccount(playerid) 

PlayerInfo[playerid][Cprobeg] = ProbegVeh[GetPlayerVehicleID(playerid)];

внизу стока 
	format(src,sizeof(src),"Cprobeg=%i,",PlayerInfo[playerid][Cprobeg]);
	strcat(query,src,sizeof(query));
stock SaveVehicle(playerid)
{
if(GetPlayerHouse(playerid) || GetPlayerHotel(playerid) )
{
PlayerInfo[playerid][cFuel] = Fuel[GetPVarInt(playerid, "PlayerCar")];
PlayerInfo[playerid][Cprobeg] = ProbegVeh[GetPlayerVehicleID(playerid)];
}
return true;
}

 

Share this post


Link to post
Share on other sites

@MuRzok это сохранение, а нужна еще и загрузка. Найдите место в моде, где происходит загрузка аккаунта и сделайте аналогично для пробега. 

Share this post


Link to post
Share on other sites

@DEST типо вот так?

 

stock LoadAccount(playerid)
{
	new string[64];
	new playername[32];
	GetPlayerName(playerid,playername,32);
	format(query,256, "SELECT * FROM "TABLE_ACCOUNT" WHERE name = '%s'  LIMIT 1",playername);
	mysql_query(query);
	mysql_store_result();
	if(mysql_fetch_row(query) == 1)
	{
		sscanf(query, "p<|>is[32]s[32]s[16]is[32]s[64]iiiis[16]iiiiiiis[16]iiiiis[16]s[20]iiiifiiiiis[32]s[32]iiiiiiiiiiiiiiiiiiiifiiiiiiiiiiiiiiiiis[128]iiiiiiiiiiiiiiiiiiis[16]iiiiiiiiiiiiiii",
		PlayerInfo[playerid][pID],
		PlayerInfo[playerid][pSendername],
		PlayerInfo[playerid][pPassword],
		PlayerInfo[playerid][pIP],
		PlayerInfo[playerid][pAdmin],
		PlayerInfo[playerid][pIpPassword],
		PlayerInfo[playerid][pMail],
		PlayerInfo[playerid][pLevel],
		PlayerInfo[playerid][pCash],
		PlayerInfo[playerid][pBank],
		PlayerInfo[playerid][pExp],
		PlayerInfo[playerid][pRegData],
		PlayerInfo[playerid][pLeader],
		PlayerInfo[playerid][pMember],
		PlayerInfo[playerid][pRank],
		PlayerInfo[playerid][pWarn],
		PlayerInfo[playerid][pSex],
		PlayerInfo[playerid][pModel],
		PlayerInfo[playerid][pChar],
		PlayerInfo[playerid][pLics],
		PlayerInfo[playerid][pGunSkill][6],
		PlayerInfo[playerid][pMuted],
		PlayerInfo[playerid][pPick],
		PlayerInfo[playerid][pCheckTime],
		PlayerInfo[playerid][pNews],
		PlayerInfo[playerid][pPhones],
		PlayerInfo[playerid][pTexts],
		PlayerInfo[playerid][pJail],
		PlayerInfo[playerid][pJailTime],
		PlayerInfo[playerid][pWanted],
		PlayerInfo[playerid][pWantedTime],
		PlayerInfo[playerid][pHeal],
		PlayerInfo[playerid][pDrugs],
		PlayerInfo[playerid][pMats],
		PlayerInfo[playerid][pCrimes],
		PlayerInfo[playerid][pJob],
		PlayerInfo[playerid][pMarried],
		PlayerInfo[playerid][pWhoMarried],
		PlayerInfo[playerid][pReferal],
		PlayerInfo[playerid][pRefMoney],
		PlayerInfo[playerid][pPayCheck],
		PlayerInfo[playerid][pFish],
		PlayerInfo[playerid][pLottery],
		PlayerInfo[playerid][pVIP],
		PlayerInfo[playerid][pTime],
		PlayerInfo[playerid][pFightStyle],
		PlayerInfo[playerid][pCredits],
		PlayerInfo[playerid][pTotalCredits],
		PlayerInfo[playerid][pSkin1],
		PlayerInfo[playerid][pSkin2],
		PlayerInfo[playerid][pSkin3],
		PlayerInfo[playerid][pSpawnChange],
		PlayerInfo[playerid][pGunSkill][0],
		PlayerInfo[playerid][pGunSkill][1],
		PlayerInfo[playerid][pGunSkill][2],
		PlayerInfo[playerid][pGunSkill][3],
		PlayerInfo[playerid][pGunSkill][4],
		PlayerInfo[playerid][pGunSkill][5],
		PlayerInfo[playerid][pSatiety],
		PlayerInfo[playerid][pHealthS],
		PlayerInfo[playerid][pSportEXP],
		PlayerInfo[playerid][pOnline],
		PlayerInfo[playerid][pZakon],
		PlayerInfo[playerid][ProverkaIP],
		PlayerInfo[playerid][pHospital],
		PlayerInfo[playerid][pWatch],
		PlayerInfo[playerid][pCiggare],
		PlayerInfo[playerid][pMask],
		PlayerInfo[playerid][pPhoneBalance],
		PlayerInfo[playerid][pTruckSkill],
		PlayerInfo[playerid][cModel],
		PlayerInfo[playerid][cClass],
		PlayerInfo[playerid][cFuel],
		PlayerInfo[playerid][cColor][0],
		PlayerInfo[playerid][cColor][1],
		PlayerInfo[playerid][cLock],
		PlayerInfo[playerid][cCost],
		PlayerInfo[playerid][cVehcom],
		PlayerInfo[playerid][cPaintjob],
		PlayerInfo[playerid][pDostup],
		PlayerInfo[playerid][pHelper],
		PlayerInfo[playerid][pMutedHelper],
		PlayerInfo[playerid][pMuteTimeHelper],
		PlayerInfo[playerid][pWork],
		PlayerInfo[playerid][pPsp],
		PlayerInfo[playerid][pTehOsmtr],
		PlayerInfo[playerid][pAvia],
		PlayerInfo[playerid][cColorA][0],
		PlayerInfo[playerid][cColorA][1],
		PlayerInfo[playerid][aCost],
		PlayerInfo[playerid][pUniv],
		PlayerInfo[playerid][pUnivDate],
		PlayerInfo[playerid][pSkok],
		PlayerInfo[playerid][pDiplom][0],
		PlayerInfo[playerid][pDiplom][1],
		PlayerInfo[playerid][pDiplom][2],
		PlayerInfo[playerid][pDiplom][3],
		PlayerInfo[playerid][pIpReg],
		PlayerInfo[playerid][pFamily],
		PlayerInfo[playerid][pHair],
		PlayerInfo[playerid][pNumberPass],
		PlayerInfo[playerid][pSchet],
		PlayerInfo[playerid][pBut],
		PlayerInfo[playerid][pSing],
		PlayerInfo[playerid][pOtm],
		PlayerInfo[playerid][pGen],
		PlayerInfo[playerid][pFuel],
		PlayerInfo[playerid][pApt],
		PlayerInfo[playerid][pWarnDate],
		PlayerInfo[playerid][pWarnSkok],
		PlayerInfo[playerid][pDate1],
		PlayerInfo[playerid][pDate2],
		PlayerInfo[playerid][Cprobeg]);
		mysql_free_result();
		sscanf(PlayerInfo[playerid][cVehcom], "p<,>a<i>[14]",PlayerInfo[playerid][cVehcoms]);
		PlayerLogged[playerid] = true;
		TimeLogged[playerid] = -1;
		if(PlayerInfo[playerid][pHair] > 0) parik[playerid] = 1;
		if(PlayerInfo[playerid][pWarn] > 0)
		{
			getdate(years, months, days);
			if(PlayerInfo[playerid][pWarnDate] != days)
			{
				if(PlayerInfo[playerid][pWarnSkok] > 1)
				{
	                PlayerInfo[playerid][pWarnSkok]--;
	                SendMes(playerid,CWHITE,"Предупреждение снимается через {63BD4E}%i{FFFFFF} дней",PlayerInfo[playerid][pWarnSkok]);
	                PlayerInfo[playerid][pWarnDate] = days;
				}
				else
				{
				    if(PlayerInfo[playerid][pWarn] == 1)
				    {
					    PlayerInfo[playerid][pWarnSkok] = 0;
					    PlayerInfo[playerid][pWarnDate] = 0;
					    PlayerInfo[playerid][pWarn] = 0;
					    SendClientMessage(playerid,COLOR_ORANGE,"Предупреждение снято");
				    }
				    else
				    {
					    PlayerInfo[playerid][pWarnSkok] = 21;
					    PlayerInfo[playerid][pWarnDate] = days;
					    PlayerInfo[playerid][pWarn]--;
					    SendMes(playerid,CWHITE,"Одно предупреждение снято. Осталось: {63BD4E}%i",PlayerInfo[playerid][pWarn]);
				    }
				}
			}
		}
	   	TextDrawShowForPlayer(playerid,Textdraw0);
	   	TextDrawShowForPlayer(playerid,Textdraw1);
		sscanf(PlayerInfo[playerid][pTexts], "p<,>a<i>[3]", PlayerInfo[playerid][pText]);
		sscanf(PlayerInfo[playerid][pPhones], "p<,>a<i>[3]", PlayerInfo[playerid][pPhone]);
		sscanf(PlayerInfo[playerid][pLics], "p<,>a<i>[5]",PlayerInfo[playerid][pLic]);
		SendClientMessage(playerid, COLOR_ORANGE, "{FFFAFA}Добро пожаловать в штат{63BD4E} Ruby.");
	//	if(PlayerInfo[playerid][pAdmin] > 0) AdminLogged[playerid] = true, SendClientMessage(playerid, COLOR_WHITE,"Возможности administratora активированы, приятной игры!");
		if(PlayerInfo[playerid][pAdmin] > 0) SendMes(playerid, COLOR_WHITE,"{63BD4E}Вы вошли как администратор: %d уровня",PlayerInfo[playerid][pAdmin]);
		if(PlayerInfo[playerid][pAdmin] > 0) SendMes(playerid, COLOR_WHITE,"{63BD4E}чтобы выйти на дежурство введите /aduty",PlayerInfo[playerid]);
		if(PlayerInfo[playerid][pVIP] == true) SendClientMessage(playerid, COLOR_WHITE, "{63BD4E}Возможности VIP аккаунта активированы, приятной игры!");
		format(string, 64, "~w~Welcome ~n~~b~   %s", PlayerInfo[playerid][pSendername]);
		GameTextForPlayer(playerid, string, 3500, 1);
		PlayerPlaySound(playerid, 30800, 0.0, 0.0, 0.0);
		if (PlayerInfo[playerid][pText][0] == 1)
		{
			SendClientMessage(playerid, COLOR_ORANGE, "[КВИТАНЦИЯ] Вы забыли оплатить за кварплату, ваш дом продали!");
			SendClientMessage(playerid, COLOR_ORANGE, "[КВИТАНЦИЯ] На ваш банковский счет возвращена стоимость дома по гос-ву");
			PlayerInfo[playerid][pText][0] = 0;
			format(PlayerInfo[playerid][pTexts], 20,  "%i, %i, %i", PlayerInfo[playerid][pText][0], PlayerInfo[playerid][pText][1], PlayerInfo[playerid][pText][2]);
			format(query, 256, "UPDATE "TABLE_ACCOUNT" SET text = '%s' WHERE name = '%s'", PlayerInfo[playerid][pTexts], PlayerInfo[playerid][pSendername]);
			mysql_query(query);
		}
		if(PlayerInfo[playerid][pText][1] == 1)
		{
			SendClientMessage(playerid, COLOR_ORANGE,"[НАЛОГОВАЯ СЛУЖБА] Ваш бизнес закрыли в связи с нехваткой ресурсов");
			SendClientMessage(playerid, COLOR_ORANGE,"[НАЛОГОВАЯ СЛУЖБА] Бюджет бизнеса зачислен на ваш банковский счет");
			PlayerInfo[playerid][pText][1] = 0;
			format(PlayerInfo[playerid][pTexts], 20, "%i, %i, %i", PlayerInfo[playerid][pText][0], PlayerInfo[playerid][pText][1], PlayerInfo[playerid][pText][2]);
			format(query, 256, "UPDATE "TABLE_ACCOUNT" SET text = '%s' WHERE name = '%s'", PlayerInfo[playerid][pTexts], PlayerInfo[playerid][pSendername]);
			mysql_query(query);
		}
		if(PlayerInfo[playerid][pText][2] == 1)
		{
			new p = PlayerInfo[playerid][pRefMoney] / 100000;
			for(new i = 1; i <= p; i++)
			{
				GiveMoney(playerid, 100000);
				PlayerInfo[playerid][pRefMoney] -= 100000;
			}
			PlayerInfo[playerid][pText][2] = 0;
			format(PlayerInfo[playerid][pTexts], 20, "%i, %i, %i", PlayerInfo[playerid][pText][0], PlayerInfo[playerid][pText][1], PlayerInfo[playerid][pText][2]);
			format(query, 256, "UPDATE "TABLE_ACCOUNT" SET text = '%s', refmoney WHERE name = '%s'", PlayerInfo[playerid][pTexts], PlayerInfo[playerid][pRefMoney], PlayerInfo[playerid][pSendername]);
			mysql_query(query);
		}
        tp__ignore_tick[playerid] = GetTickCount()+TP__IGNORE_TIME;
		SetSpawnInfo(playerid, 255, PlayerInfo[playerid][pModel], 0, 0, 0, 1.0, -1, -1, -1, -1, -1, -1);
		SpawnPlayer(playerid);
		new str123[12];
		GetPlayerIp(playerid,str123,12);
		if(PlayerInfo[playerid][pLeader] > 0)
		{
		    if(!strcmp(str123,PlayerInfo[playerid][pIpReg], true))
		    {
			    new string23[144];
				format(string23,sizeof(string23),"{63BD4E}<A> Лидер %s[%d] зашёл. IP: %s | REG IP: %s",sendername(playerid),playerid,str123,PlayerInfo[playerid][pIpReg]);
				SendAdminMessage(COLOR_LIGHTRED,string23);
		    }
		}
		format(string, 64, "%s зашел в аккаунт с ip: %s",PlayerInfo[playerid][pSendername],str123);
		Log("LogInfo",string);
		DeletePVar(playerid,"Acc");
		SetPlayerInt(PlayerInfo[playerid][pSendername], "online", 1);
	}
	return true;
}

если да, то есть и он сохраняет его, но после рестарта сервера в машину садишься и он в БД снова 0 ставит

Share this post


Link to post
Share on other sites

TS Posted (edited) · Report post

@DEST Решил проблему одну и есть другая, я в stock LoadMyCar1(playerid) и stock LoadMyCar(playerid) добавил 

 

ProbegVeh[carid] = PlayerInfo[playerid][Cprobeg];

Если получается в БД вписать число, то оно будет показывать пока не поедешь/заведёшь машину

Edited by MuRzok

Share this post


Link to post
Share on other sites

TS Posted (edited) · Report post

@MuRzok Добавлю,когда машина заводится пробег снова улетает в 0 и это если в БД поставить после рестарта число
if(newkeys & KEY_SUBMISSION)//звести двигатель KEY_ACTION)-Lctrl
    {
        if(PlayerLogged[playerid] == 0) return true;
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return true;
        if(GetPVarInt(playerid, "InShop") > 0 || InShop[playerid] > 0) return true;
        new cars =0,temp = GetVehicleModel( GetPlayerVehicleID( playerid ) );
        for(new i; i != sizeof( BE_Bad_Vehs ); i++ )
        {
            if( temp == BE_Bad_Vehs[ i ] ) cars++;
        }
        if(Bonnet[GetPlayerVehicleID(playerid)] == true) return SendClientMessage(playerid, CGREY, "Дождитесь, пока автомеханик отремонтирует транспорт!");
        if(Fuel[GetPlayerVehicleID(playerid)] <= 0 && cars == 0) return SendClientMessage(playerid, CGREY, CarHasNoFuel);
        if(Engine[GetPlayerVehicleID(playerid)] == false)
        {
            GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_ON,VEHICLE_PARAMS_ON,alarm,doors,bonnet,boot,objective);
            Engine[GetPlayerVehicleID(playerid)] = true;
            Lights[GetPlayerVehicleID(playerid)] = true;
        }
        else
        {
            GetVehicleParamsEx(GetPlayerVehicleID(playerid),engine,lights,alarm,doors,bonnet,boot,objective);
            SetVehicleParamsEx(GetPlayerVehicleID(playerid),VEHICLE_PARAMS_OFF,VEHICLE_PARAMS_OFF,alarm,doors,bonnet,boot,objective);
            Engine[GetPlayerVehicleID(playerid)] = false;
            Lights[GetPlayerVehicleID(playerid)] = false;
        }
        return true;

Edited by MuRzok

Share this post


Link to post
Share on other sites

@MuRzok сохраняется и загружается у вас переменная 

11 часов назад, MuRzok сказал:

PlayerInfo[playerid][Cprobeg]);

а отображается в carpass

В 19.03.2020 в 04:27, MuRzok сказал:

ProbegVeh[GetPlayerVehicleID(playerid )]

В коде я не увидел между ними связи.

Share this post


Link to post
Share on other sites

@DEST а как их связать? у меня вот есть 
 

stock SaveAccount(playerid)
{
	if(PlayerLogged[playerid] == 0) return 1;
	if(PlayerInfo[playerid][pMask] == 2) PlayerInfo[playerid][pMask] = 0;
	if(GetPVarInt(playerid,"PlayerCar") > 0) PlayerInfo[playerid][pFuel] = Fuel[GetPVarInt(playerid,"PlayerCar")];
	PlayerInfo[playerid][Cprobeg] = ProbegVeh[GetPlayerVehicleID(playerid)];

или
 

stock SaveVehicle(playerid)
{
if(GetPlayerHouse(playerid) || GetPlayerHotel(playerid) )
{
PlayerInfo[playerid][cFuel] = Fuel[GetPVarInt(playerid, "PlayerCar")];
PlayerInfo[playerid][Cprobeg] = ProbegVeh[GetPlayerVehicleID(playerid)];
}
return true;
}

Что если я сделать вместо 

public ToProbeg(playerid)
{
    new string[256];
    if(!IsPlayerInAnyVehicle(playerid)) return 1;
    new Float:sp = GetVehicleSpeed(GetPlayerVehicleID(playerid));
    new Float:l = (sp/2)/1000;
    Probeg[GetPlayerVehicleID(playerid)] += l;
    ProbegVeh[GetPlayerVehicleID(playerid)] = floatround(Probeg[GetPlayerVehicleID(playerid)]);
    GameTextForPlayer(playerid,string, 1500, 3);
    return 1;
}

Так
 
public ToProbeg(playerid)
{
    new string[256];
    if(!IsPlayerInAnyVehicle(playerid)) return 1;
    new Float:sp = GetVehicleSpeed(GetPlayerVehicleID(playerid));
    new Float:l = (sp/2)/1000;
    Probeg[GetPlayerVehicleID(playerid)] += l;
    ProbegVeh[GetPlayerVehicleID(playerid)] = PlayerInfo[playerid][Cprobeg];
    GameTextForPlayer(playerid,string, 1500, 3);
    return 1;
}

Тип я нашёл сис-му пробега кривую,настроил и начал делать для БД, но как-бы для меня делать такое всё равно, что для ребёнка который родился час назад говорить свободно)
 

Share this post


Link to post
Share on other sites

@MuRzok попробуйте, может быть это сработает. 

Share this post


Link to post
Share on other sites

@DEST фигня,он тогда вообще не идёт, или же там просто с 0 сразу 199846721438 и не сохраняет)

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

    • E)/(IK
      By E)/(IK
      В моде Only RolePlay можно создать всего 612 машин,для сервера мне надо  700. Так как я буду добавлять в игру их. Просто нужно мне узнать,как сделать так,чтобы больше машин можно было спавинть. После написания команды /veh 613 0 0 пишет введите /veh [ID Машины] [цвет1] [цвет2] а если вводить меньше то все работает.
    • NNN
      By NNN
      Поставил эту http://pawno-rus.ru/topic/1034-sistema-reporta/ систему репорта со всеми доработками, в компиляторе высвечиваются эти ошибки:
      loose indentation error 017: undefined symbol "AddMessage" warning 215: expression has no effect error 001: expected token: ";", but found "]" error 029: invalid expression, assumed zero fatal error 107: too many error messages on one line первое предупреждение из за корявости скрипта (loose indentation) а вот с остальными не знаю)