server save
#1

Hello, so i want my server save automatically, at the momen i have to type /saveserver, but i want if i restart smth then it save automatically


//
And the second problem is the car engine.

Now i have to type /mootor, but i want if i press 2 then engine starts
Код:
COMMAND:mootor(playerid, params[])
{
	new string[128];
	if(PlayerLoggedIn[playerid] == true)
	{
		if(IsPlayerInAnyVehicle(playerid))
		{
			if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
			{
				new vehicleid = GetPlayerVehicleID(playerid);
				if(!IsABike(vehicleid))
				{
					if(Mootor[vehicleid] == 0)
					{
						if(IsAnyFactionVehicle(vehicleid))
						{
							if(IsFactionVehicle(vehicleid, KasutajaInfo[playerid][Grupeering]))
							{
								if(K2ivitabMootorit[playerid] == 0)
								{
									format(string, sizeof(string), "* %s kдivitab sхiduki mootori.", RPN(playerid));
									SendEmotion(playerid, string);
									SetTimerEx("StartVehicleEngine", 0, false, "i i", playerid, vehicleid);
									K2ivitabMootorit[playerid] = 1;
								}
								else SendClientMessage(playerid, COLOR_WHITE, "Palun oota ennem jдrgmise mootori kдivitamist");
							}
							else SendClientMessage(playerid, COLOR_RED, "See pole sinu masin!");
						}
						else if(IsAnyJobVehicle(vehicleid))
						{
							if(IsJobVehicle(vehicleid, KasutajaInfo[playerid][Tookoht]))
							{
								if(K2ivitabMootorit[playerid] == 0)
								{
									format(string, sizeof(string), "* %s kдivitab sхiduki mootori.", RPN(playerid));
									SendEmotion(playerid, string);
									SetTimerEx("StartVehicleEngine", 0, false, "i i", playerid, vehicleid);
									K2ivitabMootorit[playerid] = 1;
								}
								else SendClientMessage(playerid, COLOR_WHITE, "Palun oota ennem jдrgmise mootori kaivitamist");
							}
							else SendClientMessage(playerid, COLOR_RED, "See pole sinu masin!");
						}
						else if(!IsAnyFactionVehicle(vehicleid) && !IsAnyJobVehicle(vehicleid))
						{
					  		if(MasinaInfo[vehicleid-FraksiMasinaidKokku][MasinOlemas] == 1)
					  		{
						  		if(!strcmp(MasinaInfo[vehicleid-FraksiMasinaidKokku][Omanik], RPNU(playerid), true))
						  		{
						  			if(K2ivitabMootorit[playerid] == 0)
									{
										format(string, sizeof(string), "* %s kдivitab sхiduki mootor.", RPN(playerid));
										SendEmotion(playerid, string);
										SetTimerEx("StartVehicleEngine", 0, false, "i i", playerid, vehicleid);
										K2ivitabMootorit[playerid] = 1;
									}
									else SendClientMessage(playerid, COLOR_WHITE, "Palun oota ennem jдrgmise mootori kaivitamist");
						  		}
						  		/*else if(!strcmp(MasinaInfo[vehicleid-FraksiMasinaidKokku][VaruOmanik], RPNU(playerid), true))
						  		{
						  			if(K2ivitabMootorit[playerid] == 0)
									{
										format(string, sizeof(string), "* %s keerab oma masina varuvхtit ja ьritab kдivitada masina mootorit.", RPN(playerid));
										SendEmotion(playerid, string);
										SetTimerEx("StartVehicleEngine", 1500, false, "i i", playerid, vehicleid);
										K2ivitabMootorit[playerid] = 1;
									}
									else SendClientMessage(playerid, COLOR_GREY, "Palun oota ennem jдrgmise mootori kдivitamist!");
						  		}*/
				  				else SendClientMessage(playerid, COLOR_RED, "See pole sinu masin!");
					  		}
				  		}
					}
					else if(Mootor[vehicleid] == 1)
					{
						new engine, lights, alarm, doors, bonnet, boot, objective;
						GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
						Mootor[vehicleid] = 0;
						format(string, sizeof(string), "* %s suretab sхiduki mootori.", RPN(playerid));
						SendEmotion(playerid, string);
						SetVehicleParamsEx(vehicleid, false, lights, alarm, doors, bonnet, boot, objective);
					}
				}
				else SendClientMessage(playerid, COLOR_WHITE, "VIGA: Jalgratastel pole mootorit");
			}
			else SendClientMessage(playerid, COLOR_WHITE, "VIGA: Sa ei ole masina juht");
		}
		else SendClientMessage(playerid, COLOR_WHITE, "VIGA: Sa pead olema mingis masinas");
	}
	else SendClientMessage(playerid, COLOR_WHITE, "VIGA: Sa ei ole veel sisse loginud");
	return 1;
}
I really hope you understand me, beacause my englis suck..
Reply
#2

If you want your server to save automatically then use a timer that you start under OnGameModeInit.

For example:

pawn Код:
new GlobalSaveTimer;

public OnGameModeInit()
{
    GlobalSaveTimer = SetTimer("GlobalSave", 3600 * 1000, true); //3600 * 1000 = 1 hour in milliseconds
}

forward GlobalSave();
public GlobalSave()
{
    SaveServer(); //Or whatever your function is
    return 1;
}
FOr the second thing you need to use the call back OnPlayerKeyStateChange() which you can find information about here: https://sampwiki.blast.hk/wiki/OnPlayerKeyStateChange
Reply
#3

Yeah, my server save now, but i dont understand this second problem, sorry but im new
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)