Litte help in dialog
#1

Hello everyone who read this topic, i making a system to find a car pos by license plate, Everywork until i arrive to the onDialogResponse, for some reason i cant get the name of the owner of the vehicle, i dont know where is the problem

This is my code

Код:
	if(dialogid == DIALOG_ENCONTRAR_VEHICULO)
	{
		if(response && strlen(inputtext) > 0)
		{
			for(new i; i < sizeof(cInfo); i++)
			{
                                //I check if the car have a license and the license is == to the inputtext 
				if(strcmp(cInfo[i][matricula], "Without License", false) == 0 && strcmp(cInfo[i][matricula], inputtext, true) == 0 && 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), "Found Vehicle | Owner: %s | License Plate: %s", name, inputtext); // <-
					SendClientMessage(playerid, -1, string);
					SendClientMessage(playerid, COLOR_YELLOW, "We find the car, check the map.");
					printf("DEBUG OUTFOR: Encontrado - Pos: %f,%f,%f, %s", x, y, z, name);
					return 0;
				}
			}
			SendClientMessage(playerid, -1, "Not vehicle found.");
		}
		else SendClientMessage(playerid, -1, "Panel closed.");
	}
Thanks in advance if someone can help me
Reply
#2

cInfo[i][ownerID]

Is it the SQLID or the id in the "tab list" ? Because I don't know your script and I need this element to try to help you.
Reply
#3

Quote:
Originally Posted by Etolas
Посмотреть сообщение
cInfo[i][ownerID]

Is it the SQLID or the id in the "tab list" ? Because I don't know your script and I need this element to try to help you.
Is the SQL ID, omg xD.. i think that was all xD let me check Thanks for ur reply Etolas
Reply
#4

Quote:
Originally Posted by N3cromancer
Посмотреть сообщение
Is the SQL ID, omg xD.. i think that was all xD let me check Thanks for ur reply Etolas
GetPlayerName(cInfo[i][ownerID], name, MAX_PLAYER_NAME);

So, you can't do this

Write a SQL request to get the playername by SQLID. If you don't know how to do, tell me.
Reply
#5

Etolas, 4 hours pass with this problem and you help me in 1 minute thanks alot bro, xD this is funny! (im so tired), i using the latest mysql from BlueG, how i can do it?

EDIT! I think i have done it via stock

Код:
stock GetPlayerTabId(mysql_player_id)
{
	foreach(new x: Player)
	{
		if(pInfo[x][id_db] == mysql_player_id)
		{
		    return pInfo[x][pID];
	    }
	}
	return INVALID_PLAYER_ID;
}
Reply
#6

I do this in my script to have directly the name.

Quote:

public MySQLGetName(result[], sqlid)
{
new query[128];
format(query, sizeof(query), "SELECT `Name` FROM `players_stats` WHERE ID=%d", sqlid);
mysql_query(query);
mysql_store_result();

if(mysql_num_rows()==0)
{return format(result, 32, "None");}
else
{
new strid[32];
if(mysql_fetch_row(strid)==1)
{
return format(result, 32, "%s", strid);
}
}
return 1;
}

My method could work for everything but take more ressources than yours. Just for your case, you script seems me much better than mine.

Your script there can't work for disconnect player unless you load all the sql database when GameMode Start
Reply
#7

Thanks my friend was very good your help it work now properly!
Reply
#8

Great, good luck !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)