Sera un bucle mald1to?
#1

Saludos a todos, he estado retomando pawno y al querer crear un trackcar por medio de matricula, ahora esta funcionando, el problema es que no muestra el nombre del propietario, que ya he colocado dentro del bucle for, pero no lo muestra en el resultado, gracias de antemano!

Aqui el codido:

Код:
   if(dialogid == DIALOG_ENCONTRAR_VEHICULO)
	{
        if(response)
        {
	        if(strlen(inputtext) > 0)
			{
			    new propietario[MAX_PLAYER_NAME], bool:ok=false, string[160], Float:ePos[3];
				for(new v = 0; v < sizeof(cInfo); v++)
	  		    {
	  		        if(!strlen(cInfo[v][matricula]))
	  		            continue;
	  		    
    				if(!strcmp(cInfo[v][matricula], inputtext, false)) 
					{
					    GetVehiclePos(cInfo[v][id_x], ePos[0], ePos[1], ePos[2]);
					    GetPlayerName(cInfo[v][ownerID], propietario, MAX_PLAYER_NAME);
					    ok = true;
					    break;
					}
					else
					{
					    ok = false;
					}
				}
				
				if(ok == false)
				{
					return Message(playerid, -1, "No se encontraron resultados.");
				}
				else
				{
					format(string, sizeof(string), "Panel de Localizacion: Vehiculo encontrado | Propietario: %s | Matricula: %s", propietario, inputtext);
					Message(playerid, -1, string);
					Message(playerid, COLOR_YELLOW, "Hemos enviado las coordenadas, dirigase al punto indicado.");
					printf("Encontrado - Pos: %f,%f,%f",ePos[0], ePos[1], ePos[2]);
				}
		  	}
			else
			{
			    return 0;
			}
		}
		else
		{
		    Message(playerid, -1, "Panel de localizacion cerrado.");
		}
		printf("$$$$$ --> Final Dialog ");
	}
	return 0;
Reply
#2

EDITO: Para decirte que no estб bien cambiar el cуdigo de tu post porque me hiciste perder el tiempo y ahora no sirve lo que me llevo un tiempo analizar. Seamos serios. Esta era mi respuesta


Asн a primera vista creo que el problema estб en PlayerName(GetOwnerByMatricula(inputtext))

Te aconsejo que no concatenes funciones como argumentos de un "format" y procures usar unicamente variables. Resulta un script mбs claro y mбs facil hallar los errores. No sabemos como operan tus funciones; Message, GetCar3DZone y PlayerName.

Yo probarнa cambiando esa parte del codigo asн

Код:
if(Encontrado == true)
{
	new id = GetOwnerByMatricula(inputtext), name[MAX_PLAYER_NAME];
	GetPlayerName(id,name,MAX_PLAYER_NAME);
	format(string, sizeof(string), "Panel de Localizacion: Vehiculo encontrado | Propietario: %s | Matricula: %s | Lugar: %s", name, inputtext, lugar);
	Message(playerid, -1, string);
	Message(playerid, COLOR_YELLOW, "Hemos enviado las coordenadas, dirigase al punto indicado.");
}
Reply
#3

Buenas alexus gracias por responder, habнa cambiado un poco el cуdigo, en la parte que ya esta verificado el ok, deberнa imprimir el nombre completo, solo recibo nada.. asн tal cual

Код:
 if(dialogid == DIALOG_ENCONTRAR_VEHICULO)
	{
        if(response)
        {
	        if(strlen(inputtext) > 0)
			{
				new bool:ok = false,
				string[160],
				Float:ePos[3];
				
				
				for(new x; x < sizeof(cInfo); x++)
				{
				    if(strlen(cInfo[x][matricula]) > 0 && cInfo[x][id_x] == GetVehicleByMatricula(inputtext))
				    {
						ok = true;
					 	GetVehiclePos(cInfo[x][id_x], ePos[0], ePos[1], ePos[2]);
						break;
					}
				}
				if(ok == true)
				{
   					new id = GetOwnerByMatricula(inputtext), name[MAX_PLAYER_NAME];
                    GetPlayerName(id, name, MAX_PLAYER_NAME);
					format(string, sizeof(string), "Panel de Localizacion: Vehiculo encontrado | Propietario: %s | Matricula: %s", name, inputtext);
					Message(playerid, -1, string);
					Message(playerid, COLOR_YELLOW, "Hemos enviado las coordenadas, dirigase al punto indicado.");
					printf("DEBUG OUTFOR: Encontrado - Pos: %f,%f,%f, %s",ePos[0], ePos[1], ePos[2], name);
				}
				else
				{
				    Message(playerid, -1, "No man..");
				}
		  	}
			else
			{
			    return 0;
			}
		}
		else
		{
		    Message(playerid, -1, "Panel de localizacion cerrado.");
		}
		printf("$$$$$ --> Final Dialog ");
	}
Por que tanto problema con las variables Get dentro del bucle? >.<

Estas son las funciones extras

Код:
stock GetVehicleByMatricula(ma[])
{
	for(new i=0; i < sizeof(cInfo); i++)
 	{
 		if(cInfo[i][id_x] != INVALID_VEHICLE_ID)
		{
  			if(strcmp(ma,cInfo[i][matricula], true) == 0)
  			{
    			return cInfo[i][id_x];
			}
        }
    }
	return INVALID_VEHICLE_ID;
}


stock GetOwnerByMatricula(ma[])
{
	for(new i=0; i < sizeof(cInfo); i++)
 	{
 		if(cInfo[i][id_x] != INVALID_PLAYER_ID)
		{
  			if(strcmp(ma,cInfo[i][matricula], true) == 0)
  			{
    			return cInfo[i][ownerID];
			}
        }
    }
	return INVALID_PLAYER_ID;
}
Reply
#4

Es que he probado tantas maneras.. que me tiene loco, 3 horas sin pegar un ojo con eso xD
Reply
#5

Creo que te has complicado la vida un poco. Si, como supongo, tu variable cInfo contiene los datos de los vehiculos, no es necesario que emplees las funciones GetVehicleByMatricula y GetOwnerByMatricula.

Me he permitido depurar y simplificar el codigo. Prueba de esta manera:
Код:
if(dialogid == DIALOG_ENCONTRAR_VEHICULO)
{
	if(response && strlen(inputtext) > 0)
	{
		for(new i; i < sizeof(cInfo); i++)
		{
			if( cInfo[i][matricula] == inputtext && cInfo[i][id_x] != INVALID_VEHICLE_ID)
			{
				new string[160], Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME];
				GetPlayerName(cInfo[i][ownerID], name, MAX_PLAYER_NAME);
				GetVehiclePos(cInfo[i][id_x], x, y, z);
				format(string, sizeof(string), "Panel de Localizacion: Vehiculo encontrado | Propietario: %s | Matricula: %s", name, inputtext);
				SendClientMessage(playerid, -1, string);
				SendClientMessage(playerid, COLOR_YELLOW, "Hemos enviado las coordenadas, dirigase al punto indicado.");
				printf("DEBUG OUTFOR: Encontrado - Pos: %f,%f,%f, %s", x, y, z, name);
				return 1;
			}
		}
		SendClientMessage(playerid, -1, "No se ha encontrado ningun vehiculo...");
	}
	else SendClientMessage(playerid, -1, "Panel de localizacion cerrado.");
	return 1;
}
Reply
#6

Resuelto, Gracias por la ayuda brother, el problema estaba en la variable ownerID.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)