Help with input dialog :D
#1

Hello!

I have added

type /getid to show input dialog and put name of player and get id of player it's not work plz help

This:
Quote:

dcmd_getid(playerid,params[]) {
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Se arch Player","Enter name:","Ok","Cancel");
new found, string[128], playername[MAX_PLAYER_NAME];
format(string,sizeof(string),"Searched for: \"%s\" ",params);
SendClientMessage(playerid,blue,string);
for(new i=0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
GetPlayerName(i, playername, MAX_PLAYER_NAME);
new namelen = strlen(playername);
new boolearched=false;
for(new pos=0; pos <= namelen; pos++)
{
if(searched != true)
{
if(strfind(playername,params,true) == pos)
{
found++;
format(string,sizeof(string),"%d. %s (ID %d)",found,playername,i);
SendClientMessage(playerid, green ,string);
searched = true;
}
}
}
}
}
if(found == 0) SendClientMessage(playerid, lightblue, "No players have this in their nick");
return 1;
}

Sorry for my bad english
Reply
#2

Try this:

Код:
dcmd_getid(playerid,params[]) 
{
	return ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Search Player", "Enter name:", "Ok", "Cancel");
}
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == 1)
	{
		if(response)
		{
			new string[128],name[64],count;
			count = 0;
			
			for(new i=0; i< MAX_PLAYERS; i++)
			{
				if(IsPlayerConnected(i))
				{
					GetPlayerName(i,name,64);
					if(!strcmp(name,inputtext))
					{
						count++;
						format(string,128,"%s - ID : %d",name,i);
						SendClientMessage(playerid,0xffff00aa,string);
					}
				}
			}
			if(count == 0) return SendClientMessage(playerid,0xffffffaa,"Player not found.");
		}
		return 1;
	}
	return 0;
}
Reply
#3

Thats fine work thank you!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)