Jump to content
  • 0

Question

Posted

Salut. Am postat destul de mult, dar problemele nu se termina. Cu noroc, am avut multe probleme la GM pe care le-am fixat, dar pe asta nu stiu. Am facut un OnPlayerKeyStateChange ca atunci cand apas pe tasta 2, sa se porneasca/opreasca motorul.

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		if(newkeys == KEY_LOOK_BEHIND)
		{
			new vID = GetPlayerVehicleID(playerid),
				tmp_engine,
				tmp_lights,
				tmp_alarm,
				tmp_doors,
				tmp_bonnet,
				tmp_boot,
				tmp_objective;
			GetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
			if(tmp_engine == 0)
			{
				tmp_engine = 1;
				new Float:x, Float:y, Float:z;
				new text[128];
				GetPlayerPos(playerid, x, y, z);
				format(text, sizeof(text), "%s a pornit motorul.", GetName(playerid));
				if(IsPlayerInRangeOfPoint(playerid, 15, x, y, z)) SendClientMessage(playerid, 0x4E87F2FF, text);
			}
			else
			{
				tmp_engine = 0;
				new Float:a, Float:b, Float:c;
				new string[128];
				GetPlayerPos(playerid, a, b, c);
				format(string, sizeof(string), "%s a oprit motorul.", GetName(playerid));
				if(IsPlayerInRangeOfPoint(playerid, 15, a, b, c)) SendClientMessage(playerid, 0x4E87F2FF, string);
			}
			SetVehicleParamsEx(vID, tmp_engine, tmp_lights, tmp_alarm, tmp_doors, tmp_bonnet, tmp_boot, tmp_objective);
		}
	}
	return 1;
}

Sunt incepator, asa am reusit sa fac.

In joc, cand intru intr-o masina si apas pe 2, se opreste motorul si trebuie sa apas din nou pe 2 ca sa il pornesc.

Masina are motorul oprit din start, nu se aude zgomot de la motor si nu merge, de ce imi opreste motorul atunci?

eroare.PNG.545285b6df712012059bc5613ed1ffff.PNG

 

 

8 answers to this question

Recommended Posts

  • 0
Posted

pune ca mașina când dai f sau enter în ea sa se pornească automat, + alea sunt ca actiunile /me si /do, apesi 2 doar fac ce zici nu ca se si intampla 

Ares4  =(

 

 

  • 0
Posted (edited)
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{	
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		if(newkeys & KEY_LOOK_BEHIND)
		{
			return cmd_engine(playerid, "a"); // sau cum ai comanda de pornit/oprit motorul
		}
	}

	return 1;
}

 

Edited by Umbra
  • 0
Posted
12 hours ago, Umbra said:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{	
	if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		if(newkeys & KEY_LOOK_BEHIND)
		{
			return cmd_engine(playerid, "a"); // sau cum ai comanda de pornit/oprit motorul
		}
	}

	return 1;
}

 

Salut. Am incercat sa fac asta dar acum orice apas imi scrie "FDH_ a pornit motorul." si motorul nu se porneste.

  • 0
Posted
13 hours ago, Kiran said:

pune ca mașina când dai f sau enter în ea sa se pornească automat, + alea sunt ca actiunile /me si /do, apesi 2 doar fac ce zici nu ca se si intampla 

Salut. Am incercat si sa pun ca atunci cand intra in masina sa se porneasca motorul, dar masina incepe sa zboare(intr-un fel) ca si cum ar avea noclip orice fac dupa aceea.

  • 0
Posted (edited)

Imi place ca doresti sa porneasca motorul dar nu ii spui niciodata sa il porneasca

SetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective)

Nu e de ajuns  sa ii iei conditia si sa zici ca tmp_engine = 1, trebuie sa ii si transmiti ca e 1

Edited by Banditul
  • 0
Posted
CMD:engine(playerid, params[])
{
	if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) 
		return SCM(playerid, -1, "Eroare: Nu conduci o masina!");
	new vID = GetPlayerVehicleID(playerid),
		engine,
		lights,
		alarm,
		doors,
		bonnet,
		boot,
		objective;
	GetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
	if(engine == 1)
	{
		engine = 0;
	}
	else
	{
		engine = 1;
	}
	SetVehicleParamsEx(vID, engine, lights, alarm, doors, bonnet, boot, objective);
	return 1;
}

Am facut comanda din nou, si merge perfect, dar daca adaug orice la partile unde schimba engine-ul in 0, respectiv 1, nu mai merge. Cum as putea sa adaug text atunci cand pornesc motorul sa le apara la cei din jur ca l-am pornit.

  • 0
Posted
22 hours ago, Banditul said:

Mesajul il adaugi in if-u in care verifici engine, respectiv else-u lui

Prima data am facut absolut totul legat de mesaj in "if", si m-am enervat ca nu merge, dar am realizat ca daca fac string-ul in afara if-ului si dau doar SendClientMessage atunci merge. Acum merge si daca apas pe 2. Ms Banditule, mereu esti aici cand am nevoie de tine =]]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.