Weapons DialogSystem Error.
#1

I was getting 1 error with dialog,I asked help for it in this same topic.I was just a missing a bracket,fixed it and compiled it.No errors then after compiling but after I tested it in game.It just didn't give me anyweapon.

The pwn code:

pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#pragma tabsize 0
#define DIALOG_WEAPONS 67

CMD:weapons(playerid, params[])
{
    ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,"Weapons", "Deagle 2500$\nMP5 3000$\nAK-47 4500$\nM4 4500$", "Select", "Cancel");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_WEAPONS)
    {
    switch(listitem)
    {
    case 0:
    {
        if(GetPlayerMoney(playerid) < 2500)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -2500);
    GivePlayerWeapon(playerid, 24, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    case 1:
    {
        if(GetPlayerMoney(playerid) < 3000)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -3000);
    GivePlayerWeapon(playerid, 29, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    case 2:
    {
        if(GetPlayerMoney(playerid) < 4500)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -4500);
    GivePlayerWeapon(playerid, 30, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    case 3:
    {
        if(GetPlayerMoney(playerid) < 4500)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -4500);
    GivePlayerWeapon(playerid, 31, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    }
    }
return 1;
}
This ain't some copy paste code,I made this my self.

Note:-
I have another dialog for spawning a few vehicles ,so maybe that dialog's response is not letting my weapon dialog function maybe?

Pawn code with car dialog and weapon dialog:

pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 12)
        {
                if(response == 1)
                {
                   if(listitem == 0)
                        {
                            new Float:x, Float:y, Float:z, Float:a;
                            GetPlayerPos(playerid, x,y,z);
                            GetPlayerFacingAngle(playerid, a);
                            new vehicleid = CreateVehicle(411, x+3,y,z, a, -1, -1, -1);
                            PutPlayerInVehicle(playerid, vehicleid, 0);
                         }
                         if(listitem == 1)
                           {
                             new Float:x, Float:y, Float:z, Float:a;
                            GetPlayerPos(playerid, x,y,z);
                            GetPlayerFacingAngle(playerid, a);
                            new vehicleid = CreateVehicle(562, x+3,y,z, a, -1, -1, -1);
                            PutPlayerInVehicle(playerid, vehicleid, 0);

                         }
                        if(listitem == 2)
                           {
                               new Float:x, Float:y, Float:z, Float:a;
                               GetPlayerPos(playerid, x,y,z);
                               GetPlayerFacingAngle(playerid, a);
                               new vehicleid = CreateVehicle(451, x+3,y,z, a, -1, -1, -1);
                               PutPlayerInVehicle(playerid, vehicleid, 0);
                            }
                        if(listitem == 3)
                           {
                               new Float:x, Float:y, Float:z, Float:a;
                               GetPlayerPos(playerid, x,y,z);
                               GetPlayerFacingAngle(playerid, a);
                               new vehicleid = CreateVehicle(520, x+3,y,z, a, -1, -1, -1);
                               PutPlayerInVehicle(playerid, vehicleid, 0);
                            }
                        if(listitem == 4)
                           {
                               new Float:x, Float:y, Float:z, Float:a;
                               GetPlayerPos(playerid, x,y,z);
                               GetPlayerFacingAngle(playerid, a);
                               new vehicleid = CreateVehicle(522, x+3,y,z, a, -1, -1, -1);
                               PutPlayerInVehicle(playerid, vehicleid, 0);
                            }
                        if(listitem == 5)
                           {
                               new Float:x, Float:y, Float:z, Float:a;
                               GetPlayerPos(playerid, x,y,z);
                               GetPlayerFacingAngle(playerid, a);
                               new vehicleid = CreateVehicle(568, x+3,y,z, a, -1, -1, -1);
                               PutPlayerInVehicle(playerid, vehicleid, 0);
                            }
                         }
                }
    if(dialogid == DIALOG_WEAPONS)
    {
    switch(listitem)
    {
    case 0:
    {
        if(GetPlayerMoney(playerid) < 2500)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -2500);
    GivePlayerWeapon(playerid, 24, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    case 1:
    {
        if(GetPlayerMoney(playerid) < 3000)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -3000);
    GivePlayerWeapon(playerid, 29, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    case 2:
    {
        if(GetPlayerMoney(playerid) < 4500)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -4500);
    GivePlayerWeapon(playerid, 30, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    case 3:
    {
        if(GetPlayerMoney(playerid) < 4500)
    return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
    GivePlayerMoney(playerid, -4500);
    GivePlayerWeapon(playerid, 31, 1000);
    SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
    }
    }
    }
return 1;
}
Reply
#2

You have just forgot to close the switch with a bracket.
Reply
#3

Here you should have 4 cases followed by each weapons respectively.
Reply
#4

Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 67)
    switch(dialogid)
    {
         case 0:
         {
              if(GetPlayerMoney(playerid) < 2500)
              return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
              GivePlayerMoney(playerid, -2500);
              GivePlayerWeapon(playerid, 24, 100);
              SendClientMessage(playerid, 0x0000FFAA, "You have succesfully buyed your weapon.");
         }
    }
    return 1;
}
Reply
#5

pawn Code:
#include <a_samp>
#include <zcmd>
#include <sscanf2>

#pragma tabsize 0

// Defines

#define StartMoney          (50000000)
#define DIALOG_WEAPONS      (67)
#define DIALOG_CARS         (12)

CMD:weapons(playerid, params[])
{
    ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST,"Weapons", "Deagle 2500$\nMP5 3000$\nAK-47 4500$\nM4 4500$", "Select", "Cancel");
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_WEAPONS)
    {
        if(response)
        {
            if(listitem == 0)
            {
                if(GetPlayerMoney(playerid) < 2500) return SendClientMessage(playerid, 0x0000FFAA, "You don't have enough cash to buy this Weapon.");
                GivePlayerMoney(playerid, -2500);
                GivePlayerWeapon(playerid, 24, 100);
                SendClientMessage(playerid, 0x0000FFAA, "You have succesfully bought your weapon.");
            }
        }
    }
    return 1;
}
I hope that I helped!>
Reply
#6

Arakuta thanks for helping!And others too.But all I was just missing was one closing bracket.
But I have a problem.No errors but I am not getting the weapon when I buy it.(Deagle)
Reply
#7

Try to increase the amount of bullets or something?, it should work theres nothing wrong with your code ~ you maybe opened an old version or something> or didnt compile it
Reply
#8

Do you have enough money?
Reply
#9

I did everything.Saved it,compiled increased ammo to 1000.

Maybe is it because I only have written the case for 1 weapon?
Reply
#10

Yea I have 50000000 (start money).If I didn't have it ,I would have got a message.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)