#Madara Posted August 2, 2015 Share Posted August 2, 2015 hi guys , i want to make script when Player his Account is added in table i create it and login then his Name will added in GridList and Near his name Online and if the Player is not in the server or logout his name will added in GridList and near his name Offline what functions i use ? Link to comment
#Madara Posted August 2, 2015 Author Share Posted August 2, 2015 getAccounts getAccountPlayer like this ? Client : addEvent("Insert",true) addEventHandler("Insert",root, function(Account) for i, v in ipairs(Account) do local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, v.Account, false, false) end end ) Server : Account = { {'Madara'}, } addEventHandler("onPlayerLogin",root, function(_,cAccount) for k , v in ipairs (Account) do local acc = getAccountPlayer(getAccounts(v)) if ( acc ) then triggerClientEvent("Insert",source,Account) end end end) Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Nope. for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then -- ACCOUNT IS ONLINE - Account: v, Player: getAccountPlayer(v) else -- ACCOUNT IS OFFLINE - Account: v, Player: Unable to get player, because he is offline. end end Link to comment
#Madara Posted August 2, 2015 Author Share Posted August 2, 2015 Nope. for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then -- ACCOUNT IS ONLINE - Account: v, Player: getAccountPlayer(v) else -- ACCOUNT IS OFFLINE - Account: v, Player: Unable to get player, because he is offline. end end like this ? Client : addEventHandler("onClientResourceStart", resourceRoot, function() Window = guiCreateWindow(488, 225, 376, 229, "Admin's Online", false) guiWindowSetSizable(Window, false) guiSetAlpha(Window, 1.00) guiSetVisible(Window,false) GridList = guiCreateGridList(9, 24, 357, 195, false, Window) local Admin = guiGridListAddColumn(GridList, "# Admin :", 0.5) local Status = guiGridListAddColumn(GridList, "# Status :", 0.5) local row = guiGridListAddRow(GridList) end ) addEvent("Online",true) addEventHandler("Online",root, function(Account) for i, v in ipairs(Account) do guiGridListSetItemText(GridList, row, Admin, v.Account, false, false) guiGridListSetItemText(GridList, row, Status, "Online", false, false) end end ) addEvent("Offline",true) addEventHandler("Offline",root, function(Account) for i, v in ipairs(Account) do guiGridListSetItemText(GridList, row, Admin, v.Account, false, false) guiGridListSetItemText(GridList, row, Status, "Offline", false, false) end end ) Server : Account = { {'Madara'}, } addEventHandler("onPlayerLogin",root, function() for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then triggerClientEvent("Online",source,Account) -- ACCOUNT IS ONLINE - Account: v, Player: getAccountPlayer(v) else triggerClientEvent("Offline",source,Account) -- ACCOUNT IS OFFLINE - Account: v, Player: Unable to get player, because he is offline. end end ) Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Put them in a table and send that table to client. local accounts = {} for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then accounts[v] = {getAccountPlayer(v), getAccountName(v)} else accounts[v] = {false, getAccountName(v)} end end And then client side loop through. for i, v in pairs(accounts) do if v[1] ~= false then -- Account is online, add it to grid list and set as online. Get his player name. local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, getPlayerName(v[1]).." - "..v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Online", false, false) else -- Account is offline, add it to grid list (?) and set as offline. Also get his account name instead name. local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Offline", false, false) end end You can use this for colors: guiGridListSetItemColor Link to comment
#Madara Posted August 2, 2015 Author Share Posted August 2, 2015 Put them in a table and send that table to client. local accounts = {} for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then accounts[v] = {getAccountPlayer(v), getAccountName(v)} else accounts[v] = {false, getAccountName(v)} end end And then client side loop through. for i, v in pairs(accounts) do if v[1] ~= false then -- Account is online, add it to grid list and set as online. Get his player name. local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, getPlayerName(v[1]).." - "..v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Online", false, false) else -- Account is offline, add it to grid list (?) and set as offline. Also get his account name instead name. local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Offline", false, false) end end You can use this for colors: guiGridListSetItemColor ah thank you , i should use triggerClientEvent right ? Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Yep. But first send a request from client side because if client doesn't load before server, it'll give you an error (Server triggered client side event but ... is not added client side) Link to comment
#Madara Posted August 2, 2015 Author Share Posted August 2, 2015 Yep. But first send a request from client side because if client doesn't load before server, it'll give you an error (Server triggered client side event but ... is not added client side) ok thank you very much . Link to comment
#Madara Posted August 2, 2015 Author Share Posted August 2, 2015 (edited) when i make trigger i got this problem debugscript : Server.lua:14 : attempt to index 'V' (a userdata vaule) addEvent("Online",true) addEventHandler("Online",root, function(accounts) if v[1] ~= false then local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, getPlayerName(v[1]).." - "..v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Online", false, false) end end ) addEvent("Offline",true) addEventHandler("Offline",root, function(accounts) for i, v in pairs(accounts) do if v[1] == false then local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Offline", false, false) end end end ) local accounts = { {'Madara'}, } addEvent("request",true) addEventHandler("request",root, function() setTimer(function() for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then accounts[v] = {getAccountPlayer(v), getAccountName(v)} triggerClientEvent("Online",source,accounts) else accounts[v] = {false, getAccountName(v)} triggerClientEvent("Offline",source,accounts) end end end,4000,0) end ) Edited August 2, 2015 by Guest Link to comment
GTX Posted August 2, 2015 Share Posted August 2, 2015 Do not put it in a timer and don't trigger it everytime you loop through accounts. Only 1 time. I gave you all info you need in my previous post... function requestAccounts() local accounts = {} for i, v in ipairs(getAccounts()) do if getAccountPlayer(v) then accounts[v] = {getAccountPlayer(v), getAccountName(v)} else accounts[v] = {false, getAccountName(v)} end end triggerClientEvent(source, "sendAccounts", source, accounts) end addEvent("requestData", true) addEventHandler("requestData", root, requestAccounts) addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("requestData", localPlayer) end ) function addAccountsToGridlist(accounts) for i, v in pairs(accounts) do if v[1] ~= false then -- Account is online, add it to grid list and set as online. Get his player name. local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, getPlayerName(v[1]).." - "..v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Online", false, false) else -- Account is offline, add it to grid list (?) and set as offline. Also get his account name instead name. local row = guiGridListAddRow(GridList) guiGridListSetItemText(GridList, row, Admin, v[2], false, false) guiGridListSetItemText(GridList, row, Status, "Offline", false, false) end end end addEvent("sendAccounts", true) addEventHandler("sendAccounts", root, addAccountsToGridlist) 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