OnDialogResponse
#1

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_COMMANDS)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    new pDialog[256 * 10];
                    strcat(pDialog, ""COL_LIGHTBLUE"/commands -> {FFFFFF}Shows you the list of server's command.\n"COL_LIGHTBLUE"/help ->{FFFFFF} Gives you the basic of how to play in the server.\n"COL_LIGHTBLUE"/ask (Question) -> {FFFFFF}To ask question to the online administrators.\n",sizeof(pDialog));
                    strcat(pDialog, ""COL_LIGHTBLUE"/kill -> {FFFFFF}Kills yourself, you must not have a wanted level.\n"COL_LIGHTBLUE"/rules -> {FFFFFF}Shows you the list of server's rules.\n"COL_LIGHTBLUE"/afk -> {FFFFFF}Go to the AFK state.\n"COL_LIGHTBLUE"/back -> {FFFFFF}Back from AFK state.\n",sizeof(pDialog));
                    strcat(pDialog, ""COL_LIGHTBLUE"/vips -> {FFFFFF}Shows you the list of online V.I.Ps.\n"COL_LIGHTBLUE"/admins -> {FFFFFF}Shows you the list of online Administrators.\n"COL_LIGHTBLUE"/pay (Player ID) (Amount) -> {FFFFFF}Give the specific players your cash.\n",sizeof(pDialog));
                    strcat(pDialog, ""COL_LIGHTBLUE"/stats -> {FFFFFF}View your statistic, to see other player's you can click on their name in Tab.\n"COL_LIGHTBLUE"/report (Player ID) (Reason) -> {FFFFFF}Reports a specific players for a reason.\n",sizeof(pDialog));
                    strcat(pDialog, ""COL_LIGHTBLUE"/cw (Message) -> {FFFFFF}Sends a car whisper to players in your vehicle.\n"COL_LIGHTBLUE"/pm (Player ID) (Message) -> {FFFFFF}Sends a private messages to a specific players.\n"COL_LIGHTBLUE"/changename (New Name) -> {FFFFFF}To change your ingame name, fee 500k.\n",sizeof(pDialog));
                    strcat(pDialog, ""COL_LIGHTBLUE"/r (Message) ->{FFFFFF} Reply to your last private message.\n"COL_LIGHTBLUE"/nopm -> {FFFFFF}Rejects all incoming private messages.",sizeof(pDialog));
                    ShowPlayerDialog(playerid, DIALOG_COMMANDS, DIALOG_STYLE_MSGBOX, ""COL_YELLOW"General Commands", pDialog, "Close", "");
                }
                case 1:
                {
                    if(pInfo[playerid][pVIP] < 1)
                        return SendClientMessage(playerid, -1, "{FF0000}[VIP] You are not authorized to use this command.");
                    new combine[256 * 10];

                    if(pInfo[playerid][pVIP] >= 1)
                    {
                        strcat(combine, "{375FFF}Bronze V.I.P:\n");
                        strcat(combine, ""COL_LIGHTBLUE"/viptag - {FFFFFF}Toggle your VIP Tag.\n"COL_LIGHTBLUE"/vrepair - {FFFFFF}Repair your vehicles for free.\n"COL_LIGHTBLUE"/vcar - {FFFFFF}Spawn an Infernus in your location.\n");
                        strcat(combine, "{FF0000}* VIP Chat: ! (Ex: !Hello)\n\n");
                    }
                    if(pInfo[playerid][pVIP] >= 2)
                    {
                        strcat(combine, "{375FFF}Gold V.I.P:\n");
                        strcat(combine, ""COL_LIGHTBLUE"/vheal - {FFFFFF}Heals yourself for free.\n\n");
                    }
                    if(pInfo[playerid][pVIP] >= 3)
                    {
                        strcat(combine, "{375FFF}Diamond V.I.P:\n");
                        strcat(combine, "Coming Soon\n");
                    }

                    ShowPlayerDialog(playerid, DIALOG_BLANK, DIALOG_STYLE_MSGBOX, "VIP Commands", combine, "CLOSE", "");
                }
            }
            return 1;
        }
    }
    if(dialogid == DIALOG_REGISTER)
    {
        new file[128], name[MAX_PLAYER_NAME], str[1024];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(file, sizeof(file), "SFGWL/Accounts/%s.ini", name);
        if(response)
        {
            if(!strlen(inputtext))
            {
                format(str,sizeof str,"{FFFFFF}Hello "COL_YELLOW"%s{FFFFFF}.\n\nPlease insert your password to register your account.\n\n• You will need atleast 5 characters for your password\n• Remember, don't give your password to other people the administrator team will not ask for your password.\n• Don't leave your password blank!\n\nIf you are not a member of our "COL_BLUE2"Discord{FFFFFF}, feel free to join: "COL_BLUE2"www.discord.gg/pwWQF3k{FFFFFF}.", GetName(playerid), playerid);
                ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Account Register", str,"Register","Quit");
            }
            dini_Create(file);
            dini_IntSet(file, "Password", num_hash(inputtext));
            dini_IntSet(file, "AdminLevel", pInfo[playerid][pAdmin] = 0);
            dini_IntSet(file, "VIPLevel", pInfo[playerid][pVIP] = 0);
            dini_IntSet(file, "Cash", pInfo[playerid][pCash] = 0);
            dini_IntSet(file, "Score", pInfo[playerid][pScore] = 0);
            dini_IntSet(file, "Kills", pInfo[playerid][pKills] = 0);
            dini_IntSet(file, "Deaths", pInfo[playerid][pDeaths] = 0);
            dini_Set(file, "IP", GetPlayerIP2(playerid));
            dini_IntSet(file, "LoyaltyPoints", pInfo[playerid][pLoyalty] = 0);
            dini_IntSet(file, "Hours", pInfo[playerid][pHours] = 0);
            dini_IntSet(file, "Minutes", pInfo[playerid][pMinutes] = 0);
            dini_IntSet(file, "Second", pInfo[playerid][pSecond] = 0);
            pInfo[playerid][pLogged] = 1;


            GivePlayerCash(playerid, 10000);
            format(str, sizeof(str), "{FFFFFF}Congratulations "COL_ORANGE"%s{FFFFFF}, you have succesfully registered in our database.", name);
            SendClientMessage(playerid, -1, str);
            SendClientMessage(playerid, -1, "{FFFFFF}You have received "COL_ORANGE"$10.000 {FFFFFF}in your hand as a fresh start.");
            SendClientMessage(playerid, -1, "{C0C0C0}[SERVER] {FFFFFF}Please refer to "COL_GREY"/cmds {FFFFFF}for server commands and "COL_GREY"/rules {FFFFFF}for a good behaviour{FFFFFF}.");
            SendClientMessage(playerid, -1, "{C0C0C0}[SERVER] {FFFFFF}Read "COL_GREY"/help {FFFFFF}for server guide, if you need any assistance feel free to use "COL_GREY"/ask (Question).");
            SendClientMessage(playerid, -1, "{C0C0C0}[SERVER] {FFFFFF}Join our discord channel here: "COL_BLUE2"www.discord.gg/pwWQF3k{FFFFFF}.");
        }
        else
        {
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_LOGIN)
    {
        new file[128], name[MAX_PLAYER_NAME], str[1024];
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        format(file, sizeof(file), "SFGWL/Accounts/%s.ini", name);
        if(response)
        {
            if(strlen(inputtext))
            {
                if(num_hash(inputtext) != dini_Int(file, "Password"))
                {
                    format(str,sizeof str,"{FFFFFF}Hello "COL_YELLOW"%s{FFFFFF}.\n\nPlease insert your password to login to your account.\n"COL_RED"You have entered an incorrect password.\n\n{FFFFFF}If you are not a member of our "COL_BLUE2"Discord{FFFFFF}, feel free to join: "COL_BLUE2"www.discord.gg/pwWQF3k{FFFFFF}.", GetName(playerid), playerid);
                    ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT, "Account Login", str, "Login", "Cancel");
                }
                else
                {
                    pInfo[playerid][pAdmin] = dini_Int(file, "AdminLevel");
                    pInfo[playerid][pVIP] = dini_Int(file, "VIPLevel");
                    pInfo[playerid][pCash] = dini_Int(file, "Cash");
                    pInfo[playerid][pScore] = dini_Int(file, "Score");
                    pInfo[playerid][pKills] = dini_Int(file, "Kills");
                    pInfo[playerid][pDeaths] = dini_Int(file, "Deaths");
                    pInfo[playerid][pIP] = dini_Int(file, "IP");
                    pInfo[playerid][pBanned] = dini_Int(file, "Banned");
                    pInfo[playerid][pLoyalty] = dini_Int(file, "LoyaltyPoints");
                    pInfo[playerid][pHours] = dini_Int(file, "Hours");
                    pInfo[playerid][pMinutes] = dini_Int(file, "Minutes");
                    pInfo[playerid][pSecond] = dini_Int(file, "Second");
                    pInfo[playerid][pLogged] = 1;

                    SetPlayerCash(playerid, pInfo[playerid][pCash]);
                    SetPlayerScore(playerid, pInfo[playerid][pScore]);
                    format(str, sizeof(str), "{FFFFFF}Welcome back "COL_LIGHTBLUE"%s{FFFFFF}, your status has been succesfully loaded!", name);
                    SendClientMessage(playerid, -1, str);
                    format(str, sizeof(str), "{FFFFFF}Admin Level: "COL_GREEN"%s {FFFFFF}- VIP Level: "COL_GREEN"%s", GetAdminName(playerid), GetVIPName(playerid));
                    SendClientMessage(playerid, -1, str);
                }
            }
        }
        else
        {
            Kick(playerid);
        }
    }
    if(dialogid == DIALOG_SHOP)
    {
        if(response)
        {
            if(GetPlayerCash(playerid) < WEAPON_SHOP[listitem][WEAPON_PRICE])
            {
                return SendClientMessage(playerid, 0xAA0000FF, ""COL_RED"[ERROR] You don't have enough money to buy this item.");
            }
            GivePlayerCash(playerid, -WEAPON_SHOP[listitem][WEAPON_PRICE]);
            GivePlayerWeapon(playerid, WEAPON_SHOP[listitem][WEAPON_ID], WEAPON_SHOP[listitem][WEAPON_AMMO]);

            GameTextForPlayer(playerid, "~g~Item Purchased!", 3000, 3);
        }
    }
    return 1;
}
Every dialog is working fine, but the last one which is shop is not working well. I clicked a gun and then purchase but instead of giving me my gun, nothing happened. Also, i don't use any filterscripts.
Reply
#2

