Jump to content

Weapon Shop


Recommended Posts

--ID , Slot, Name, Ammo, Price 
wpShopTable = { 
    {331, 0, "Brass Knuckles", 1, 5}, 
    {333, 1, "Golf Club", 1, 5}, 
    {334, 1, "Nightstick", 1, 5}, 
    {335, 1, "Knife", 1, 20}, 
    {336, 1, "Baseball Bat", 1, 5}, 
    {337, 1, "Shovel", 1, 5}, 
    {338, 1, "Pool Cue", 1, 5}, 
    {339, 1, "Katana", 1, 50}, 
    {341, 1, "Chainsaw", 1, 250}, 
    {346, 2, "Pistol", 17, 170}, 
    {347, 2, "Silenced Pistol", 17, 180}, 
    {348, 2, "Desert Eagle", 7, 100}, 
    {349, 3, "Shotgun", 1, 20}, 
    {350, 3, "Sawn-Off Shotgun", 2, 50}, 
    {351, 3, "SPAZ-12", 7, 70}, 
    {352, 4, "Uzi", 50, 500}, 
    {353, 4, "MP5", 30, 300}, 
    {372, 4, "TEC-9", 50, 500}, 
    {355, 5, "AK-47", 30, 600}, 
    {356, 5, "M4", 50, 1000}, 
    {357, 6, "Country Rifle", 1, 25}, 
    {358, 6, "Sniper Rifle", 1, 30}, 
    {359, 7, "Rocket Launcher", 1, 100}, 
    {360, 7, "Heat-Seeking RPG", 1, 120}, 
    {361, 7, "Flamethrower", 50, 500}, 
    {362, 7, "Minigun", 500, 5000}, 
    {342, 8, "Grenade", 1, 70}, 
    {343, 8, "Tear Gas", 1, 50}, 
    {344, 8, "Molotov Cocktails", 1, 60}, 
    {363, 8, "Satchel Charges", 1, 100}, 
    {365, 9, "Spraycan", 500, 200}, 
    {366, 9, "Fire Extinguisher", 500, 200}, 
    {367, 9, "Camera", 36, 100}, 
    {321, 10, "Long Dil**", 1, 5}, 
    {322, 10, "Short Dil**", 1, 5}, 
    {323, 10, "Vibra***", 1, 5}, 
    {325, 10, "Flowers", 1, 5}, 
    {326, 10, "Cane", 1, 5}, 
    {368, 11, "NV Googles", 1, 50}, 
    {369, 11, "IR Goorles", 1, 50}, 
    {371, 11, "Parachute", 1, 100}, 
    {364, 12, "Satchel Detonator", 1, 0} 
} 
  
wpShopWin1 = guiCreateWindow(492, 207, 500, 394, "|Weapon_Shop|", false) 
guiWindowSetSizable(wpShopWin1, false) 
  
wpShopGridlist1 = guiCreateGridList(10, 25, 481, 313, false, wpShopWin1) 
guiGridListAddColumn(wpShopGridlist1, "ID", 0.1) 
guiGridListAddColumn(wpShopGridlist1, "Slot", 0.05) 
guiGridListAddColumn(wpShopGridlist1, "Name", 0.45) 
guiGridListAddColumn(wpShopGridlist1, "Damage", 0.1) 
guiGridListAddColumn(wpShopGridlist1, "Ammo", 0.14) 
guiGridListAddColumn(wpShopGridlist1, "Price", 0.14) 
wpShopBtnBuy = guiCreateButton(114, 348, 328, 27, "Buy", false, wpShopWin1) 
guiSetProperty(wpShopBtnBuy, "NormalTextColour", "FFAAAAAA") 
wpShopBtnClose = guiCreateButton(10, 348, 61, 27, "Close", false, wpShopWin1) 
guiSetProperty(wpShopBtnClose, "NormalTextColour", "FFAAAAAA") 
guiSetVisible(wpShopWin1, false) 
  
