Recommended Posts

Posted (edited)

السلام عليكم و رحمة الله وبركاته 

اعطوني شرح دي المشكلة 

Server [16:06:22] MOD1\server.lua @ line 35: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got nil]

 

[16:06:22] MOD1\server.lua @ line 44: Bad argument @ 'triggerClientEvent' [Expected string at argument 1, got nil]

 

....

Edited by fargot..

Share this post


Link to post
function givePlayerRandomPackage ( player )
    if not getPlayerAccount ( player ) then return end
    triggerClientEvent ( player, 'Package:Random', player )
end

addCommandHandler ( 'getP',
function ( )
givePlayerRandomPackage ( root )
givePlayerRandomPackage ( source )
outPut ( ' Your Get Package To all', root )
triggerClientEvent ( source, 'Package:Random', source )
end)

addEvent ( 'Package:givePlayerPackage', true )
function givePlayerPackage ( package, ammount )
    if package then
        local _type
        if package == 1 then
            _type = 'Gold'
        elseif package == 2 then
            _type = 'Silver'
        elseif package == 3 then
            _type = 'Bronze'
        end
        local account = getAccountName ( getPlayerAccount ( source ) )
        local result = dbPoll(dbQuery(db, "SELECT * FROM Packages WHERE account = ? AND number = ? ", account, package), -1)
        if type(result) == "table" and #result ~= 0 and result[1]["account"] == account and result[1]["number"] == package then
            dbExec(db, "UPDATE Packages SET ammount = ? WHERE account = ? AND number = ?", tonumber ( result[1]["ammount"] + ammount ), account, package)
            outPut ( ammount.." of 'Lucky ".._type.."' package has been added to your inventory.", source )
        else
            dbExec ( db, "INSERT INTO Packages VALUES (?,?,?)", account, package, ammount)
            outPut ( ammount.." of Lucky ".._type.." package has been added to your inventory.", source )
        end
    end
end
addEventHandler ( 'Package:givePlayerPackage', root, givePlayerPackage )

