Jump to content

WiBox

Members
  • Posts

    234
  • Joined

  • Last visited

1 Follower

About WiBox

  • Birthday 27/02/2002

Details

  • Location
    Lebanon

Recent Profile Visitors

1,575 profile views

WiBox's Achievements

Trick

Trick (18/54)

12

Reputation

  1. Uh that's well too much If you want, you can make a log panel, insert inside it whatever you want? Something like ( exports.log:logSomething(player, "message") ) message can be whatever u want to log inside it error, message, chat, whatever
  2. I understood that you want to send to the admin whatever the player IS saying, and whatever is being said TO the player right? You can't tell if something is chatting to him directly, so I saved whatever is being said next him ? Chat with me private in your own native language and explain precisely what you need~
  3. I've no time left to explain to code, hope you got the logic behind it --Server side! local chats = {} local chatRange = 20 --Range to check who's near by the player local saveTimer, saveInterval = false, 50*1000 --Each 50 seconds, save chat to .txt local adminSpectating = {} function getPlayerAccountName(plr) return getAccountName(getPlayerAccount(plr)) end function getOnlineAdmins() local temp = {} --Temp table to insert all online admins in for index, players in ipairs (getElementsByType("player")) do --Loop over all players to check who's admin local account = getPlayerAccount(players) --Get player account if (account and not isGuestAccount(account)) then --Checking for any errors and whether the account is an guest account local accountName = getAccountName(account) --Get account name using the account local isAdmin = isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) --checking if user.accountName is added in Admin ACL group. if isAdmin then -- If he is.. table.insert(temp, players) --add him in table end end end return temp -- return it to get the table end function getPlayersInRange (plr, range) local x, y, z = getElementPosition(plr) local players = {} for index, value in ipairs(getElementsByType("player")) do if(plr and value)then --Usually we would check if plr ~= value so we don't add him to the list, although we want to save the 'plr' chat as well! local Sx, Sy, Sz = getElementPosition(value) local distance = getDistanceBetweenPoints3D(x, y, z, Sx, Sy, Sz) if(distance <= range)then table.insert(players, value) end end end return players end function onPlayerChat(msg, msgType) local type = "("..getPlayerName(source)..") " if (msgType == 0) then type = "/say: " elseif (msgType == 1) then type = "/me: " elseif (msgType == 2) then type = "/teamsay: " elseif (msgType == 3) then type = "private: " elseif (msgType == 4) then type = "internal: " else type = "unknown :" end for index, value in ipairs(getOnlineAdmins()) do if (adminSpectating[value] == source) then triggerClientEvent(value, "addToMemo", value, type.." "..msg) end end local accountName local playersInRange = getPlayersInRange(source, chatRange) for index, value in ipairs (playersInRange) do accountName = getPlayerAccountName(value) if (not chats[accountName]) then --We must make sure that the table chats[accountName] exists! chats[accountName] = {} end table.insert(chats[accountName], type.." "..msg) --Now all messages that the player(source) said are saved for everyone and himself! end --In the same sense, if you know want to check what the player said and whatever was said next him, are saved in that table end --But like that your server RAM will cry xD. So we'll save the chats in a TXT file! addEventHandler("onPlayerChat", root, onPlayerChat) --Once any player chats function loadChatsToMemo(admin, player) if (not admin or not player) then --If admin or player were not given return false --End the function end local accountName = getPlayerAccountName(player) if (not fileExists("chats/"..accountName..".txt")) then return triggerClientEvent(admin, "loadChatToMemo", admin, false) --If file doesn't exists, let the admin know! end local file = fileOpen("chats/"..accountName..".txt") local fileSize = fileGetSize(file) local fileContent = fileRead(file, fileSize) triggerClientEvent(admin, "loadChatsToMemo", admin, fileContent) end function saveChats() for index, value in ipairs (getElementsByType("player")) do local accountName = getPlayerAccountName(value) local file if (fileExists("chats/"..accountName..".txt")) then file = fileOpen("chats/"..accountName..".txt") else file = fileCreate("chats/"..accountName..".txt") end if (file) then for index2, messages in ipairs (chats[accountName]) do fileWrite(file, messages) end fileClose(file) chats[accountName] = {} --re empty the table once you save its data, so it doesn't duplicate. end end end saveTimer = setTimer(saveChats, saveInterval, 0) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end return false end function spectatePlr(admin, cmd, playerName) if (not isObjectInACLGroup("user."..getPlayerAccountName(admin), aclGetGroup("Admin")) then -- if the one who used the command isn't an Admin return false -- End the function end local player = getPlayerFromPartialName(playerName) --helps to find a player using a part of his name! if (not player) then return outputChatBox("ERROR: Please re-enter the player's nickname!", admin, 255, 150, 0) end setCameraTarget(admin, player) loadChatsToMemo(admin, player) adminSpectating[admin] = player end addCommandHandler("spectate", spectatePlr) function stopSpectate(admin) if (not isObjectInACLGroup("user."..getPlayerAccountName(admin), aclGetGroup("Admin") and adminSpectating[admin]) then return false -- if the one who used the command isn't an Admin, End the function end setCameraTarget(admin) --Retarget it to the admin triggerClientEvent(admin, "closeMemo", admin) adminSpectating[admin] = false end addCommandHandler("stopspectate", stopSpectate) --Client Side! local chatWindow function loadChatsToMemo(chats) if (not chatWindow) then local screenX, screenY = guiGetScreenSize() chatWindow = guiCreateWindow(screenX-300, 0, 300, 300, "Chats Record", false) chatMemo = guiCreateMemo(0, 0, 300, 300, "Loading...", false, chatWindow) guiWindowSetSizable(chatWindow, false) guiSetAlpha(chatWindow, 1) end showCursor(true) if (not chats) then return guiSetText(chatMemo, "This player has no chat record!") end guiSetText(chatMemo, chats) end addEvent("loadChatsToMemo", true) addEventHandler("loadChatsToMemo", localPlayer, loadChatsToMemo) function addToMemo(message) guiSetText(chatMemo, guiGetText(chatMemo).."\n"..addToMemo) end addEvent("addToMemo", true) addEventHandler("addToMemo", localPlayer, addToMemo) function closeMemo() guiSetVisible(chatWindow, false) showCursor(false) end addEvent("closeMemo", true) addEventHandler("closeMemo", localPlayer, closeMemo) I didn't test it, but that should do the job?
  4. It's close to what I need, I'll remove "AlwaysOnTop" once the focused window isn't the close button window. Thanks a lot mate!
  5. Is there any other scripts running? Maybe there're other scripts enabling these options?
  6. No, of course not. When you use addEventHandler with onChatMessage event, each time someone use /say /teamsay or /me it will automatically trigger onChatMessage event handler, means you have to use it only once. Just like the code I've send above. function getOnlineAdmins() local temp = {} --Temp table to insert all online admins in for index, players in ipairs (getElementsByType("player")) do --Loop over all players to check who's admin local account = getPlayerAccount(players) --Get player account if (account and not isGuestAccount(account)) then --Checking for any errors and whether the account is an guest account local accountName = getAccountName(account) --Get account name using the account local isAdmin = isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) --checking if user.accountName is added in Admin ACL group. if isAdmin then -- If he is.. table.insert(temp, players) --add him in table end end end return temp -- return it to get the table end function sendChatsToAdmins(message, by) local name local onlineAdmins = getOnlineAdmins() if (by and isElement(by) and getElementType(by) == "player") then name = getPlayerName(by).."(player)" elseif (by) then for index, resources in ipairs (getResources()) do if (by == resources) then name = getResourceName(by).."(resource)" end end else name = "Unknown: " end for index, admins in ipairs (onlineAdmins()) do outputChatBox(name..": "..message, admins, 255, 255, 255) --PlayerName(player): message or ResourceName(resource): message end end addEventHandler("onChatMessage", root, sendChatsToAdmins) Should be something like this? It isn't written perfectly but it should do the job
  7. Once a new map starts, maybe its script is turning on the blur again? Search for setPlayerBlurLevel and resetBlurLevel if you didn't find any of these two functions inside the map script, then there's something resetting/changing the blur level on map load...
  8. Whoever uses /say /teamsay or /me will trigger onChatMessage, you can't know if a player is writing the message to another player. If you made another chat system, add a trigger using triggerEvent
  9. I've actually tried it, I didn't see a close button.. I appreciate your help.
  10. First, get all online administrators using getOnlineAdmins then use event handler onPlayerChat function getOnlineAdmins() local temp = {} --Temp table to insert all online admins in for index, players in ipairs (getElementsByType("player")) do --Loop over all players to check who's admin local account = getPlayerAccount(players) --Get player account if (account and not isGuestAccount(account)) then --Checking for any errors and whether the account is an guest account local accountName = getAccountName(account) --Get account name using the account local isAdmin = isObjectInACLGroup("user."..accountName, aclGetGroup("Admin")) --checking if user.accountName is added in Admin ACL group. if isAdmin then -- If he is.. table.insert(temp, players) --add him in table end end end return temp -- return it to get the table end function sendChatsToAdmins(message, messageType) local onlineAdmins = getOnlineAdmins() local playerName = getPlayerName(source) --source is the one who sent a message. for index, admins in ipairs (onlineAdmins) do outputChatBox(playerName..": "..message, 255, 255, 255) --PlayerName: message end end addEventHandler("onPlayerChat", root, sendChatsToAdmins) Haven't tested it but it should work
  11. So first I tried on top-left: window = guiCreateWindow(800, 290, 500, 500, "Testing", false) closeBut = guiCreateButton(0, 0, 22, 19, "X", false, window) guiSetProperty(closeBut, "ClippedByParent", "False") guiSetProperty(closeBut, "AlwaysOnTop", "True") It looks like this: Now, I'm used to it on the right just like most operating systems, it just doesn't look right to me, so I tried taking it to the top right of the window.. window = guiCreateWindow(800, 290, 500, 500, "Testing", false) closeBut = guiCreateButton(800-22-5, 0, 22, 19, "X", false, window)--X position set to 800-button width guiSetProperty(closeBut, "ClippedByParent", "False") guiSetProperty(closeBut, "AlwaysOnTop", "True") It took me an hour to figure out that the button is that far above ? Now, I tried to see how I could make it go lower: window = guiCreateWindow(800, 290, 500, 500, "Testing", false) closeBut = guiCreateButton(160-19, 0, 22, 19, "X", false, window) --Here I tried to make it on one-quarter 1/4 guiSetProperty(closeBut, "ClippedByParent", "False") guiSetProperty(closeBut, "AlwaysOnTop", "True") Of course, I tried changing its 'Y' position, to end up between 2 numbers that were the reason I'm asking for aid: window = guiCreateWindow(800, 290, 500, 500, "Testing", false) closeBut = guiCreateButton(160-19, 8, 22, 19, "X", false, window)--Kept on one-quarter but with 'Y' position as 8 guiSetProperty(closeBut, "ClippedByParent", "False") guiSetProperty(closeBut, "AlwaysOnTop", "True") window = guiCreateWindow(800, 290, 500, 500, "Testing", false) closeBut = guiCreateButton(160-19, 9, 22, 19, "X", false, window)--Kept on one-quarter but with 'Y' position as 9 guiSetProperty(closeBut, "ClippedByParent", "False") guiSetProperty(closeBut, "AlwaysOnTop", "True") I don't want to use onClientRender for CPU usage and a button without parent means its on top of the guiRoot and if you open more than 1 window, those buttons will be on top of everything.. I tried using labels, worked perfectly. And the rest? Static images, edits, combo box, checkbox, radio button, grid list, memo, progress bar, scroll bar and tab panel have the same problem as the button takes the same position as all these pictures.. Anyone knows what should I do? I don't want to place the button on top-left neither use a label as button..
  12. Well, if I spawn peds in a certain range from the player in a way that would be inside his distance of render things will be solved, better than using setElementStreamable. Thank you
  13. I'm trying to make something like a NPC system, while using setPedControlState and setPedAnalogControlState (Ped was inside a vehicle) I've seen that, while the ped is inside my distance of render (setFarClipDistance) the control state works, but when the ped is outside it, he won't move.. So I used outputChatBox with getElementPosition ped when I'm far it gave the same coordination in another words the ped didn't move, isn't there a way to disable that? To make a ped drive a car even if he's not inside my distance of render?
  14. -- Wait my bad I forget to think about how triggerEvent works, thank you both!
  15. Dude that's not what I need I want to like function applySetting() -- when this function activate, all 'addEventHandler('onSettingsChange" .. will activate setSetting(slcSet, guiGetText(settingsEdit)) end addEventHandler("onClientGUIClick", apply, applySetting, false) ------------------------------------------------------------------------------------------------------------- --[[ of using triggerEvent I want to use 'addEventHandler' so when it apply settings all the eventhandler with "onSettingsChange" shall activate]] -- CLIENT SIDE (?) -- SECOND RESOURCE function set() if ( exports.settings:getSetting("setHaze") ) then setHaze( exports.settings:getSetting("setHaze") ) end end addEventHandler("onSettingsChange", root, set) I gave an example like replacing onPlayerLogin with onSettingsChange, when a player logins all event handler with onPlayerLogin will activate.. I want it like that when a function activate all the handlers will activate as well... Example, in addEventHandler("onWeaponFire", ...) How does it activate? when a random weapon has fire.. of course it's a function so it checks if a random weapon has fire, when a random weapon fire, all addEventHandler('onWeaponFire"..) in all resources will activate. Isn't that right? I want to do the same thing with onSettingsChange
×
×
  • Create New...