Mostafa Raise Posted August 9, 2021 Share Posted August 9, 2021 Hello, my English is not good But try to read I want to have a script that creates a ped instead of someone when they leave the server And above that ped is written the reason for leaving the player from the server. As : Internet outage Normal exit Link to comment
CastiaL Posted August 9, 2021 Share Posted August 9, 2021 (edited) Server-Side --[[ Server-Side ]] local pedID = 0 -- Ped Character ID local deleteMin = 5 -- Ped will be deleted in 5 minutes local peds = {} function quitPlayer ( quitType ) x, y, z = getElementPosition(source) peds[source] = createPed(pedID, x, y, z) setElementData(peds[source], "info", getPlayerName(source):gsub ("#%x%x%x%x%x%x", "").." (" .. quitType .. ")") -- for exp. CastiaL (Timed Out) setTimer(function() destroyElement(peds[source]) peds[source] = nil end, deleteMin*60*1000, 1) end addEventHandler ( "onPlayerQuit", root, quitPlayer ) Client-Side --[[ Client-Side ]] local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() local maxrange = 30 local textSize = 1 -- Ped's Text Box Size function pedNametag() for _, ped in ipairs(getElementsByType("ped")) do if not getElementData(ped, "info") then return end local pedX,pedY,pedZ = getElementPosition(ped) local sx,sy = getScreenFromWorldPosition (pedX,pedY,pedZ) local cameraX,cameraY,cameraZ = getCameraMatrix() if sx then if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= maxrange then dxDrawText(getElementData(ped, "info"),sx,sy,screenWidth, screenHeight,tocolor ( 150, 150, 150, 255 ), textSize,"sans") end end end end addEventHandler("onClientRender",rootElement, pedNametag) Can You Test It Edited August 9, 2021 by CastiaL Link to comment
Mostafa Raise Posted August 9, 2021 Author Share Posted August 9, 2021 On 09/08/2021 at 06:51, CastiaL said: Server-Side --[[ Server-Side ]] local pedID = 0 -- Ped Character ID local deleteMin = 5 -- Ped will be deleted in 5 minutes local peds = {} function quitPlayer ( quitType ) x, y, z = getElementPosition(source) peds[source] = createPed(pedID, x, y, z) setElementData(peds[source], "info", getPlayerName(source):gsub ("#%x%x%x%x%x%x", "").." (" .. quitType .. ")") -- for exp. CastiaL (Timed Out) setTimer(function() destroyElement(peds[source]) peds[source] = nil end, deleteMin*60*1000, 1) end addEventHandler ( "onPlayerQuit", root, quitPlayer ) Client-Side --[[ Client-Side ]] local rootElement = getRootElement() local screenWidth, screenHeight = guiGetScreenSize() local maxrange = 30 local textSize = 1 -- Ped's Text Box Size function pedNametag() for _, ped in ipairs(getElementsByType("ped")) do if not getElementData(ped, "info") then return end local pedX,pedY,pedZ = getElementPosition(ped) local sx,sy = getScreenFromWorldPosition (pedX,pedY,pedZ) local cameraX,cameraY,cameraZ = getCameraMatrix() if sx then if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= maxrange then dxDrawText(getElementData(ped, "info"),sx,sy,screenWidth, screenHeight,tocolor ( 150, 150, 150, 255 ), textSize,"sans") end end end end addEventHandler("onClientRender",rootElement, pedNametag) Can You Test It hi This resource that you gave builds the ped But it does not enter the reason for leaving Link to comment
CastiaL Posted August 9, 2021 Share Posted August 9, 2021 (edited) i tested, the code is working Edited August 9, 2021 by CastiaL Link to comment
CastiaL Posted August 9, 2021 Share Posted August 9, 2021 -- Server-Side Update local pedID = 0 -- Ped Character ID local deleteMin = 5 -- Ped will be deleted in 5 minutes local peds = {} function quitPlayer ( quitType ) x, y, z = getElementPosition(source) peds[source] = createPed(pedID, x, y, z) setElementData(peds[source], "info", getPlayerName(source):gsub ("#%x%x%x%x%x%x", "").." (" .. quitType .. ")") -- for exp. CastiaL (Timed Out) setTimer(function(player) destroyElement(peds[player]) peds[player] = nil end, deleteMin*60*1000, 1, source) end addEventHandler ( "onPlayerQuit", root, quitPlayer ) i'm fix the code 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