addEvent ( 'Package:openPack', true )
addEventHandler ( 'Package:openPack', root,
function ( package )
    if package then
        package = tonumber ( package )
        local account = getAccountName ( getPlayerAccount ( source ) )
        local result = dbPoll(dbQuery(db, "SELECT * FROM Packages WHERE account = ? AND number = ?", account, package), -1)
        if type(result) == "table" and #result ~= 0 and tonumber ( result[1]["ammount"] ) > 0 then
            if package == 1 then
                packType[source] = math.random ( #Lucky1 )
                giveReward ( source, Lucky1, packType[source] )
            elseif package == 2 then
                packType[source] = math.random ( #Lucky2 )
                giveReward ( source, Lucky2, packType[source] )
            elseif package == 3 then
                packType[source] = math.random ( #Lucky3 )
                giveReward ( source, Lucky3, packType[source] )
            end
            dbExec(db, "UPDATE Packages SET ammount = ? WHERE account = ? AND number = ?", tonumber ( result[1]["ammount"] - 1 ), account, package)
        end
    end
end)

function giveReward ( player, pType, random )
    if pType[random][2] == 'Car' then
        local model = CarIDs[math.random ( #CarIDs )]
        triggerEvent("GivePlayerVehicle", player, getPlayerName ( player ), getAccountName ( getPlayerAccount ( player ) ), model, 0, player)
        outPut ( ' You won '..getVehicleNameFromModel ( model )..' from your lucky packages.', player )
    elseif pType[random][2] == 'kMoney' then
        local myG = getElementData(player,"Gold") or 0
        setElementData(player,"Gold",tonumber(myG+pType[random][3]))
        outPut ( ' You won '..pType[random][3]..' K money from your lucky packages.', player )
    elseif pType[random][2] == 'Weapon' then
        local rnd = math.random ( 3 )
        if rnd == 1 then
            giveWeapon ( player, 36, 20, true )
        elseif rnd == 2 then
            giveWeapon ( player, 35, 20, true )
        elseif rnd == 3 then
            giveWeapon ( player, 38, 9999, true )
        end
        setPedStat ( player, 24, 1000 )
        setElementHealth ( player, 200 )
        outPut ( ' You won '..getPedTotalAmmo ( player )..' Ammo of '..getWeaponNameFromID ( getPedWeapon ( player ) )..' and 200HP from your lucky packages.', player )
    elseif pType[random][2] == 'Launcher' then
        setElementData(player,"CancelData",true)
        local myG = getElementData(player,"GLA") or 0
        if tonumber(myG) < tonumber ( pType[random][3] ) then
            setElementData(player,"GLA",tonumber(pType[random][3]))
        end
        setElementData(player,"CancelData",nil)
        outPut ( ' You won '..pType[random][3]..' Launchers from your lucky packages.', player )
    elseif pType[random][2] == 'Health' then
        setPedStat ( player, 24, 1000 )
        setElementHealth ( player, 200 )
        outPut ( ' You won 200HP from your lucky packages.', player )
    elseif pType[random][2] == 'Money' then
        local pMoney = getPlrMoney ( player )
        setElementData(player,"Money", tonumber(pMoney+pType[random][3]))
        outPut ( ' You won '..pType[random][3]..'$ from your lucky packages.', player )
    elseif pType[random][2] == 'Exp' then
        local myG = getElementData(player,"XP") or 0
        setElementData(player,"XP",tonumber(myG+pType[random][3]))
        local myP = getElementData(player,"PXP") or 0
        setElementData(player,"PXP",tonumber(myP+pType[random][3]))
        outPut ( ' You won '..pType[random][3]..' Exp from your lucky packages.', player )
    elseif pType[random][2] == 'Gold' then
        -- idkkk #Nu9aiF
        outPut ( ' You are lucky , you get VIP weapons.', player )
    elseif pType[random][2] == 'VIP' then
        -- idkkk #Nu9aiF
        outPut ( ' OMG !!! , you won a VIP for 1 day.', player )
	elseif pType[random][2] == 'CarSkin' then
        local rnd = math.random ( #Skins )
        givePlayerCarSkin ( player, rnd )
        outPut ( ' You got a car skin, '..Skins[rnd][1], player )
    end
    random = nil
end

------------
-- USEFUL --
------------


addEventHandler ( "onPlayerWasted", getRootElement(),
function ( _, attacker )
    if attacker and isElement ( attacker) and getElementType ( attacker ) == 'player' and attacker ~= source then
        local randomm = math.random ( 1 )
        local _random = math.random ( 80 )
        if randomm == _random then
            givePlayerRandomPackage ( attacker )
        end
    end
end)



addEvent ( 'Package:getMyPackages', true )
addEventHandler ( 'Package:getMyPackages', root,
function ( )
    local account = getAccountName ( getPlayerAccount ( source ) )
    local result = dbPoll(dbQuery(db, "SELECT * FROM Packages WHERE account = ?", account), -1)
    if type(result) == "table" and #result ~= 0 and result[1]["account"] == account and tonumber ( result[1]["ammount"] ) > 0 then
        triggerEvent ( source, 'Package:addPackagesToGridList', source, result )
    end
end)



function getPlrMoney (plr)
    if plr then
        local data = getElementData(plr,"Money")
        if data then
            return tonumber(data)
        end 
    end
    return tonumber(0)
end

function givePlayerCarSkin ( player, skin )
    if Skins[skin] then
        local account = getAccountName ( getPlayerAccount ( player ) )
        local result = dbPoll(dbQuery(db, "SELECT * FROM CarSkins WHERE account = ? AND skin = ? ", account, skin), -1)
        if type(result) == "table" and #result == 0 then
            dbExec ( db, "INSERT INTO CarSkins VALUES (?,?,?)", account, skin, Skins[skin][1])
        end
    end
end

addEvent ( 'VehicleSkin:getMySkins', true )
addEventHandler ( 'VehicleSkin:getMySkins', root,
function ()
    local account = getAccountName ( getPlayerAccount ( source ) )
    local result = dbPoll(dbQuery(db, "SELECT * FROM CarSkins WHERE account = ?", account), -1)
    if result then
        triggerClientEvent ( source, 'onGetMySkins', source, result )
    end
end)
-----------------------------------

function setVehicleSkin ( vehicle, skin )
    local owner = getElementData(vehicle, "Owner")
    local id = getElementData ( vehicle, 'ID')
    if owner and owner == source and id then
        for i,v in ipairs ( VehiclesSkins ) do
            if v[1] == id then
                table.remove ( VehiclesSkins, i )
            end
        end
        table.insert ( VehiclesSkins, { id, skin } )
        triggerClientEvent ( 'VehicleSkin:setVehicleSkin', source, vehicle, skin )
    end
end
addEvent ( 'setVehicleSkin', true )
addEventHandler ( 'setVehicleSkin', root, setVehicleSkin)

addEvent ( 'getAllCarsSkins', true )
addEventHandler ( 'getAllCarsSkins', root,
function ()
    if VehiclesSkins then
        outputChatBox ( 'trigger')
        triggerClientEvent ( source, 'VehicleSkin:getSkinsTable', source, VehiclesSkins )
    end
end)

addEvent ( 'resetVehicleSkin', true )
addEventHandler ( 'resetVehicleSkin', root,
function ( vehicle )
    if vehicle then
        local owner = getElementData(vehicle, "Owner")
        local id = getElementData ( vehicle, 'ID')
        if owner and owner == source and id then
            for i,v in ipairs ( VehiclesSkins ) do
                if v[1] == id then
                    table.remove ( VehiclesSkins, i )
                    triggerClientEvent ( 'removeSkin', source, vehicle )
                    return
                end
            end
        end
    end
end)

addEventHandler("onElementDataChange",getRootElement(),
function (dataName,oldValue)
    if getElementType ( source ) == 'vehicle' then
        local owner = getElementData ( source, 'Owner')
        local id = getElementData ( source, 'ID')
        if (dataName == "Owner" and owner and isElement ( owner ) ) then
            for i,v in ipairs ( VehiclesSkins ) do
                if v[1] == id then
                    triggerClientEvent ( 'VehicleSkin:setVehicleSkin', source, source, v[2] )
                    return
                end
            end
        end
    end
end)

 

51 minutes ago, !#DesTroyeR_,) said:

وعليكم السلام ,

حط الكود طيب !

حطيت الكود

Share this post


Link to post
addCommandHandler ( source,'getP',
function ( )
givePlayerRandomPackage ( root )
givePlayerRandomPackage ( source )
outPut ( ' Your Get Package To all', root )
triggerClientEvent ( source, 'Package:Random', source )
end)

 

Share this post


Link to post
2 hours ago, #BrosS said:

addCommandHandler ( source,'getP',
function ( )
givePlayerRandomPackage ( root )
givePlayerRandomPackage ( source )
outPut ( ' Your Get Package To all', root )
triggerClientEvent ( source, 'Package:Random', source )
end)

 

يعني كذا انت صلحتها ؟

Share this post


Link to post
Posted (edited)

بجربه ونشوف

23 minutes ago, #BrosS said:

ايه

تظهر لي كذا 

[20:29:52] [Gta-Mc]Packages\server.lua @ line 39: Bad argument @ 'addCommandHandler' [Expected staring at argument 1, got nill]

Client [20:29:52] [Gta-Mc]Packages\client.lua @ line 101: Bad argument @ 'guiStaticImageLoadImage' [Expected gui-element at argument 1, got nil] 

Client :

local screenW, screenH = guiGetScreenSize()
local alpha = 255
local img = "img/pack.png"
local wnd = {}

function render ()
    dxDrawImage(screenW - 252 - 10, (screenH - 225) / 2, 252, 225, img, 0, 0, 0, tocolor(255, 255, 255, alpha), false)
end

addEvent ( 'Package:Random', true )
addEventHandler ( 'Package:Random', root,
function ()
    if sound then return end
    img = "img/pack.png"
    addEventHandler("onClientRender", root, render)
    sound = playSound ( 'sound.mp3' )
    setTimer (
        function ()
            local rnd = math.random ( 100 )
            if rnd == 32 and rnd == 16 and rnd == 11 and rnd == 48 then
                if isElement ( sound ) then destroyElement ( sound ) end
                pack = 1
                img = "img/lucky"..pack..".png"
                sound = playSound ( 'sound2.mp3' )
                setTimer ( function () if isElement ( sound ) then destroyElement ( sound ) end end, 2000, 1 )
            elseif rnd >= 1 and rnd <= 50 and rnd ~= 48 and rnd ~= 32 and rnd ~= 11 and rnd ~= 16 then
                if isElement ( sound ) then destroyElement ( sound ) end
                pack = 2
                img = "img/lucky"..pack..".png"
                sound = playSound ( 'sound2.mp3' )
                setTimer ( function () if isElement ( sound ) then destroyElement ( sound ) end end, 2000, 1 )
            else
                if isElement ( sound ) then destroyElement ( sound ) end
                pack = 3
                img = "img/lucky"..pack..".png"
                sound = playSound ( 'sound2.mp3' )
                setTimer ( function () if isElement ( sound ) then destroyElement ( sound ) end end, 2000, 1 )
            end
            setTimer(function() removeEventHandler("onClientRender", root, render) sound = nil end, 3000, 1) 
            triggerServerEvent ( 'Package:givePlayerPackage', localPlayer, pack, 1 )
        end
    ,6000, 1 )
end)

addEventHandler("onClientResourceStart", resourceRoot,
function()
    local screenW, screenH = guiGetScreenSize()
    wnd.main = guiCreateWindow((screenW - 380) / 2, (screenH - 298) / 2, 380, 298, "[ Gta-Mc ] : My Packages", false)
    guiWindowSetMovable(wnd.main, false)
    guiWindowSetSizable(wnd.main, false)
    guiSetVisible ( wnd.main, false )
        
    wnd.grid = guiCreateGridList(10, 28, 189, 257, false, wnd.main)
    guiGridListAddColumn(wnd.grid, "Package", 0.5)
    guiGridListAddColumn(wnd.grid, "Ammount", 0.3)
        
  --  wnd.pack = guiCreateStaticImage(221, 49, 137, 168, "img/pack.png", false, wnd.main)
    wnd.open = guiCreateButton(212, 251, 71, 34, "Open the pack", false, wnd.main)
    guiSetAlpha(wnd.open, 0.78)
    guiSetFont(wnd.open, "default-bold-small")
    wnd.close = guiCreateButton(293, 251, 71, 34, "Close", false, wnd.main)
    guiSetAlpha(wnd.close, 0.78)
    guiSetFont(wnd.close, "default-bold-small")    
end)

bindKey("F7","down",
function ()
    guiSetVisible ( wnd.main, true )
    showCursor ( true )
    guiBringToFront ( wnd.main )
    triggerServerEvent ( 'Package:getMyPackages', localPlayer )
end)

addEventHandler ( 'onClientGUIClick', resourceRoot,
function (button, state)
    if button == "left" and state == "up" then
        if _bug then 
            return 'Stuuuuuupid :Pp' 
        end
        if source == wnd.close then
            guiSetVisible ( wnd.main, false )
            showCursor ( false )
        elseif source == wnd.open then
            if ( guiGridListGetSelectedItem ( wnd.grid ) ~= -1 ) then 
            local ammount = tonumber ( guiGridListGetItemText ( wnd.grid, guiGridListGetSelectedItem ( wnd.grid ), 2 ) )
                if ammount > 1 then
                    triggerServerEvent ( 'Package:openPack', localPlayer, guiGridListGetItemData ( wnd.grid, guiGridListGetSelectedItem ( wnd.grid ), 1 ) )
                    guiGridListSetItemText ( wnd.grid, guiGridListGetSelectedItem ( wnd.grid ), 2, tostring ( ammount - 1 ), false, false )
                else
                    triggerServerEvent ( 'Package:openPack', localPlayer, guiGridListGetItemData ( wnd.grid, guiGridListGetSelectedItem ( wnd.grid ), 1 ) )
                    guiGridListRemoveRow ( wnd.grid, guiGridListGetSelectedItem ( wnd.grid ) )
                end
                guiSetEnabled ( wnd.open, false )
                setTimer ( guiSetEnabled, 5000, 1, wnd.open, true )
            end
        elseif source == wnd.grid then
            local id = guiGridListGetItemData ( wnd.grid, guiGridListGetSelectedItem ( wnd.grid ), 1 )
            if id and (fileExists("img/lucky"..id..".png")) then
                guiStaticImageLoadImage(wnd.pack, "img/lucky"..id..".png")
            else
                guiStaticImageLoadImage(wnd.pack, "img/pack.png")
            end
        end
    end
end)

addEvent ( 'Package:addPackagesToGridList', true )
addEventHandler ( 'Package:addPackagesToGridList', root,
function ( packages )
    if packages then
        guiGridListClear ( wnd.grid )
        for i,v in ipairs ( packages ) do
            local row = guiGridListAddRow ( wnd.grid )
            local type
            if v['number'] == 1 then
                type = 'Gold'
            elseif v['number'] == 2 then
                type = 'Silver'
            elseif v['number'] == 3 then
                type = 'Bronze'
            end
            guiGridListSetItemText ( wnd.grid, row, 1, tostring ( type ), false, false )
            guiGridListSetItemText ( wnd.grid, row, 2, tostring ( v['ammount'] ), false, false )
            guiGridListSetItemData ( wnd.grid, row, 1, tostring ( v['number'] ) )
        end
    end
end)   


_bug = false 
function handleInterrupt( status )
    if ( status == 0 ) then
        _bug = true
    elseif ( status == 1 ) then
        _bug = false
    end
end
addEventHandler( "onClientPlayerNetworkStatus", root, handleInterrupt)

 

Edited by fargot..

Share this post


Link to post
addCommandHandler ( 'getP',
function ( player )
givePlayerRandomPackage ( root )
givePlayerRandomPackage ( player )
outPut ( ' Your Get Package To all', root )
triggerClientEvent ( player, 'Package:Random', player )
end)

لول اسف جرب نسيت كيف يستخدمو الوظيفة

Share this post


Link to post
3 hours ago, #BrosS said:

addCommandHandler ( 'getP',function ( player )givePlayerRandomPackage ( root )givePlayerRandomPackage ( player )outPut ( ' Your Get Package To all', root )triggerClientEvent ( player, 'Package:Random', player )end)

لول اسف جرب نسيت كيف يستخدمو الوظيفة

بروس الحين اقدر اوزع بس عند ما اوزع يطلع دي 

Server [00:48:35] [Gta-Mc]Packages\server.lua @ line 35: Bad argument @ 'getPlayerAccount' [Expected player or console at argument 1, got root]

و دي كمان 

Client [00:52:52] [Gta-Mc]Packages\client.lua @ line 101: Bad argument @ 'guiStaticImageLoadImage' [Expected gui-element at argument 1, got nil]

ملف الكلينت هو فوق شوف الاكود فوق 

Share this post


Link to post

@fargot..

addCommandHandler ( 'getP',
function ( player )
for k,v in ipairs(getElementsByType("player")) do
givePlayerRandomPackage ( v )
end
outPut ( ' Your Get Package To all', player )
triggerClientEvent ( player, 'Package:Random', player )
end)

وسطر 57 شيل ال --
وخلاص

Share this post


Link to post
8 hours ago, Rakan# said:

@fargot..


addCommandHandler ( 'getP',function ( player )for k,v in ipairs(getElementsByType("player")) dogivePlayerRandomPackage ( v )endoutPut ( ' Your Get Package To all', player )triggerClientEvent ( player, 'Package:Random', player )end)

وسطر 57 شيل ال --
وخلاص

سطر 57 بتاع الكلينت ولا سيرفير ؟

Share this post


Link to post
Posted (edited)

 

11 hours ago, fargot.. said:

Client [00:52:52] [Gta-Mc]Packages\client.lua @ line 101: Bad argument @ 'guiStaticImageLoadImage' [Expected gui-element at argument 1, got nil]

في الكلينت انت حاط 

addEventHandler("onClientResourceStart", resourceRoot,
function()
    local screenW, screenH = guiGetScreenSize()
    wnd.main = guiCreateWindow((screenW - 380) / 2, (screenH - 298) / 2, 380, 298, "[ Gta-Mc ] : My Packages", false)
    guiWindowSetMovable(wnd.main, false)
    guiWindowSetSizable(wnd.main, false)
    guiSetVisible ( wnd.main, false )
        
    wnd.grid = guiCreateGridList(10, 28, 189, 257, false, wnd.main)
    guiGridListAddColumn(wnd.grid, "Package", 0.5)
    guiGridListAddColumn(wnd.grid, "Ammount", 0.3)
        
  	wnd.pack = guiCreateStaticImage(221, 49, 137, 168, "img/pack.png", false, wnd.main)
    wnd.open = guiCreateButton(212, 251, 71, 34, "Open the pack", false, wnd.main)
    guiSetAlpha(wnd.open, 0.78)
    guiSetFont(wnd.open, "default-bold-small")
    wnd.close = guiCreateButton(293, 251, 71, 34, "Close", false, wnd.main)
    guiSetAlpha(wnd.close, 0.78)
    guiSetFont(wnd.close, "default-bold-small")    
end)

انت حاط -- على الصوره الي تبي تستبدلها بدال الصوره

شيل ال -- بس

Edited by salh

Share this post


Link to post
Posted (edited)
9 minutes ago, salh said:

 

 في الكلينت انت حاط 


addEventHandler("onClientResourceStart", resourceRoot,function()    local screenW, screenH = guiGetScreenSize()    wnd.main = guiCreateWindow((screenW - 380) / 2, (screenH - 298) / 2, 380, 298, "[ Gta-Mc ] : My Packages", false)    guiWindowSetMovable(wnd.main, false)    guiWindowSetSizable(wnd.main, false)    guiSetVisible ( wnd.main, false )            wnd.grid = guiCreateGridList(10, 28, 189, 257, false, wnd.main)    guiGridListAddColumn(wnd.grid, "Package", 0.5)    guiGridListAddColumn(wnd.grid, "Ammount", 0.3)          	wnd.pack = guiCreateStaticImage(221, 49, 137, 168, "img/pack.png", false, wnd.main)    wnd.open = guiCreateButton(212, 251, 71, 34, "Open the pack", false, wnd.main)    guiSetAlpha(wnd.open, 0.78)    guiSetFont(wnd.open, "default-bold-small")    wnd.close = guiCreateButton(293, 251, 71, 34, "Close", false, wnd.main)    guiSetAlpha(wnd.close, 0.78)    guiSetFont(wnd.close, "default-bold-small")    end)

انت حاط -- على الصوره الي تبي تستبدلها بدال الصوره

شيل ال -- بس

تمام حليتها اعطيني الحين تاع دي 

Server [12:27:22] Packages\server.lua @ line 176: Bad argument @ 'triggerEvent' [Expected string at argument 1, got player]

Edited by fargot..

Share this post


Link to post
function givePlayerCarSkin ( player, skin )
    if Skins[skin] then
        local account = getAccountName ( getPlayerAccount ( player ) )
        local result = dbPoll(dbQuery(db, "SELECT * FROM CarSkins WHERE account = ? AND skin = ? ", account, skin), -1)
        if type(result) == "table" and #result == 0 then
            dbExec ( db, "INSERT INTO CarSkins VALUES (?,?,?)", account, skin, Skins[skin][1])
	end
end

كان فيه end

زايده

  • Confused 1

Share this post


Link to post

بدل السطر عندك الى

   triggerEvent ('Package:addPackagesToGridList', source, result )

 

Share this post


Link to post
2 minutes ago, Rakan# said:

بدل السطر عندك الى


   triggerEvent ('Package:addPackagesToGridList', source, result )

 

مشكور ركان مشكورين على المساعدة 

ركان في مشكلة بعد ما اوزع يقلي روح للانفيتوري تلقاه يعني اف 7 بعد ما اروح ما القى البكج في اف 7 عشان افتحه 

Share this post


Link to post
Just now, fargot.. said:

مشكور ركان مشكورين على المساعدة 

ركان في مشكلة بعد ما اوزع يقلي روح للانفيتوري تلقاه يعني اف 7 بعد ما اروح ما القى البكج في اف 7 عشان افتحه 

حط السيرفر والكلنت بعد تعديلاتك هنا

Share this post


Link to post
13 minutes ago, salh said:

كان فيه end

زايده

عندك اند ناقصة 

💀

  • Haha 1

Share this post


Link to post

غلط مطبعي (:

Share this post


Link to post

عدنان المود كان شغال تعال خاص وخذه ~

Share this post


Link to post

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.