Show me how your WEAPON_SHOP array looks like and the line where you show that dialog to a player.
Reply
#3

Quote:
Originally Posted by Skimmer
View Post
Show me how your WEAPON_SHOP array looks like and the line where you show that dialog to a player.
pawn Code:
enum E_WEAPON_SHOP_DATA
{
    WEAPON_MODELID,
    WEAPON_NAME[35],
    WEAPON_PRICE,
    WEAPON_AMMO,
    WEAPON_ID
};

new const WEAPON_SHOP[][E_WEAPON_SHOP_DATA] =
{
    {341, "Chainsaw", 10000, 1, WEAPON_CHAINSAW},
    {347, "Silenced 9mm", 1500, 150, WEAPON_SILENCED},
    {348, "Desert Eagle", 2500, 150, WEAPON_DEAGLE},
    {350, "Sawed Off Shotgun", 8000, 30, WEAPON_SAWEDOFF},
    {351, "Spas12 Shotgun", 4500, 100, WEAPON_SHOTGSPA},
    {352, "Micro-UZI", 3500, 500, WEAPON_UZI},
    {353, "MP5", 3000, 300, WEAPON_MP5},
    {372, "Tec-9", 3500, 500, WEAPON_TEC9},
    {358, "Sniper Rifle", 8000, 20, WEAPON_SNIPER},
    {355, "Ak47", 4500, 250, WEAPON_AK47},
    {356, "M4", 5000, 250, WEAPON_M4},
    {359, "RPG", 15000, 1, WEAPON_ROCKETLAUNCHER}
};
There it is.
Reply
#4

