Name from dialog
#3

Something fast I made, it should work.
Код:
#include <a_samp >
#include <zcmd >

public OnDialogResponse( playerid, dialogid, response, listitem, inputtext[ ] )
{
	if( dialogid == 1 )
    {
        if( response )
        {
			if( GetPlayerIdFromName( inputtext ) != INVALID_PLAYER_ID )
			{
			    // Give hime cookie!
			    return 1;
			}
			else return SendClientMessage( playerid, -1, "Invalid player ID!" );
		}
	}
	return 1;
}

CMD:cookie( playerid, params[ ] )
{
    ShowPlayerDialog( playerid, 1, DIALOG_STYLE_INPUT, "Enter name", "Enter player name to who you want to give cookie", "Give", "Cancel" );
    return 1;
}

stock GetPlayerIdFromName( playername[ ] )
{
	for( new i = 0; i <= GetMaxPlayers( ); i++ )
	{
    	if( IsPlayerConnected( i ) )
  		{
        	new
				playername2[ MAX_PLAYER_NAME ]
			;
            GetPlayerName(i, playername2, sizeof(playername2));
      		if( strcmp( playername2, playername, true, strlen( playername ) ) == 0 )
         	{
            	return i;
          	}
      	}
   	}
	return INVALID_PLAYER_ID;
}
Reply


Messages In This Thread
Name from dialog - by Larry123 - 07.11.2012, 19:50
Re: Name from dialog - by Sinner - 07.11.2012, 19:58
Re: Name from dialog - by Konstantinos - 07.11.2012, 20:13
Re: Name from dialog - by Larry123 - 07.11.2012, 20:18

Forum Jump:


Users browsing this thread: 2 Guest(s)