Jump to content

[ executeSQLQuery ] -- GridList


Recommended Posts

ما فهمت ._.,

تقصد انك حافظ قيمه مثلا حطيت كلام بالجريد وانت حافظه,؟

ومتى تبيها تطلع بالجريد ؟

مثلاً انا مسوي كود يحفظ فلوس اللاعب وابي اذا افتح الجريد ليست يطلع الإسم وجنبه المبلغ

Link to comment

؟؟

عارف كيف احفظ و عارف كيف اسوي القاعدة وعارف كل شيء ,

بس الي مو عارفه انه انا حافظ قيمه ابي اخليها في الجريد لست ,

مثلا :

Rank :                       Name :                    Money :       
1 -                     #[9MoD]Al-Ha[J]aRii       939432432 
Link to comment
اطرح تجربتكـ .

الي ابي اسويه انا هو :

Rank :   Account Name :  Money : 
1-       Alhajarii        88883 

Rank : ماعرفت حقه ولا شيء

Rank : انا ابيه الى 30 حق توب 30

---------------------------------

هذه الكود وهو مو كامل ذذ

addEventHandler("onPlayerLogin",resourceRoot,function() 
        local Account_ = getAccountName(getPlayerAccount(source)) 
        local RowAccount = executeSQLQuery("SELECT * FROM Save_Money_Account WHERE Account = '"..tostring(Account_).."'") 
        if ( #RowAccount ~= 0 )   then 
                triggerClientEvent ( source, "SetGridList", source, RowAccount[1]["Account"], RowAccount[1]["Money"] ) 
        end 
end) 
  

-- Client  
  
addEvent("SetGirdList", true) 
addEventHandler("SetGridList", root,  
function(Account,Money) 
local row = guiGridListAddRow(Grid) 
guiGridListSetItemText(Grid, row, 1, "Rank :" , false, false) -- هذا ماعرفت له 
guiGridListSetItemText(Grid, row, 2, tostring(Account) , false, false) 
guiGridListSetItemText(Grid, row, 3, tonumber(Money) , false, false) 
end) 
Link to comment
guiGridListAddColumn(Grid,"Rank :   ",0.10) 
guiGridListAddColumn(Grid,"Name :   ",0.10) 
guiGridListAddColumn(Grid,"Money:   ",0.10) 
  
addEvent("returnUp",true) 
addEventHandler("returnUp", root,function(Value) 
    guiGridListClear(Grid) 
    local Rank = 0 
    for _,v in ipairs (Value) do 
        Rank = Rank + 1 
        local row = guiGridListAddRow(Grid) 
        guiGridListSetItemText(Grid, row, 1,tonumber(Rank), false, false) 
        guiGridListSetItemText(Grid, row, 2,tostring(v.Name_), false, false) 
        guiGridListSetItemText(Grid, row, 3,tonumber(v.Money_), false, false) 
        if ( Rank == 30 ) then 
            break; 
        end 
    end 
end) 
  
local ReGet = true 
  
setTimer(function() 
    if ( ReGet == true ) then 
        if ( guiGetVisible(wndName) == true ) then 
            triggerServerEvent("Up",getLocalPlayer()) 
            ReGet = false 
            setTimer(function() 
                ReGet = true 
            end,5000,1) 
        end 
    end 
end,1000,0) 

addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()),function() 
    executeSQLQuery("CREATE TABLE IF NOT EXISTS SQL_xTop_Money (Name,Account,Money)") 
end) 
  
addEventHandler("onPlayerQuit",getRootElement(),function() 
    local Name = getPlayerName(source) 
    local Account = getAccountName(getPlayerAccount(source)) 
    local Money = getPlayerMoney(source) 
    if not ( Account ) then return end 
    local RowAccount = executeSQLQuery("SELECT * FROM SQL_xTop_Money WHERE Account = '"..tostring(Account).."'") 
    if ( type(RowAccount) == "table" and #RowAccount == 0 or not RowAccount) then 
        executeSQLQuery("INSERT INTO SQL_xTop_Money(Name,Account,Money) VALUES(?,?,?)",tostring(Name),tostring(Account),tonumber(Money)) 
    else 
        executeSQLQuery("UPDATE SQL_xTop_Money SET Name=?,Money=? WHERE Account=?",tostring(Name),tonumber(Money),tostring(Account)) 
    end 
end) 
  
function getAllMoneyUsers() 
    local Row = executeSQLQuery("SELECT * FROM SQL_xTop_Money") 
    if ( type (Row) == "table" and #Row == 0 or not Row ) then 
        return { } 
    else 
        return Row 
    end 
end 
  
addEvent("Up",true) 
addEventHandler("Up",root,function() 
    local TableUsersTop = {} 
    for _,v in ipairs(getAllMoneyUsers()) do 
        table.insert(TableUsersTop,{Name_ = v.Name,Money_ = v.Money,}) 
        table.sort(TableUsersTop,function (a,b) return (tonumber (a.Money_) or 0 ) > ( tonumber (b.Money_) or 0) end) 
    end 
    triggerClientEvent(source,"returnUp",source,TableUsersTop) 
end) 

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...