Sergey_Walter Posted June 14, 2013 Share Posted June 14, 2013 код на стороне клиента. gPhoneBook = guiCreateGridList(27, 302, 261, 158,false,iphoneMain) local colName = guiGridListAddColumn(gPhoneBook,"Имя",0.5) local colNumber = guiGridListAddColumn(gPhoneBook,"Номер",0.4) if contactList then local players = getElementsByType("player", getRootElement(), true ) for _, record in ipairs(contactList) do local row = guiGridListAddRow(gPhoneBook) guiGridListSetItemText(gPhoneBook, row, colName, record[1], false, false) guiGridListSetItemText(gPhoneBook, row, colNumber, record[2], false, false) for _, value in ipairs(players) do local foundPhone,_,foundPhoneNumber = exports.global:hasItem(value, 2, tonumber(record[2])) if tonumber(record[2]) == foundPhoneNumber then guiGridListSetItemColor(gPhoneBook, row, colName, 0, 255, 0) else guiGridListSetItemColor(gPhoneBook, row, colName, 255, 0, 0) end end end end Суть функции в том, чтоб если игрок на сервере то этот номер в записной книжке был зелёным и офф. красным! local foundPhone,_,foundPhoneNumber = exports.global:hasItem(value, 2, tonumber(record[2])) это функция узнаёт элемент чела по номеру и работает нормально! в record[2] записывается номер по циклу из книжки. Читал про local players = getElementsByType("player", getRootElement(), true ), true поставил! http://screenshot.su/show.php?img=26d88 ... 911326.jpg Заходит 2 игрок и т.д, циклом его номер телефона не находит, а мой видит. В чё проблемм мб? Link to comment
Sergey_Walter Posted June 15, 2013 Author Share Posted June 15, 2013 Фух, за пол дня додумался.. Сторона сервера: function getOnlinePhone(number, thePlayer) for _, value in ipairs(exports.pool:getPoolElementsByType("player")) do local logged = getElementData(value, "loggedin") if logged==1 then local foundPhone,_,foundPhoneNumber = exports.global:hasItem(value, 2, tonumber(number)) if foundPhone then triggerClientEvent("found", thePlayer, true, value) break else triggerClientEvent("found", thePlayer, false, value) break end end end end addEvent("getOnlinePhone", true) addEventHandler("getOnlinePhone", root, getOnlinePhone) for key, record in ipairs(contactList) do getOnlinePhone(record[2], client) end Сторона клиента: isOnlinePhone = {} foundElement = {} count = 0 function found(found, element) count = count + 1 isOnlinePhone[count] = found foundElement[count] = element end addEvent("found", true) addEventHandler("found", getRootElement(), found) gPhoneBook = guiCreateGridList(27, 302, 261, 158,false,iphoneMain) local colName = guiGridListAddColumn(gPhoneBook,"Имя",0.5) local colNumber = guiGridListAddColumn(gPhoneBook,"Номер",0.4) if contactList then for key, record in ipairs(contactList) do local row = guiGridListAddRow(gPhoneBook) guiGridListSetItemText(gPhoneBook, row, colName, record[1], false, false) guiGridListSetItemText(gPhoneBook, row, colNumber, record[2], false, false) if isOnlinePhone[key] then guiGridListSetItemColor(gPhoneBook, row, colName, 0, 255, 0) else guiGridListSetItemColor(gPhoneBook, row, colName, 255, 0, 0) end end end 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