Help with dialog
#1

Hi guys! I have a problem with a dialog response... I want that if you type example "5" in the textbox of the dialog it will give you 5 dollars. I tried to do it with zcmd and sscanf and it worked fine, but it was just a command like "/pay" not a dialog response...

The command "/pay" is
Код:
CMD:(playerid,params[])
{
    new
        ID,
        amount,
        name[MAX_PLAYERS],
        string7[200],
        name2[MAX_PLAYERS],
        string8[200];
    if(sscanf(params, "ui", ID,amount)) return SendClientMessage(playerid, -1, "Usage: /pay [playerid] [amount]");
    if(amount > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "[ERROR]: You do not have enough money to pay that player!");
    if(amount <= 0) return SendClientMessage(playerid, -1, "[ERROR]: You cannot pay less than $1!");
    GetPlayerName(ID, name2, sizeof(name2));
    format(string8, sizeof(string8),"You have paid %s $%i", name2, amount);
    SendClientMessage(playerid, COLOR_RED, string8);
    GetPlayerName(playerid, name, sizeof(name));
    format(string7, sizeof(string7), "%s(%d) Has paid you: $%i", name, playerid, amount);
    SendClientMessage(ID, COLOR_RED, string7);
    GivePlayerMoney(ID, amount);
    GivePlayerMoney(playerid, -amount);
    return 1;
}
Thanks for help :3
Reply
#2

I think you can do ShowPlayerDialog thing
Here is OnDialogResponse thing -
pawn Код:
//under ondialogresponse -
if(dialogid == DIALOG_GIVE_MONEY)//replace with your dilalog id
{
      if(!response)return 1;
      new amount = strval(inputtext);
      if(amount == 0)return SendClientMessage(playerid, -1, "{ff0000}Enter a numeric value greater than 0");
      //now use amount to give money
Reply
#3

Thanks! it work! :3 it was so easy... haha +rep
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)