In need of a small script made..
#1

Hello, I know I'm asking a lot but I really need someone to make me a /buygun script, I want it so when their at the point and type e.g. /buygun colt45 it gives them a colt45.. Here's a short brief:

Quote:
Variables that you need are
PlayerInfo[playerid][pMoney] (to check if they have enough for the gun and then take the money away)

PlayerInfo[playerid][pLevel] (certain guns at certain levels)

If you say yes, here's what I need:
Colt45 - Level 1, $500

MP5 - Level 2, $1,500
Shotgun - Level 2, $2,000

Desert Eagle - Level 3, $10,000
Rifle - Level 3, $12,000

M4 - Level 3, $20,000
AK47 - Level 3, $30,000
Spas12 - Level 3, $65,000
Sniper - Level 3, $200,000
RPG - Level 15, $20,000,000

The point is:
246.321929, 108.295661, 1003.218750
And if they type /buygun colt45 outside of the point it says "Please go to the Black Market!", if they type /buygun (no gun name) at the Black Market, it comes up with like a "USUAGE: [gun names], [level needed], [price]" list..

I'll be very grateful if someone can do this for free, if you can't.. reply back with a price you want, I might be able to pay.
Reply
#2

you need to give me more info's, what is different between M4 Level 3 and Level 1
Reply
#3

There is no difference, there is no M4 level 1.
I will explain it:
Colt45 - Level 1, $500
Gunname - level required to buy (PlayerInfo[playerid][pLevel]), money required to buy (PlayerInfo[playerid][pMoney])

So if a player tries to buy an M4 when they are level 2, it will return telling them they aren't the right level.
Reply
#4

aha, ok I'll script that for you
Reply
#5

Here is code that you will put after #include

pawn Код:
enum _weapons{
    Weapon_Name[64],
    Model,
    Level,
    Price
}

new Weapons[][_weapons] = {
    {'colt45',22,1,500},
    {'mp5',29,2,1500},
    {'shotgun',25,2,2000},
    {'deagle',24,3,10000},
    {'rifle',33,3,12000},
    {'m4',31,3,20000},
    {'ak47',30,3,30000},
    {'spas12',26,3,65000},
    {'sniper',34,3,200000},
    {'rpg',35,15,20000000}
};
and this in OnPlayerCommandText

pawn Код:
if(!strcmp(cmd, "/buygun", true)){
    new tmp[128], BG_String[256];
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)){
        SendClientMessage(playerid, COLOR_GREY, "USAGE: /buygun [GunName]");
        return 1;
    }
    for(new i=0;i<sizeof(Weapons);i++){
        if(!strcmp(Weapons[i][Weapon_Name], tmp, true)){
            if(PlayerInfos[playerid][pLevel] >= Weapons[i][Level]){
                if(PlayerInfos[playerid][pMoney] >= Weapons[i][Price]){
                    GivePlayerWeapon(playerid, Weapons[i][Model], 500);
                    PlayerInfos[playerid][pMoney] = PlayerInfos[playerid][pMoney] - Weapons[i][Price];
                    GivePlayerMoney(playerid, -Weapons[i][Price]);
                    return 1;
                }else{
                    SendClientMessage(playerid, COLOR_RED, "You don't have enough money.");
                    return 1;
                }
            }else{
                format(BG_String, sizeof(BG_String), "You have to be at least level %d to buy this weapon.", Weapons[i][Level]);
                SendClientMessage(playerid, COLOR_REd, BG_String);
                return 1;
            }
        }
    }
    return 1;
}
Reply
#6

I got invalid decloration on:
Код:
new Weapons[][_weapons] = {
    {'colt45',22,1,500},
    {'mp5',29,2,1500},
    {'shotgun',25,2,2000},
    {'deagle',24,3,10000},
    {'rifle',33,3,12000},
    {'m4',31,3,20000},
    {'ak47',30,3,30000},
    {'spas12',26,3,65000},
    {'sniper',34,3,200000},
    {'rpg',35,15,20000000}
};
Reply
#7