Do you lose cash when you buy a weapon? Also show me the line where you make the dialog visible for player.

Does that occur for all weapons? Check if the weapon ids in definitions are correct.
Reply
#5

Yes, it occurs for all weapons. Also, the ids are corrects. It used to work for me yesterday. And no, i don't lose cash.

pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == WeaponShop[0])
    {
        if(PickupCD[playerid] == 0)
        {
            new subString[64];
            static string[sizeof(WEAPON_SHOP) * sizeof(subString)];

            if (string[0] == EOS)
            {
                for (new i; i < sizeof(WEAPON_SHOP); i++)
                {
                    format(subString, sizeof(subString), "%i\t%s~n~~g~~h~$%i\n", WEAPON_SHOP[i][WEAPON_MODELID], WEAPON_SHOP[i][WEAPON_NAME], WEAPON_SHOP[i][WEAPON_PRICE]);
                    strcat(string, subString);
                }
            }
            PickupCD[playerid] = 3;
            return ShowPlayerDialog(playerid, DIALOG_SHOP, DIALOG_STYLE_PREVIEW_MODEL, "Weapon Shop", string, "Purchase", "Cancel");
        }
    }
    else if(pickupid == WeaponShop[1])
    {
        if(PickupCD[playerid] == 0)
        {
            new subString[64];
            static string[sizeof(WEAPON_SHOP) * sizeof(subString)];

            if (string[0] == EOS)
            {
                for (new i; i < sizeof(WEAPON_SHOP); i++)
                {
                    format(subString, sizeof(subString), "%i\t%s~n~~g~~h~$%i\n", WEAPON_SHOP[i][WEAPON_MODELID], WEAPON_SHOP[i][WEAPON_NAME], WEAPON_SHOP[i][WEAPON_PRICE]);
                    strcat(string, subString);
                }
            }
            PickupCD[playerid] = 3;
            return ShowPlayerDialog(playerid, DIALOG_SHOP, DIALOG_STYLE_PREVIEW_MODEL, "Weapon Shop", string, "Purchase", "Cancel");
        }
    }
    return 1;
}
Reply
#6

