WASSIm. Posted December 18, 2014 Share Posted December 18, 2014 Wouldn't it be muuuuuuuuuuuuuuuch easier to just save players in a database by serial, as you might even already do for stats, and take the number of rows as total visitors? No files, variables or other weird stuff involved. SELECT count(*) FROM TABLE; yes i already do it but he don't understand Link to comment
#RooTs Posted December 18, 2014 Author Share Posted December 18, 2014 Seriously, how hard can this be?!Server local serials = {} function onPlayerJoin() local serial = getPlayerSerial(source) if serials[serial] then else serials[serial] = serial end setElementData(source, "uniqueHits", CountHits) addEventHandler("onPlayerJoin",root,onPlayerJoin) function CountHits() local hits = 0 for i,v in pairs(serials) do hits = hits + 1 end return hits end function onResourceStart() local file = fileOpen("pc.txt") if file then size = fileGetSize(file) local buffer = fileRead(file,size) local serials = fromJSON(buffer) fileClose(file) end end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function onResourceStop() local file = fileCreate("pc.txt") fileWrite(file, toJSON(serials)) fileClose(file) end addEventHandler("onResourceStop", resourceRoot, onResourceStop) Client local uniqueHits = getElementData(getLocalPlayer(), "uniqueHits") Link to comment
Anubhav Posted December 18, 2014 Share Posted December 18, 2014 LekRoots, you are not doing anything. You are not even seeing the post of WASSim, if you don't understand, try to do it. You'll understand yourself, we are not going to MAKE SCRIPTS FOR YOU as you tell. Use the db* functions. Use getPlayerSerial and getPlayerName. triggerClientEvent dxDrawText It's so easy, you can make a HUD but not this? Seems that you are copying them from a site Link to comment
xeon17 Posted December 18, 2014 Share Posted December 18, 2014 It's so easy, you can make a HUD but not this? Seems that you are copying them from a site Come on , seriously? what so hard at creating HUDS? dxDrawImage dxDrawText dxDrawRectangle getElementHealth getPlayerMoney getPedTotalAmmo Can be done in 30 minutes.... Link to comment
Anubhav Posted December 18, 2014 Share Posted December 18, 2014 It's so easy, you can make a HUD but not this? Seems that you are copying them from a site Come on , seriously? what so hard at creating HUDS? dxDrawImage dxDrawText dxDrawRectangle getElementHealth getPlayerMoney getPedTotalAmmo Can be done in 30 minutes.... Ok just don't reply this, if you want to go at skype. No fights or offense please but it's not easy for everyone. I create every gui using guiGetScreenSize( which takes me alot of time ). And I'm not good in designing so much so it looks bullshit Link to comment
.:HyPeX:. Posted December 18, 2014 Share Posted December 18, 2014 Gosh you copied my code directly, didnt you look at how it works? anyone would realize instantly that it wont update anything else than the source.. If you cant do anything with this code, simply start learning yourself and stop wasting our time with no work from your side. local serials = {} function onPlayerJoin() local serial = getPlayerSerial(source) if serials[serial] then else serials[serial] = serial end for i,source in ipairs(getElementsByType("player")) do setElementData(source, "uniqueHits", CountHits) end addEventHandler("onPlayerJoin",root,onPlayerJoin) function CountHits() local hits = table.size(serials) return hits end function onResourceStart() local file = fileOpen("pc.txt") if file then size = fileGetSize(file) local buffer = fileRead(file,size) local serials = fromJSON(buffer) fileClose(file) end end addEventHandler("onResourceStart", resourceRoot, onResourceStart) function onResourceStop() local file = fileCreate("pc.txt") fileWrite(file, toJSON(serials)) fileClose(file) end addEventHandler("onResourceStop", resourceRoot, onResourceStop) function table.size(tab) local length = 0 for _ in pairs(tab) do length = length + 1 end return length end Link to comment
TAPL Posted December 18, 2014 Share Posted December 18, 2014 ^ setElementData(source, "uniqueHits", CountHits) CountHits isn't variable you should use (). setElementData(source, "uniqueHits", CountHits()) And local serials = fromJSON(buffer) Should be: serials = fromJSON(buffer) And still there's end missing. Link to comment
Ianito Posted December 18, 2014 Share Posted December 18, 2014 Try... local screenW,screenH = guiGetScreenSize() local resW, resH = 1280, 720 local x, y = (screenW/resW), (screenH/resH) local isVisible = false; function DXINFO () totalVisited = getElementData(root,"uniqueHits"); dxDrawText("Visitas "..tostring(totalVisited),x*310, y*660, x*310, y*40,tocolor(255, 255, 255,255),1.0,"default","left","top",false,false,false,true) end function toggleRadar() if isVisible then addEventHandler("onClientRender", root, DXINFO) else removeEventHandler("onClientRender", root, DXINFO) end isVisible = not isVisible end bindKey ("F11", "down", toggleRadar) addEventHandler("onClientRender", root, DXINFO) Server: (WASSIm.) addEventHandler("onResourceStart", resourceRoot, function () executeSQLQuery("CREATE TABLE IF NOT EXISTS players (name TEXT, serial TEXT)") for _, player in pairs(getElementsByType("player")) do local serial = getPlayerSerial(player) local result = executeSQLQuery("SELECT * FROM players WHERE serial=?", serial) if (#result == 0) then local name = getPlayerName(player) executeSQLQuery("INSERT INTO players(name,serial) VALUES(?,?)", name, serial) end end local count = #executeSQLQuery("SELECT * FROM players") if (count) and (tonumber(count)) then totalVisiters = count setElementData(root, "uniqueHits", totalVisiters) end end) addEventHandler("onPlayerJoin",root, function () local serial = getPlayerSerial(source) local result = executeSQLQuery("SELECT * FROM players WHERE serial=?", serial) if (#result == 0) then local name = getPlayerName(source) executeSQLQuery("INSERT INTO players(name,serial) VALUES(?,?)", name, serial) totalVisiters = totalVisiters+1 setElementData(root, "uniqueHits", totalVisiters) end end) Link to comment
#RooTs Posted December 18, 2014 Author Share Posted December 18, 2014 Try... local screenW,screenH = guiGetScreenSize() local resW, resH = 1280, 720 local x, y = (screenW/resW), (screenH/resH) local isVisible = false; function DXINFO () totalVisited = getElementData(root,"uniqueHits"); dxDrawText("Visitas "..tostring(totalVisited),x*310, y*660, x*310, y*40,tocolor(255, 255, 255,255),1.0,"default","left","top",false,false,false,true) end function toggleRadar() if isVisible then addEventHandler("onClientRender", root, DXINFO) else removeEventHandler("onClientRender", root, DXINFO) end isVisible = not isVisible end bindKey ("F11", "down", toggleRadar) addEventHandler("onClientRender", root, DXINFO) Server: (WASSIm.) addEventHandler("onResourceStart", resourceRoot, function () executeSQLQuery("CREATE TABLE IF NOT EXISTS players (name TEXT, serial TEXT)") for _, player in pairs(getElementsByType("player")) do local serial = getPlayerSerial(player) local result = executeSQLQuery("SELECT * FROM players WHERE serial=?", serial) if (#result == 0) then local name = getPlayerName(player) executeSQLQuery("INSERT INTO players(name,serial) VALUES(?,?)", name, serial) end end local count = #executeSQLQuery("SELECT * FROM players") if (count) and (tonumber(count)) then totalVisiters = count setElementData(root, "uniqueHits", totalVisiters) end end) addEventHandler("onPlayerJoin",root, function () local serial = getPlayerSerial(source) local result = executeSQLQuery("SELECT * FROM players WHERE serial=?", serial) if (#result == 0) then local name = getPlayerName(source) executeSQLQuery("INSERT INTO players(name,serial) VALUES(?,?)", name, serial) totalVisiters = totalVisiters+1 setElementData(root, "uniqueHits", totalVisiters) end end) @Iaan(~C.A.) Perfect Working, thanks Saving visits in sql, and not repeat the same visits of player sorry staff. more you(s) not understand my English 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