Quote:
Originally Posted by Jack_Leslie
Посмотреть сообщение
I got invalid decloration on:
Код:
new Weapons[][_weapons] = {
    {'colt45',22,1,500},
    {'mp5',29,2,1500},
    {'shotgun',25,2,2000},
    {'deagle',24,3,10000},
    {'rifle',33,3,12000},
    {'m4',31,3,20000},
    {'ak47',30,3,30000},
    {'spas12',26,3,65000},
    {'sniper',34,3,200000},
    {'rpg',35,15,20000000}
};
Maybe because its like this
pawn Код:
new Weapons[11][_weapons] = {
{'colt45',22,1,500},
    {'mp5',29,2,1500},
    {'shotgun',25,2,2000},
    {'deagle',24,3,10000},
    {'rifle',33,3,12000},
    {'m4',31,3,20000},
    {'ak47',30,3,30000},
    {'spas12',26,3,65000},
    {'sniper',34,3,200000},
    {'rpg',35,15,20000000}
This should work if im not wrong.
Reply
#8

Unfortunately you're wrong, I get this error:
error 027: invalid character constant

On,
Код:
{'colt45',22,1,500},
Reply
#9

Can anyone fix?
Reply
#10

I think this should fix it.
Код:
new Weapons[10][3] = {
    {'colt45',22,1,500},
    {'mp5',29,2,1500},
    {'shotgun',25,2,2000},
    {'deagle',24,3,10000},
    {'rifle',33,3,12000},
    {'m4',31,3,20000},
    {'ak47',30,3,30000},
    {'spas12',26,3,65000},
    {'sniper',34,3,200000},
    {'rpg',35,15,20000000}
};
Reply
#11

error 032: array index out of bounds (variable "Weapons")
Reply
#12

pawn Код:
new Menu:weaponmenu;
pawn Код:
//CommandText
    if(strcmp(cmdtext, "/buyguns", true) == 0)
    {
    ShowMenuForPlayer(weaponmenu, playerid);
    return 1;
    }
pawn Код:
//FSInit
        weaponmenu = CreateMenu("Weapon Menu", 1, 220.0, 100.0, 150.0, 150.0);
    AddMenuItem(weaponmenu, 0, "9mm Weapon");
    AddMenuItem(weaponmenu, 0, "Silenced 9mm Weapon");
    AddMenuItem(weaponmenu, 0, "Desert Eagle Weapon");
    AddMenuItem(weaponmenu, 0, "Shotgun Weapon");
    AddMenuItem(weaponmenu, 0, "Sawnoff Shotgun Weapon");
    AddMenuItem(weaponmenu, 0, "Combat Shotgun Weapon");
    AddMenuItem(weaponmenu, 0, "Micro SMG (Uzi)Weapon");
    AddMenuItem(weaponmenu, 0, "SMG (MP5) Weapon");
    AddMenuItem(weaponmenu, 0, "AK47 (Kalashnikov)Weapon");
    AddMenuItem(weaponmenu, 0, "M4 Weapon");
    AddMenuItem(weaponmenu, 0, "Tec9 Weapon");
pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
    new Menu:CurrentMenu = GetPlayerMenu(playerid);
    if(CurrentMenu == weaponmenu)
    {
        switch(row)
        {
            case 0: //9mm
            {
                GivePlayerWeapon(playerid, 22 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your 9mm!");
               
            }
            case 1: //Silenced 9mm
            {
                GivePlayerWeapon(playerid, 23 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Silenced 9mm!");
               
            }
            case 2: //Desert Eagle
            {
                GivePlayerWeapon(playerid, 24 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Desert Eagle!");
           
            }
            case 3: //Shotgun
            {
                GivePlayerWeapon(playerid, 25 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Shotgun!!");
            }
            case 4: //Sawnoff Shotgun
            {
                GivePlayerWeapon(playerid, 26 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Sawnoff Shotgun!");
            }
            case 5: //Combat Shotgun
            {
                GivePlayerWeapon(playerid, 27 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Combat Shotgun!");
            }
            case 6: //Micro SMG (Uzi)
            {
                GivePlayerWeapon(playerid, 28 , 500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Micro SMG (Uzi)!");
            }
            case 7: //SMG (MP5)
            {
                GivePlayerWeapon(playerid, 29 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your SMG (MP5)!");
                }
            case 8: //AK47 (Kalashnikov)
            {
                GivePlayerWeapon(playerid, 30 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your AK47 !");
            }
            case 9: //M4
            {
                GivePlayerWeapon(playerid, 31 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your M4!");
            }
            case 10: //Tec9
            {
                GivePlayerWeapon(playerid, 32 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Tec9!");
            }
        }
    }
    return 1;
}
You can change weapons price by changing the number below:

GivePlayerMoney(playerid, -500);

Make sure to use the - (It'll remove the cash)
Reply
#13

Quote:
Originally Posted by Alex_Obando
Посмотреть сообщение
pawn Код:
new Menu:weaponmenu;
pawn Код:
//CommandText
    if(strcmp(cmdtext, "/buyguns", true) == 0)
    {
    ShowMenuForPlayer(weaponmenu, playerid);
    return 1;
    }
pawn Код:
//FSInit
        weaponmenu = CreateMenu("Weapon Menu", 1, 220.0, 100.0, 150.0, 150.0);
    AddMenuItem(weaponmenu, 0, "9mm Weapon");
    AddMenuItem(weaponmenu, 0, "Silenced 9mm Weapon");
    AddMenuItem(weaponmenu, 0, "Desert Eagle Weapon");
    AddMenuItem(weaponmenu, 0, "Shotgun Weapon");
    AddMenuItem(weaponmenu, 0, "Sawnoff Shotgun Weapon");
    AddMenuItem(weaponmenu, 0, "Combat Shotgun Weapon");
    AddMenuItem(weaponmenu, 0, "Micro SMG (Uzi)Weapon");
    AddMenuItem(weaponmenu, 0, "SMG (MP5) Weapon");
    AddMenuItem(weaponmenu, 0, "AK47 (Kalashnikov)Weapon");
    AddMenuItem(weaponmenu, 0, "M4 Weapon");
    AddMenuItem(weaponmenu, 0, "Tec9 Weapon");
pawn Код:
public OnPlayerSelectedMenuRow(playerid, row)
{
    new Menu:CurrentMenu = GetPlayerMenu(playerid);
    if(CurrentMenu == weaponmenu)
    {
        switch(row)
        {
            case 0: //9mm
            {
                GivePlayerWeapon(playerid, 22 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your 9mm!");
               
            }
            case 1: //Silenced 9mm
            {
                GivePlayerWeapon(playerid, 23 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Silenced 9mm!");
               
            }
            case 2: //Desert Eagle
            {
                GivePlayerWeapon(playerid, 24 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Desert Eagle!");
           
            }
            case 3: //Shotgun
            {
                GivePlayerWeapon(playerid, 25 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Shotgun!!");
            }
            case 4: //Sawnoff Shotgun
            {
                GivePlayerWeapon(playerid, 26 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Sawnoff Shotgun!");
            }
            case 5: //Combat Shotgun
            {
                GivePlayerWeapon(playerid, 27 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Combat Shotgun!");
            }
            case 6: //Micro SMG (Uzi)
            {
                GivePlayerWeapon(playerid, 28 , 500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Micro SMG (Uzi)!");
            }
            case 7: //SMG (MP5)
            {
                GivePlayerWeapon(playerid, 29 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your SMG (MP5)!");
                }
            case 8: //AK47 (Kalashnikov)
            {
                GivePlayerWeapon(playerid, 30 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your AK47 !");
            }
            case 9: //M4
            {
                GivePlayerWeapon(playerid, 31 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your M4!");
            }
            case 10: //Tec9
            {
                GivePlayerWeapon(playerid, 32 , 500);
                GivePlayerMoney(playerid, -500);
                SendClientMessage(playerid, LIGHT_BLUE, "Enjoy your Tec9!");
            }
        }
    }
    return 1;
}
You can change weapons price by changing the number below:

GivePlayerMoney(playerid, -500);

Make sure to use the - (It'll remove the cash)
EDIT:
It kinda works, thanks. But I cant use the mouse to go through the Menu. I have to use W and D or Up and Down hen Space
Reply
#14

no this will fix

pawn Код:
enum _weapons{
    Weapon_Name[64],
    Model,
    Level,
    Price
}

new Weapons[][_weapons] = {
    {"colt45",22,1,500},
    {"mp5",29,2,1500},
    {"shotgun",25,2,2000},
    {"deagle",24,3,10000},
    {"rifle",33,3,12000},
    {"m4",31,3,20000},
    {"ak47",30,3,30000},
    {"spas12",26,3,65000},
    {"sniper",34,3,200000},
    {"rpg",35,15,20000000}
};
i had to put " instead of '
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)