What you can do is to print a string to console in your condition where you compare the dialog id to be sure if it's even gets called.

pawn Code:
if(dialogid == DIALOG_SHOP)
{
    print("action for dialog shop");
    if(response)
    {
        ...
    }
}
Also try to use different id for DIALOG_SHOP.
Reply
#7

Tried this:
pawn Code:
if(dialogid == 7)
    {
        print("Opening Dialog");
        if(response)
        {
            print("Choosing a Weapon");
            if(GetPlayerCash(playerid) < WEAPON_SHOP[listitem][WEAPON_PRICE])
            {
                SendClientMessage(playerid, 0xAA0000FF, ""COL_RED"[ERROR] You don't have enough money to buy this item.");
            }
            GivePlayerCash(playerid, -WEAPON_SHOP[listitem][WEAPON_PRICE]);
            GivePlayerWeapon(playerid, WEAPON_SHOP[listitem][WEAPON_ID], WEAPON_SHOP[listitem][WEAPON_AMMO]);

            GameTextForPlayer(playerid, "~g~Item Purchased!", 3000, 3);
            print("Weapon Bought");
        }
    }
The printf doesnt show.
Reply
#8

I meant by trying to use different id is that you change the id of DIALOG_SHOP at definition.

pawn Code:
#define DIALOG_SHOP 6161
Reply
#9

Quote:
Originally Posted by Skimmer
View Post
I meant by trying to use different id is that you change the id of DIALOG_SHOP at definition.

pawn Code:
#define DIALOG_SHOP 6161
Same, nothing happens.
Reply
#10

This is weird. I tested that code on my local server and it's working fine.

I know this question will be a bit stupid, but are you maybe editing the wrong script?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)