[Ajuda] cуdigo n funciona
#1

Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
		if(newkeys == 65536 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // Y
		{
			GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
			if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET) {
				SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
				SendClientMessage(playerid, Branco, "Vocк abriu a mala do carro !");
			}
			else
			{
				SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective);
				SendClientMessage(playerid, Cinza, "Vocк fechou a mala do carro !");
			}
		}

	}

	new t[80];
	format(t, sizeof(t)," Tecla: %d", newkeys);
	SendClientMessage(playerid, -1, t);
	return true;
}
Fiz esse cуdigo pra abrir a mala do carro apertando Y mais n funciona.

@edit
Reply
#2

poderia me dizer aonde vocк pega o id do carro e insere na variavel "id" que estб usando para identificar o carro ?, creio que seu erro estб ai
Reply
#3

Tente trocar
Code:
if(newkeys == 65536 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
Por:
Code:
if(newkeys & KEY_YES && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
Reply
#4

й uma variбvel global e eu to usando new id = GetPlayerVehicleID(playerid); dentro da public do KeyStage
Reply
#5

Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new id = GetPlayerVehicleID(playerid);

	if(newkeys == 131072 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)   // Verifica se o jogador pressionou o N
	{
		// A gente remove o IsPlayerAnyVehicle pois sempre que ele N espaзo irб aparecer a mensagem.
		GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
		if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET) {
			SetVehicleParamsEx(id, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
			SendClientMessage(playerid, Branco, "Vocк ligou o seu veнculo!");
		}
		else
		{
			SetVehicleParamsEx(id, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
			SendClientMessage(playerid, Cinza, "Vocк desligou o seu veнculo!");
		}
// ------------------------------------------------------------------------------- >>
// PRУXIMO ITEM
//------------------------------------------------------------------------------
		if(newkeys & KEY_YES && GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // Y
		{
			GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
			if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET) {
				SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
				SendClientMessage(playerid, Branco, "Vocк abriu a mala do carro !");
			}
			else
			{
				SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective);
				SendClientMessage(playerid, Cinza, "Vocк fechou a mala do carro !");
			}
		}
// ------------------------------------------------------------------------------- >>
// PRУXIMO ITEM
//------------------------------------------------------------------------------
	}
/*
	new t[80];
	format(t, sizeof(t)," Tecla: %d", newkeys);
	SendClientMessage(playerid, -1, t);
*/
	return true;
}
public completa.

nгo ta funcionando Ermanhaut

sinceramente pra mim ta tudo certo, o de desligar/ligar com N ta funcionando perfeitamente
serб que tem algo errado aqui
Code:
				SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
?
Reply
#6

Code:
if(newkeys == 131072 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
Este mйtodo de verificar teclas й incorreto. Ao invйs de == utilize &.
Para mais informaзхes, veja a pбgina da Wiki

Eu arrumei seu cуdigo, veja se funciona:
Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	new id = GetPlayerVehicleID(playerid);

	if(newkeys & KEY_NO && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
		if(engine == VEHICLE_PARAMS_OFF || engine == VEHICLE_PARAMS_UNSET) {
			SetVehicleParamsEx(id, VEHICLE_PARAMS_ON, lights, alarm, doors, bonnet, boot, objective);
			SendClientMessage(playerid, Branco, "Vocк ligou o seu veнculo!");
		}
		else
		{
			SetVehicleParamsEx(id, VEHICLE_PARAMS_OFF, lights, alarm, doors, bonnet, boot, objective);
			SendClientMessage(playerid, Cinza, "Vocк desligou o seu veнculo!");
		}
	}

	if(newkeys & KEY_YES && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
	{
		GetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, boot, objective);
		if(boot == VEHICLE_PARAMS_OFF || boot == VEHICLE_PARAMS_UNSET) {
			SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_ON, objective);
			SendClientMessage(playerid, Branco, "Vocк abriu a mala do carro !");
		}
		else
		{
			SetVehicleParamsEx(id, engine, lights, alarm, doors, bonnet, VEHICLE_PARAMS_OFF, objective);
			SendClientMessage(playerid, Cinza, "Vocк fechou a mala do carro !");
		}
	}
/*
	new t[80];
	format(t, sizeof(t)," Tecla: %d", newkeys);
	SendClientMessage(playerid, -1, t);
*/
	return true;
}
Reply
#7

@edit

funcionou aqui obrigado !

qual o parвmetro do farol ?
Reply
#8

Quote:
Originally Posted by dimy
View Post
@edit

funcionou aqui obrigado !

qual o parвmetro do farol ?
lights
Reply
#9

ok obrigado + REP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)