function replace( ) 
    for i,v in pairs( wpShopTable ) do 
        guiGridListAddRow(wpShopGridlist1) 
        guiGridListSetItemText(wpShopGridlist1, 0, 1, tostring( v[1] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 2, tostring ( v[2] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 3, tostring ( v[3] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 4, tostring ( getWeaponProperty( tonumber( v[1] ), "poor", "weapon_range")), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 5, tostring( v[4] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 6, "$"..tostring (v[5]), false, false) 
         
    end 
end 
setTimer( replace,1000,1 ) 
  
function showWPSGUI () 
guiSetVisible(wpShopWin1, true) 
showCursor(true) 
end 
  
function closeWPSGUI ( button ) 
    if button == "left" then 
    guiSetVisible(wpShopWin1, false) 
    showCursor(false) 
    end 
end 
  
addEventHandler ( "onClientGUIClick", wpShopBtnClose, closeWPSGUI, false ) 
  
addCommandHandler ( "buyweap", showWPSGUI ) 

Как сделать чтобы все строчки отображались?

ато вот:

31961228e65b.jpg

Link to comment
  • Other Languages Moderators
guiGridListAddRow(wpShopGridlist1) 
        guiGridListSetItemText(wpShopGridlist1, 0, 1, tostring( v[1] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 2, tostring ( v[2] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 3, tostring ( v[3] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 4, tostring ( getWeaponProperty( tonumber( v[1] ), "poor", "weapon_range")), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 5, tostring( v[4] ), false, false) 
        guiGridListSetItemText(wpShopGridlist1, 0, 6, "$"..tostring (v[5]), false, false) 

Ты указываешь нулевую строку в 2 аргументе функции guiGridListSetItemText. Значит, когда будет цикл, то ты увидишь только последний текст т.к ты указал нулевую строку. Тебе нужно строку, которая возвращает функция guiGridListAddRow применить как второй аргумент к функции guiGridListSetItemText.

И ещё

guiGridListSetItemText(wpShopGridlist1, iRow, 4, tostring ( getWeaponProperty( tonumber( v[1] ), "poor", "weapon_range")), false, false) 

В аргументе функции getWeaponProperty тебе надо указывать ИД оружия, а не ИД МОДЕЛИ. В своём коде уже написал функцию для нахождения ИДА оружия из ИДА МОДЕЛИ.

  
local WeaponsIds =  
{ 
    --0 слот 
    [1] = 331, 
    --1 слот 
    [2] = 333, 
    [3] = 334, 
    [4] = 335, 
    [5] = 336, 
    [6] = 337, 
    [7] = 338, 
    [8] = 339, 
    [9] = 341, 
    --2 слот 
    [22] = 346, 
    [23] = 347, 
    [24] = 348, 
    --3 слот 
    [25] = 349, 
    [26] = 350, 
    [27] = 351, 
    --4 слот 
    [28] = 352, 
    [29] = 353, 
    [32] = 372, 
    --5 слот 
    [30] = 355, 
    [31] = 356, 
    --6 слот 
    [33] = 357, 
    [34] = 358, 
    --7 слот 
    [35] = 359, 
    [36] = 360, 
    [37] = 361, 
    [38] = 362, 
    --8 слот 
    [16] = 342, 
    [17] = 343, 
    [18] = 344, 
    [39] = 363, 
    --9 слот 
    [41] = 365, 
    [42] = 366, 
    [43] = 367, 
    --10 слот 
    [10] = 321, 
    [11] = 322, 
    [12] = 323, 
    [13] = 324, 
    [14] = 325, 
    [15] = 326, 
    --11 слот 
    [44] = 368, 
    [45] = 369, 
    [46] = 371, 
    --12 слот 
    [40] = 364 
} 
  
function GetWeaponIDFromModelID( iModelID ) 
    for i, v in pairs( WeaponsIds ) do 
        if v == iModelID then 
            return i 
        end 
    end 
    return false 
end 
  
-- Со строки 65 
local iRow = guiGridListAddRow( wpShopGridlist1 ) 
guiGridListSetItemText(wpShopGridlist1, iRow, 1, tostring( v[1] ), false, false) 
guiGridListSetItemText(wpShopGridlist1, iRow, 2, tostring ( v[2] ), false, false) 
guiGridListSetItemText(wpShopGridlist1, iRow, 3, tostring ( v[3] ), false, false) 
guiGridListSetItemText(wpShopGridlist1, iRow, 4, tostring ( getWeaponProperty( GetWeaponIDFromModelID( tonumber( v[1] ) ), "poor", "damage")), false, false) 
guiGridListSetItemText(wpShopGridlist1, iRow, 5, tostring( v[4] ), false, false) 
guiGridListSetItemText(wpShopGridlist1, iRow, 6, "$"..tostring (v[5]), false, false) 

Link to comment

[1] = 331,

а как же строка с ценой и патронами?

или после запятой дописывать?

[1] = 331, 0, "Brass Knuckles", 1, 5

СПС

Тупо заменил ид модели на ид оружия и всё

wpShopTable = { 
    {1, 0, "Brass Knuckles", 1, 5}, 
    {2, 1, "Golf Club", 1, 5}, 
    {3, 1, "Nightstick", 1, 5}, 
    {4, 1, "Knife", 1, 20}, 
    {5, 1, "Baseball Bat", 1, 5}, 
    {6, 1, "Shovel", 1, 5}, 
    {7, 1, "Pool Cue", 1, 5}, 
    {8, 1, "Katana", 1, 50}, 
    {9, 1, "Chainsaw", 1, 250}, 
    {22, 2, "Pistol", 17, 170}, 
    {23, 2, "Silenced Pistol", 17, 180}, 
    {24, 2, "Desert Eagle", 7, 100}, 
    {25, 3, "Shotgun", 1, 20}, 
    {26, 3, "Sawn-Off Shotgun", 2, 50}, 
    {27, 3, "SPAZ-12", 7, 70}, 
    {28, 4, "Uzi", 50, 500}, 
    {29, 4, "MP5", 30, 300}, 
    {32, 4, "TEC-9", 50, 500}, 
    {30, 5, "AK-47", 30, 600}, 
    {31, 5, "M4", 50, 1000}, 
    {33, 6, "Country Rifle", 1, 25}, 
    {34, 6, "Sniper Rifle", 1, 30}, 
    {35, 7, "Rocket Launcher", 1, 100}, 
    {36, 7, "Heat-Seeking RPG", 1, 120}, 
    {37, 7, "Flamethrower", 50, 500}, 
    {38, 7, "Minigun", 500, 5000}, 
    {16, 8, "Grenade", 1, 70}, 
    {17, 8, "Tear Gas", 1, 50}, 
    {18, 8, "Molotov Cocktails", 1, 60}, 
    {39, 8, "Satchel Charges", 1, 100}, 
    {41, 9, "Spraycan", 500, 200}, 
    {42, 9, "Fire Extinguisher", 500, 200}, 
    {43, 9, "Camera", 36, 100}, 
    {10, 10, "Long Dil**", 1, 5}, 
    {11, 10, "Short Dil**", 1, 5}, 
    {12, 10, "Vibra***", 1, 5}, 
    {14, 10, "Flowers", 1, 5}, 
    {15, 10, "Cane", 1, 5}, 
    {44, 11, "NV Googles", 1, 50}, 
    {45, 11, "IR Goorles", 1, 50}, 
    {46, 11, "Parachute", 1, 100}, 
    {40, 12, "Satchel Detonator", 1, 0} 
} 

3bda173eaca2.jpg

Link to comment

Как видно на скриншоте, в полосках Damage у холодного оружия написано false(что совсем не уважает холодное оружие)

Как сделать так чтобы в строчке было написано вместо false - unknown(типа неизвестно).

Вот строчка:

guiGridListSetItemText(wpShopGridlist1, iRow, 4, tostring ( getWeaponProperty( tonumber( v[1] ), "poor", "weapon_range")), false, false) 

Link to comment
  • Other Languages Moderators

Тебе нужно вместо аргумента третьего в функции getWeaponProperty использовать 'damage', а не 'weapon_range'.

Link to comment

да, ну я и туп, как скопировал с вики так и оставил :oops:

_______________________

--[id], model , Slot, Name, Ammo, Price, Damage 
wpShopTable = { 
    {0, 0, "Unarmed", 1, 0, "5-25"}, 
    {1, 0, "Brass Knuckles", 1, 5, "5-25"}, 
    {2, 1, "Golf Club", 1, 5, "10-25"}, 
    {3, 1, "Nightstick", 1, 5, "10-25"}, 
    {4, 1, "Knife", 1, 20, "10-25"}, 
    {5, 1, "Baseball Bat", 1, 5, "10-25"}, 
    {6, 1, "Shovel", 1, 5, "10-25"}, 
    {7, 1, "Pool Cue", 1, 5, "10-25"}, 
    {8, 1, "Katana", 1, 50, "10-25"}, 
    {9, 1, "Chainsaw", 1, 250, "25-100"}, 
    {22, 2, "Pistol", 17, 170, 25}, 
    {23, 2, "Silenced Pistol", 17, 180, 40}, 
    {24, 2, "Desert Eagle", 7, 100, 70}, 
    {25, 3, "Shotgun", 1, 20, 10}, 
    {26, 3, "Sawn-Off Shotgun", 2, 50, 10}, 
    {27, 3, "SPAZ-12", 7, 70, 15}, 
    {28, 4, "Uzi", 50, 500, 20}, 
    {29, 4, "MP5", 30, 300, 25}, 
    {32, 4, "TEC-9", 50, 500, 20}, 
    {30, 5, "AK-47", 30, 600, 30}, 
    {31, 5, "M4", 50, 1000, 30}, 
    {33, 6, "Country Rifle", 1, 25, 75}, 
    {34, 6, "Sniper Rifle", 1, 30, 125}, 
    {35, 7, "Rocket Launcher", 1, 100, 75}, 
    {36, 7, "Heat-Seeking RPG", 1, 120, 75}, 
    {37, 7, "Flamethrower", 50, 500, 25}, 
    {38, 7, "Minigun", 500, 5000, 140}, 
    {16, 8, "Grenade", 1, 70, 75}, 
    {17, 8, "Tear Gas", 1, 50, 75}, 
    {18, 8, "Molotov Cocktails", 1, 60, 75}, 
    {39, 8, "Satchel Charges", 1, 100, 75}, 
    {41, 9, "Spraycan", 500, 200, 1}, 
    {42, 9, "Fire Extinguisher", 500, 200, 1}, 
    {43, 9, "Camera", 36, 100, 0}, 
    {10, 10, "Long Dil**", 1, 5, "10-25"}, 
    {11, 10, "Short Dil**", 1, 5, "10-25"}, 
    {12, 10, "Vibra***", 1, 5, "10-25"}, 
    {14, 10, "Flowers", 1, 5, "10-25"}, 
    {15, 10, "Cane", 1, 5, "10-25"}, 
    {44, 11, "NV Googles", 1, 50, 0}, 
    {45, 11, "IR Goorles", 1, 50, 0}, 
    {46, 11, "Parachute", 1, 100, 0}, 
    {40, 12, "Satchel Detonator", 1, 0, 0} 
} 
  
wpShopWin1 = guiCreateWindow(492, 207, 500, 394, "|Weapon_Shop|", false) 
guiWindowSetSizable(wpShopWin1, false) 
  
wpShopGridlist1 = guiCreateGridList(10, 25, 481, 313, false, wpShopWin1) 
guiGridListAddColumn(wpShopGridlist1, "ID", 0.1) 
guiGridListAddColumn(wpShopGridlist1, "Slot", 0.05) 
guiGridListAddColumn(wpShopGridlist1, "Name", 0.45) 
guiGridListAddColumn(wpShopGridlist1, "Damage", 0.1) 
guiGridListAddColumn(wpShopGridlist1, "Ammo", 0.14) 
guiGridListAddColumn(wpShopGridlist1, "Price", 0.14) 
wpShopBtnBuy = guiCreateButton(114, 348, 328, 27, "Buy", false, wpShopWin1) 
guiSetProperty(wpShopBtnBuy, "NormalTextColour", "FFAAAAAA") 
wpShopBtnClose = guiCreateButton(10, 348, 61, 27, "Close", false, wpShopWin1) 
guiSetProperty(wpShopBtnClose, "NormalTextColour", "FFAAAAAA") 
guiSetVisible(wpShopWin1, false) 
  
function GetWeaponIDFromModelID( iModelID ) 
    for i, v in pairs( WeaponsIds ) do 
        if v == iModelID then 
            return i 
        end 
    end 
    return false 
end 
  
function addRowWPSGUI() 
         -- If the column was successfully created 
                for i, v in ipairs( wpShopTable ) do --Loop through all the players, adding them to the table 
                        local iRow = guiGridListAddRow( wpShopGridlist1 ) 
                        guiGridListSetItemText(wpShopGridlist1, iRow, 1, tostring ( v[1] ), false, false) 
                        guiGridListSetItemText(wpShopGridlist1, iRow, 2, tostring ( v[2] ), false, false) 
                        guiGridListSetItemText(wpShopGridlist1, iRow, 3, tostring ( v[3] ), false, false) 
                        guiGridListSetItemText(wpShopGridlist1, iRow, 4, tostring ( v[6] ), false, false) 
                        guiGridListSetItemText(wpShopGridlist1, iRow, 5, tostring ( v[4] ), false, false) 
                        guiGridListSetItemText(wpShopGridlist1, iRow, 6, "$"..tostring (v[5]), false, false) 
                end 
end 
addEventHandler ( "onClientResourceStart", getRootElement(), addRowWPSGUI ) 
  
function showWPSGUI () 
guiSetVisible(wpShopWin1, true) 
showCursor(true) 
end 
  
function closeWPSGUI ( button ) 
    if button == "left" then 
    guiSetVisible(wpShopWin1, false) 
    showCursor(false) 
    end 
end 
  
addEventHandler ( "onClientGUIClick", wpShopBtnClose, closeWPSGUI, false ) 
  
addCommandHandler ( "buyweap", showWPSGUI ) 

Как сделать чтобы при нажатии на ряд выдавалось сообщение:

Id v[1], ammo v[5], $ v[6] ??? :?::?::?::?::?:

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...