Dialog Input
#1

I'm making a /buyclothes in Binco.

I have already created the dialog upon /buyclothes in Binco, and it's an INPUT dialog.

How do I make it so if they enter the number "1", they will get skin ID 1.

And if they enter "2", they will get skin ID 2.

I just need to know how I "get the input text", and I can add the SetPlayerSkin by myself. Thanks.
Reply
#2

i assume you already opened the dialog with the input requester, like:
Код:
ShowPlayerDialog(playerid,DIALOG_SENDCASH,DIALOG_STYLE_INPUT,Title,"","Transfer","Cancel");
then you only need to convert the inputtext into an integer:
Код:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[])
{
//...
	if(dialogid == DIALOG_SENDCASH)
	{
		new Amount=strval(inputtext);
		SendCash(playerid,TargetID,Amount);
	}
//... other stuff maybe...
}
the strval was what you were looking for, in combination with the inputtext...
Reply
#3

I'm looking on how to make it so if someone enters "2", it will give them skin ID 2.
Reply
#4

pawn Код:
#define D_CHANGE_SKIN 5

ShowPlayerDialog(playerid,D_CHANGE_SKIN ,DIALOG_STYLE_INPUT,"Skin","Type in your wanted skin id into the input box.","Change","Cancel");

public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]) {
        if(dialogid == D_CHANGE_SKIN) {
             new skinid = strval(inputtext);
     SetPlayerSkin(playerid, skinid);
        }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Carlton
pawn Код:
#define D_CHANGE_SKIN 5

ShowPlayerDialog(playerid,D_CHANGE_SKIN ,DIALOG_STYLE_INPUT,"Skin","Type in your wanted skin id into the input box.","Change","Cancel");

public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]) {
        if(dialogid == D_CHANGE_SKIN) {
             new skinid = strval(inputtext);
     SetPlayerSkin(playerid, skinid);
        }
    return 1;
}
Thanks, this is nice, but how do I make it so they can't buy any skin above 295? Cause if I buy skin ID 400 ingame it crashes everyone, which needs to not happen
Reply
#6

Use this so people wont have bad skins.
pawn Код:
stock IsValidSkin(skinid)
{
  #define   MAX_BAD_SKINS 35
  new badSkins[MAX_BAD_SKINS] =
  {
    0, 3, 4, 5, 6, 8, 10, 42, 65, 74,
        86, 92, 99, 119, 143, 144, 145, 146,
        149, 178, 208, 251, 252, 254, 264,
        265, 267, 273, 279, 277, 276, 274, 275,
        278, 289
  };
  if (skinid < 0 || skinid > 299) return false;
  for (new i = 0; i < MAX_BAD_SKINS; i++)
  {
    if (skinid == badSkins[i]) return false;
  }
  #undef MAX_BAD_SKINS
  return 1;
}
or...
if (skinid < 0 || skinid > 299)
Reply
#7

Quote:
Originally Posted by Johndaone
...
That's the old inefficient way of doing it from the debugfs, it also blocks other skins such as CJ, Truth etc. which are infact valid and up to the server owner to block them.

pawn Код:
stock IsValidSkin(skinid)
{
    if (skinid < 0 || skinid > 299)
      return 0;

    switch (skinid)
    {
      case
            3, 4, 5, 6, 8, 42, 65, 74,
            86, 119, 149, 208, 273, 289: return 0;
    }
   
    return 1;
}
Reply
#8

Ok so i add the stock IsInvalidSkin thing, but what else do I do to restrict them? Do I need to add an If line to the dialog response?
Reply
#9

pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
  if(response)
  {
     if(dialogid == D_CHANGE_SKIN)
     {  
      if(!inputtext[0])
      {
        SendClientMessage(playerid, COLOR, "Type the skin ID you want!");
        ShowPlayerDialog(playerid, D_CHANGE_SKIN, DIALOG_STYLE_INPUT, "Skin", "Type in your wanted skin id into the input box.", "Change", "Cancel");
      }
      else if(IsValidSkin(strval(inputtext)) == 0)
      {
        SendClientMessage(playerid, COLOR, "Invalid skin ID!");
        ShowPlayerDialog(playerid, D_CHANGE_SKIN, DIALOG_STYLE_INPUT, "Skin", "Type in your wanted skin id into the input box.", "Change", "Cancel");
        return 1;
      }
      SetPlayerSkin(playerid, strval(inputtext));
      SetSpawnInfo(playerid, 0, strval(inputtext), 0.0, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0, 0); // recommended
      SendClientMessage(playerid, "You have changed your skin!");
     }
  }
  return 1;
}
Reply
#10

u also need the "IsNumeric" Function here is the stock of it under IsValidSkin
Код:
stock IsValidSkin(SkinID)
{
	if((SkinID == 0)||(SkinID == 7)||(SkinID >= 9 && SkinID <= 41)||(SkinID >= 43 && SkinID <= 64)||(SkinID >= 66 && SkinID <= 73)||(SkinID >= 75 && SkinID <= 85)||(SkinID >= 87 && SkinID <= 118)||(SkinID >= 120 && SkinID <= 148)||(SkinID >= 150 && SkinID <= 207)||(SkinID >= 209 && SkinID <= 264)||(SkinID >= 274 && SkinID <= 288)||(SkinID >= 290 && SkinID <= 299)) return true;
	else return false;
}
stock IsNumeric(string[])
{
	for (new i = 0, j = strlen(string); i < j; i++)
	{
		if (string[i] > '9' || string[i] < '0') return 0;
	}
	return 1;
}
then use under OnDialogResponse :
Код:
if(dialogid == urdialog)
{
if(!reponse) return SendClientMessage(playerid,COLOR_RED,"You Canceled");
if(response)
{
if(IsNumeric(inputtext))
	  {
		if(IsValidSkin(strval(inputtext)))
		{
			SetPlayerSkin(playerid, strval(inputtext));
		}
		else
		{
		SendClientMessage(playerid,Color_Red,"All The Skins Availabe Exept From 1 -> 299 Exept Those Numbers :");
		SendClientMessage(playerid,Color_Red,"8,65,74,86,119,149,208,265,266,267,268,269,270,271,272,273,289");
		}
		}
		else
		{
		SendClientMessage(playerid,0xFF0000,"Please Use Numbers");
        }
        }
        }
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)