Best-Killer Posted November 5, 2016 Share Posted November 5, 2016 Kills_ = {} addEventHandler('onResourceStart',resourceRoot,function () exports.NGSQL:db_exec("CREATE TABLE IF NOT EXISTS group_kills ( Name VARCHAR(20), Kills VARCHAR(40) )") end ) addEventHandler("onPlayerWasted",root,function ( _,Killer ) if ( Killer and Killer ~= source and getElementType(Killer) == "player" ) then local groupKills = exports.SAEGGroups:getPlayerGroup( Killer ) if not Kills_[Killer] then Kills_[Killer] = 0; end Kills_[Killer] = Kills_[Killer] + 1 local Sel = exports.NGSQL:db_exec("SELECT * FROM group_kills WHERE Name=?", groupKills) if ( type ( Sel ) == "table" and #Sel == 0 or not Sel ) then exports.NGSQL:db_exec(" INSERT INTO `group_kills` ( Name, Kills) VALUES(?,?)",groupKills,Kills_[Killer]) else exports.NGSQL:db_exec(" UPDATE group_kills SET Name =?, Kills =? ",groupKills,Kills_[Killer]) end end end) addEvent ( 'getData', true) addEventHandler ( 'getData', root, function() local db = exports.NGSQL:db_query("SELECT * FROM group_kills") if (type(db) ~= "table" or (type(db)=="table" and #db==0) or not db) then return end triggerClientEvent ( source, 'setData', source, db ) end ) local screenW, screenH = guiGetScreenSize() function killListGui() killgrid = guiCreateGridList(865, 590, 159, 178, false) guiGridListAddColumn(killgrid, "Gang", 0.5) guiGridListAddColumn(killgrid, "Kills", 0.5) guiSetAlpha(killgrid, 0.73) dxDrawRectangle(865, 590, 159, 178, tocolor(0, 0, 0, 180), false) guiSetVisible ( killgrid,true ) end addEventHandler("onClientResourceStart", resourceRoot,killListGui) dx = function() dxDrawRectangle(865, 590, 159, 178, tocolor(0, 0, 0, 180), false) end function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end bindKey('f4','down', function() if isEventHandlerAdded ("onClientRender", root,dx) then removeEventHandler("onClientRender", root,dx) else triggerServerEvent( 'getData', localPlayer ) addEventHandler("onClientRender", root,dx) end end) addEvent( 'setData', true ) addEventHandler ( 'setData', root, function(data) guiGridListClear ( killgrid ) table.sort ( data, function (a,b) return ( tonumber(a.Kills) or 0 ) > ( tonumber(b.Kills) or 0 )end) for k,v in ipairs ( data ) do local Row = guiGridListAddRow(killgrid) guiGridListSetItemText(killgrid,Row,1,v.name,false,false) guiGridListSetItemText(killgrid,Row,2,v.kills,false,false) if k == 10 then break end end end) 0 errors but group name & kills not added to database or showing in gui Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now