Script Help [CMD]
#1

Hello i found this script that i liked By ''Inn0cent''

Код:
//Weapons shop.

#include <a_samp>
#define DIALOG_WEAPONS 1337
#define     GREY       "{6c6c6c}"
#define     RED        "{FF0000}"

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/weapon", cmdtext, true, 10) == 0)
    {
        new string[368];
        strcat(string,"Explosives                                   [$500]");
        strcat(string,"Hand Guns                                    [$1,000]\n");
        strcat(string,"Shotguns                                       [$5,000]\n");
        strcat(string,"Assault Weapons                          [$8,000]\n");
        strcat(string,"Rifles                                              [$12,000]\n");
        ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons:",string,"Select","Back");
        return 1;
    }
    return 0;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == DIALOG_WEAPONS)
    {
        if(response)
        {
            if(listitem == 0)
            {
                new string[128];
                strcat(string,"Gernade\n");
                strcat(string,"Molotov Cocktail\n");
                ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "$500",string,"Buy","Back");
            }
            if(listitem == 1)//HAND GUNS
            {
                new string[128];
                strcat(string,"9mm\n");
                strcat(string,"Silence 9mm\n");
                strcat(string,"Desert Eagle\n");
                strcat(string,"Chainsaw\n");
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST,"$1,000",string,"Buy","Back");
            }
            if(listitem == 2)//Shotguns
            {
                new string[128];
                strcat(string,"Shotgun\n");
                strcat(string,"Sawnoff Shotgun\n");
                strcat(string,"Combat Shotgun\n");
                ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST,"$5,000",string,"Buy","Back");
            }
            if(listitem == 3)//Assault Weapons
            {
                new string[128];
                strcat(string,"Micro SMG/Uzi\n");
                strcat(string,"MP5\n");
                strcat(string,"AK-47\n");
                strcat(string,"M4\n");
                strcat(string,"Tec-9\n");
                ShowPlayerDialog(playerid, 3, DIALOG_STYLE_LIST, "$8,000",string,"Buy","Back");
            }
            if(listitem == 4)
            {
                new string[128];
                strcat(string,"Country Rifle\n");
                strcat(string,"Sniper Rifle\n");
                ShowPlayerDialog(playerid, 4, DIALOG_STYLE_LIST, "$12,000",string,"Buy","Back");
            }
        }
    }
    if(dialogid == 1)//HAND GUNS
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) < 1000) return SendClientMessage(playerid,-1,""RED"You dont have enough cash to buy this item.");
            if(listitem == 0)
            {
                GivePlayerWeapon(playerid, 22, 1000);
                GivePlayerMoney(playerid,-1000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 1)
            {
                GivePlayerWeapon(playerid, 23, 1000);
                GivePlayerMoney(playerid,-1000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 2)
            {
                GivePlayerWeapon(playerid, 24, 1000);
                GivePlayerMoney(playerid,-1000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 3)
            {
                GivePlayerWeapon(playerid, 9, 1000);
                GivePlayerMoney(playerid,-1000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
        }
    }
    if(dialogid == 2)//SHOT GUNS
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) < 5000) return SendClientMessage(playerid,-1,""RED"You dont have enough cash to buy this item.");
            if(listitem == 0)
            {
                GivePlayerWeapon(playerid, 25, 1000);
                GivePlayerMoney(playerid,-5000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 1)
            {
                GivePlayerWeapon(playerid, 26, 1000);
                GivePlayerMoney(playerid,-5000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 2)
            {
                GivePlayerWeapon(playerid, 27, 1000);
                GivePlayerMoney(playerid,-5000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
        }
    }
    if(dialogid == 3)//Assault weapons
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) < 8000) return SendClientMessage(playerid,-1,""RED"You dont have enough cash to buy this item.");
            if(listitem == 0)
            {
                GivePlayerWeapon(playerid,28,1000);
                GivePlayerMoney(playerid,-8000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 1)
            {
                GivePlayerWeapon(playerid,29,1000);
                GivePlayerMoney(playerid,-8000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 2)
            {
                GivePlayerWeapon(playerid,30,1000);
                GivePlayerMoney(playerid,-8000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 3)
            {
                GivePlayerWeapon(playerid,31,1000);
                GivePlayerMoney(playerid,-8000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 4)
            {
                GivePlayerWeapon(playerid,32,1000);
                GivePlayerMoney(playerid,-8000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
        }
    }
    if(dialogid == 4)//Rifles
    {
        if(response)
        {
            if(GetPlayerMoney(playerid) < 12000) return SendClientMessage(playerid,-1,""RED"You dont have enough cash to buy this item.");
            if(listitem == 0)
            {
                GivePlayerWeapon(playerid,33,1000);
                GivePlayerMoney(playerid,-12000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
            if(listitem == 1)
            {
                GivePlayerWeapon(playerid,34,1000);
                GivePlayerMoney(playerid,-12000);
                SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
            }
        }
    }
    if(dialogid == 5)//Explosives
    {
        if(GetPlayerMoney(playerid) < 12000) return SendClientMessage(playerid,-1,""RED"You dont have enough cash to buy this item.");
        if(listitem == 0)
        {
            GivePlayerWeapon(playerid,16,1000);
            GivePlayerMoney(playerid,-500);
            SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
        }
        if(listitem == 1)
        {
            GivePlayerWeapon(playerid,18,1000);
            GivePlayerMoney(playerid,-500);
            SendClientMessage(playerid,-1,""GREY"Weapon has been purchased");
        }
    }
    return 1;
}
and i want to make it only available at some weapon ammunation interior or other places
Reply
#2

pawn Код:
if (strcmp("/weapon", cmdtext, true, 10) == 0)
{
    if(GetPlayerInterior(playerid) == 4)
    {
        new string[368];
        strcat(string,"Explosives                                   [$500]");
        strcat(string,"Hand Guns                                    [$1,000]\n");
        strcat(string,"Shotguns                                       [$5,000]\n");
        strcat(string,"Assault Weapons                          [$8,000]\n");
        strcat(string,"Rifles                                              [$12,000]\n");
        ShowPlayerDialog(playerid, DIALOG_WEAPONS, DIALOG_STYLE_LIST, "Weapons:",string,"Select","Back");
        return 1;
    }
    else return SendClientMessage(playerid,COLOR,"You need to be in Ammunation!");
}
Not tested, but i think it work. And here you can get interior ids http://weedarr.wikidot.com/interior
Reply
#3

Add a virtual world atleast, there are many places that has interior 4.
Change this:
pawn Код:
if(GetPlayerInterior(playerid) == 4)
To:
pawn Код:
if(GetPlayerInterior(playerid) == 4 && GetPlayerVirtualWorld(playerid) == 59)
59 is an example, you may change it.
Reply
#4

Thank you guys +REP'ed
Reply
#5

when i tried to compile it, it say this

Код:
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(23) : error 017: undefined symbol "COLOR"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(26) : warning 217: loose indentation
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(26) : error 029: invalid expression, assumed zero
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(26) : error 004: function "OnDialogResponse" is not implemented
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(28) : error 017: undefined symbol "dialogid"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(30) : error 017: undefined symbol "response"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(32) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(39) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(48) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(56) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(66) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(75) : error 017: undefined symbol "dialogid"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(77) : error 017: undefined symbol "response"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(80) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(86) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(92) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(98) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(106) : error 017: undefined symbol "dialogid"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(108) : error 017: undefined symbol "response"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(111) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(117) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(123) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(131) : error 017: undefined symbol "dialogid"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(133) : error 017: undefined symbol "response"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(136) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(142) : error 017: undefined symbol "listitem"
C:\Users\Hamza\Desktop\NEXUS GAMING ROLEPLAY\filterscripts\buyweapon.pwn(148) : error 017: undefined symbol "listitem"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
Reply
#6

Probably a missing bracket somthing like this bro "}" try reviewing to figure out where u missed it.
Reply
#7

Like Imperor yes, to not make it hard for you to search for it instead use a missing bracket finder/fixer.
Reply
#8

Thank you
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)