SA-MP Forums Archive
Help me with input - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help me with input (/showthread.php?tid=483578)



Help me with DIALOG_STYLE_INPUT - Gr1Fax - 26.12.2013

Hi everyone, how can i create inputtext, that insert text someone name. On that player add's money or something else.


Re: Help me with input - Smileys - 26.12.2013

you mean like a dialog?

Step 1: Create a dialog: https://sampwiki.blast.hk/wiki/ShowPlayerDialog
Step 2: ondialog response:

pawn Код:
GivePlayerMoney( playerid, strval( inputtext ) );
^^ untested, but should work.
strval converts a string into an integer value, the inputtext is a string.

https://sampwiki.blast.hk/wiki/Strval


Re: Help me with input - Gr1Fax - 26.12.2013

Look, DIALOG_STYLE_INPUT if I enter someones online players ID, it gives him money.


Re: Help me with input - Gr1Fax - 26.12.2013

help. Bump


Re: Help me with input - Hansrutger - 26.12.2013

Yes hello, thanks for bumping the thread after that only 30 minutes has passed.

Код:
#define DIALOG_GIVE_MOENY 50

#define DIALOG_GIVE_MONEY2 51

new targetID;

OnPlayerDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if(dialogid == DIALOG_GIVE_MONEY)
	{
		if(response)
		{
			targetID = strval(inputtext);
			if(IsPlayerConnected(targetID)
			{
				ShowPlayerDialog(playerid, DIALOG_GIVE_MONEY2, DIALOG_STYLE_INPUT, "", "Insert the amount of money you want to give to the player.", "Next", "Close");
				return 1;
			}
			else
			{
				SCM(playerid, color, "Target is not online.");
				return 1;
			}
		}
		else if(!response)
		{
			SCM(playerid, color, "Well you just suck!");
			return 1;
		}
	}
	
	if(dialogid == DIALOG_GIVE_MOENY2)
	{
		if(response)
		{
			new money = strval(inputtext);
			ResetPlayerMoney(targetid);
			GivePlayerMoney(targetid, money);
			return 1;
		}
		if(!response) return SCM(playerid, color, "You suck even more now.");
	}
}

CMD:giveMoneyToPlayer(playerid, params[])
{
	ShowPlayerDialog(playerid, DIALOG_GIVE_MONEY, DIALOG_STYLE_INPUT, "", "Insert a player ID in the box below.", "Next", "Close");
	return 1;
}
Pretty sure this won't work if two players do this command at the same time because targetID is only one. But eh' whatever, don't see why you want this in dialogs if you can get it in a simple command. -.-' Oh and if you copy and paste this won't work.