Jump to content

Snakegold

Members
  • Posts

    130
  • Joined

  • Last visited

Details

  • Gang
    Avalan
  • Location
    Guengla
  • Occupation
    Nothing
  • Interests
    KWE

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Snakegold's Achievements

Poot-butt

Poot-butt (14/54)

6

Reputation

  1. Snakegold

    Help

    server side: function handlePlayerDamage(attacker, weapon, bodypart, loss) local victim = source if getElementHealth(victim) > 0 then setElementHealth(victim, getElementHealth(victim) - loss) if getElementHealth(victim) <= 0 then setElementData(victim, "isDead", true) killPed(victim) end cancelEvent() end end addEvent("onPlayerDamage", true) addEventHandler("onPlayerDamage", root, handlePlayerDamage) function isPlayerDead(player) return getElementData(player, "isDead") or false end client side: function onClientPlayerDamage(attacker, weapon, bodypart, loss) triggerServerEvent("onPlayerDamage", localPlayer, attacker, weapon, bodypart, loss) end addEventHandler("onClientPlayerDamage", root, onClientPlayerDamage) DEBUG: ERROR: Client "playername" triggered serverside event onPlayerDamage, but event is not marked as remotely triggerable
  2. Snakegold

    Help

    I mean when we both shoot each other, we both die. I want only one to die Example: https://imgur.com/a/1ajcl51 'The bug screenshot'
  3. Snakegold

    Help

    Hello community, could you please advise me on how to resolve the delay in determining player deaths? Specifically, when I shoot someone and they shoot me simultaneously, there are instances where both of us end up dying. I want to ensure that only one player dies in such situations.
  4. hello guys can you tell me how to reduce the col shape height? its very high https://imgur.com/UhKmJ8W
  5. Hi everyone, i have downloader system it loads all the vehicles/wps/skins correctly but fails to replace wheels why ? ["wheels/wheel17.dff"] = 1098, ["wheels/wheels.txd"] = 1098, ["wheels/wheel16.dff"] = 1097, ["wheels/wheels.txd"] = 1097, ["wheels/wheel15.dff"] = 1096, ["wheels/wheels.txd"] = 1096, ["wheels/wheel14.dff"] = 1085, ["wheels/wheels.txd"] = 1085, ["wheels/wheel13.dff"] = 1084, ["wheels/wheels.txd"] = 1084, ["wheels/wheel12.dff"] = 1083, ["wheels/wheels.txd"] = 1083, ["wheels/wheel11.dff"] = 1082, ["wheels/wheels.txd"] = 1082, ["wheels/wheel10.dff"] = 1081, ["wheels/wheels.txd"] = 1081, ["wheels/wheel9.dff"] = 1080, ["wheels/wheels.txd"] = 1080, ["wheels/wheel8.dff"] = 1079, ["wheels/wheels.txd"] = 1079, ["wheels/wheel7.dff"] = 1078, ["wheels/wheels.txd"] = 1078, ["wheels/wheel6.dff"] = 1077, ["wheels/wheels.txd"] = 1077, ["wheels/wheel5.dff"] = 1076, ["wheels/wheels.txd"] = 1076, ["wheels/wheel4.dff"] = 1075, ["wheels/wheels.txd"] = 1075, ["wheels/wheel3.dff"] = 1074, ["wheels/wheels.txd"] = 1074, ["wheels/wheel2.dff"] = 1073, ["wheels/wheels.txd"] = 1073, ["wheels/wheel1.dff"] = 1025, ["wheels/wheel1.txd"] = 1025, client side: local tempTable = {} local modCount = 0 local allModCount = 0 local keys = 0 local loadedMods = {} local modKeys = {} local currentFileNumber = 0 local currentFileName = "" function addFile(file, mod) if not downloadFile(file) then outputDebugString(file .. " not found!") else allModCount = allModCount + 1 modCache[file] = mod currentFileNumber = currentFileNumber + 1 currentFileName = file if not modKeys[mod] then keys = keys + 1 modKeys[mod] = keys end end end local sx,sy = guiGetScreenSize() local imgrot = 0 function renderGTAVLoading() local percent = math.floor((modCount / allModCount) * 100) if percent == 100 then allModCount = 0 modCount = 0 buggedVehs = 1 tempTable = {} modKeys = {} keys = 0 removeEventHandler("onClientRender", root, renderGTAVLoading) end local filePath = "cars" -- replace this with the actual file path local text = "Downloading (" .. filePath .. ", " .. currentFileName .. "... " .. percent .. "%) " local textWidth = dxGetTextWidth(text, 1, "bankgothic") imgrot = imgrot + 5 dxDrawImage(sx - textWidth / 2 - 195, 12, 20, 20, "loading.png", imgrot, 0, 0, nil, true) dxDrawText(text, (sx - textWidth) / 2, 14, (sx + textWidth) / 2, 20, tocolor(255, 255, 255, 255), 1, "bankgothic", "center", "top", false, false, true) end function restoreAllModels() -- teljes ram tisztítás local restored = {} for k,v in pairs(loadedMods) do if not restored[k] then engineRestoreModel(k) restored[k] = true end end loadedMods = {} for k,_ in pairs(vehicleParts) do for key,value in pairs(vehicleParts[k]) do if not restored[value] then engineRestoreModel(value) restored[value] = true end end end restored = nil end addCommandHandler("restoremodels", restoreAllModels) local startTimer function loadMods() startTimer = setTimer(function() if not isTransferBoxActive() then killTimer(startTimer) loadedMods = {} for k,v in pairs(modCache) do addFile(k, v) end for k,_ in pairs(vehicleParts) do for key,value in pairs(vehicleParts[k]) do addFile(key, value) end end addEventHandler("onClientRender", root, renderGTAVLoading) end end, 2000, 0) end addEventHandler("onClientResourceStart", resourceRoot, loadMods) addCommandHandler("be", loadMods) addCommandHandler("reloadcar", function(cmd, id) local id = tonumber(id) or 0 local i = 0 for k,v in pairs(modCache) do if v == id then addFile(k, v) i = i + 1 end end if i > 0 then addEventHandler("onClientRender", root, renderGTAVLoading) outputChatBox("[HL] #FFFFFFVehicle reloaded!", 0, 255, 0, true) else outputChatBox("[HL] #FFFFFFThere is no such vehicle in the list!", 0, 255, 0, true) end end) addEventHandler("onClientFileDownloadComplete", root, function(file,success) if source == resourceRoot then if success then local kit = string.sub(file, -4) if kit == ".dff" then local name = file:gsub(".dff", "") local mod = tonumber(modCache[file]) or 0 if mod < 1000 and mod > 0 then if modCache[name..".txd"] then if fileExists(name..".txd") then if not loadedMods[mod] then loadVehicleMod(name, mod, modKeys[mod]) end end else if not loadedMods[mod] then loadDFF(name,mod) end end modKeys[file] = nil end modCount = modCount + 1 elseif kit == ".txd" then local name = file:gsub(".txd", "") local mod = tonumber(modCache[file]) or 0 if mod < 1000 and mod > 0 then if modCache[name..".dff"] then if fileExists(name..".dff") then if not loadedMods[mod] then loadVehicleMod(name, mod, modKeys[mod]) end end else if not loadedMods[mod] then loadTXD(name, mod) end end modKeys[file] = nil end modCount = modCount + 1 end end end end) function loadVehicleMod(file, mod, key) if key then local bugged = buggedVehicles[mod] if not bugged then loadTXD(file, mod) loadDFF(file, mod) -- Use 'mod' instead of 'file' to maintain consistency else loadTXD(file, mod) setTimer(loadBuggedParts, 200 * key, 1, file, mod) end end end function loadTXD(file, mod) txd = fileExists(file .. ".txd") and engineLoadTXD(file .. ".txd") or false if txd then engineImportTXD(txd, mod) else outputDebugString("Failed to load TXD: " .. file .. ".txd for mod: " .. mod) outputDebugString("Full path: " .. file .. ".txd") end end function loadDFF(file, mod) file = file:gsub(".dff", "") dff = fileExists(file .. ".dff") and engineLoadDFF(file .. ".dff", mod) or false if dff then engineReplaceModel(dff, mod) loadedMods[mod] = true else outputDebugString("Failed to load DFF: " .. file .. ".dff for mod: " .. mod) outputDebugString("Full path: " .. file .. ".dff") end end function loadBuggedParts(file,mod) if vehicleParts[mod] then local dff = fileExists(file..".dff") and engineLoadDFF(file..".dff", mod) or false if dff then engineReplaceModel(dff, mod) loadedMods[mod] = true end for k,v in pairs(vehicleParts[mod]) do local dff = fileExists(k) and engineLoadDFF(k, mod) or false if dff then engineReplaceModel(dff, v) end end end end
  6. و لك ساعدوني ؟
  7. السلام عليكم شباب أنا عندي مود كلانات و هذا كود يسوي فحص للتاج و يضم اللاعب اذا هو موجود في الكلان function CL.CheckForTag(p, name) if not isElement(p) or getElementType(p) ~= "player" then return end local account = getPlayerAccount(p) if not isGuestAccount(account) then local q = executeSQLQuery("SELECT * FROM my_clans WHERE account=?", getAccountName(account)) if #q == 0 then return end local t = getPlayerTeam(p) if t then if countPlayersInTeam(t) < 2 then destroyElement(t) outputDebugString("Team destroyed for player " .. getPlayerName(p)) end setPlayerTeam(p, nil) local r, g, b = math.random(50, 200), math.random(50, 200), math.random(50, 200) setPlayerNametagColor(p, r, g, b) outputDebugString("Player " .. getPlayerName(p) .. " removed from team") end for i, v in ipairs(q) do if (string.find(name, "[" .. v.tag .. "]", 1, true) ~= nil) then local nt = getTeamFromName(v.clan) local q2 = executeSQLQuery("SELECT * FROM clans WHERE name=?", v.clan) if nt then setPlayerTeam(p, nt) outputDebugString("Player " .. getPlayerName(p) .. " joined clan " .. v.clan) else createTeam(q2[1].name, q2[1].r, q2[1].g, q2[1].b) setPlayerTeam(p, getTeamFromName(v.clan)) outputDebugString("Player " .. getPlayerName(p) .. " created and joined clan " .. v.clan) end end end triggerEvent("WS:Add", p) end end addEvent("CL:CheckForTag", true) addEventHandler("CL:CheckForTag", root, CL.CheckForTag) for i,k in ipairs(getElementsByType("player")) do local name = getPlayerName(k) CL.CheckForTag(k,name) end و المشلكة أني سويت مهمة و لما تنتهي المهمة بدي اللاعبين يرجعو للكلان الي تبعهم function GW.Close() GW["CLOSE"] = setTimer(function() local players = getPlayersInDimension(GW["D"]) if #players < 6 then GW["STATE"] = "Not Running" GW.Unload() GW.Start() for i, v in ipairs(getElementsByType("player")) do outputChatBox("• #FFFFFFGang War #CE1030event over!", v, 206, 16, 48, true) end for i, v in ipairs(players) do local name = getPlayerName(v) outputChatBox("[ERROR]: 3 Players are required in both gangs", v, 255, 0, 0, true) call(getResourceFromName("Core"), "spawnThePlayer", v, OLDS[v]) triggerEvent("CL:CheckForTag",v,name) setElementFrozen(v, false) removeElementData(v, "GW:Joined") triggerClientEvent(v, "GW:RemoveGUI", v) for k, z in ipairs(OLDW[v]) do giveWeapon(v, z, 500, true) end end return end for i, v in ipairs(getElementsByType("player")) do outputChatBox("• #FFFFFFGang War #CE1030event has started!", v, 206, 16, 48, true) end for i, v in ipairs(players) do setElementFrozen(v, false) end local t1p = getPlayersInTeam(getTeamFromName(GW["T1"])) local t2p = getPlayersInTeam(getTeamFromName(GW["T2"])) for i, v in ipairs(t1p) do local t = getPlayerTeam(v) local name = getTeamName(t) for k, z in ipairs(weapons[name]) do local id = z.id local ammo = z.ammo local current = z.current or false giveWeapon(v, id, ammo, current) local r, g, b = getTeamColor(t) local weaponName = wtb[id] triggerClientEvent(v, "NT:Add", v, "+ " .. weaponName, 1, "bankgothic", { 33, 117, 221, 255 }, true, { 0, 0, 0, 255 }, 5000) end end for i, v in ipairs(t2p) do local t = getPlayerTeam(v) local name = getTeamName(t) for k, z in ipairs(weapons[name]) do local id = z.id local ammo = z.ammo local current = z.current or false giveWeapon(v, id, ammo, current) local r, g, b = getTeamColor(t) local weaponName = wtb[id] triggerClientEvent(v, "NT:Add", v, "+ " .. weaponName, 1, "bankgothic", { 33, 117, 221, 255 }, true, { 0, 0, 0, 255 }, 5000) end end GW["STATE"] = "Running" -- Trigger the "CL:CheckForTag" event for each player to add them back to their clans for i, v in ipairs(players) do local name = getPlayerName(v) triggerEvent("CL:CheckForTag", v, name) outputDebugString("Triggered CL:CheckForTag for player " .. name) end end, 5000, 1) end سويت triggerEvent("CL:CheckForTag",v,name) بس ما اشتغلت
  8. السلام عليكم و رحمة الله هذا كود لما تكتب شي يطلع فوق رأس اللاعب شباب بدي اضهر رسالات التيم و عندي global chat بدي كمان رسالات الجلوبال تضهر كيف؟؟ local textsToDraw = {} local hideown local showtime local characteraddition local maxbubbles local showthebubbles = true function income(message, messagetype) if source ~= getLocalPlayer() or not hideown then -- Print the messagetype for debugging outputConsole("Received message with messagetype: " .. tostring(messagetype)) -- Include Global chat messages in the bubbles if messagetype == 2 or messagetype == "global" then addText(source, message, messagetype) else addText(source, message, messagetype) end end end function addText(source,message,messagetype) local notfirst = false for i,v in ipairs(textsToDraw) do if v[1] == source then v[4] = v[4] + 1 notfirst = true end end local infotable = {source,message,messagetype,0} table.insert(textsToDraw,infotable) if not notfirst then setTimer(removeText,showtime + (#message * characteraddition),1,infotable) end end function removeText(infotable) for i,v in ipairs(textsToDraw) do if v[1] == infotable[1] and v[2] == infotable[2] then for i2,v2 in ipairs(textsToDraw) do if v2[1] == v[1] and v[4] - v2[4] == 1 then setTimer(removeText,showtime + (#v2[2] * characteraddition),1,v2) end end table.remove(textsToDraw,i) break end end end function getTextsToRemove() for i,v in ipairs(textsToDraw) do if v[1] == source then removeText(v) end end end function handleDisplay() if showthebubbles then for i,v in ipairs(textsToDraw) do if isElement(v[1]) then if getElementHealth(v[1]) > 0 then local camPosXl, camPosYl, camPosZl = getPedBonePosition (v[1], 6) local camPosXr, camPosYr, camPosZr = getPedBonePosition (v[1], 7) local x,y,z = (camPosXl + camPosXr) / 2, (camPosYl + camPosYr) / 2, (camPosZl + camPosZr) / 2 -- local posx,posy = getScreenFromWorldPosition(x,y,z+0.25) local cx,cy,cz = getCameraMatrix() local px,py,pz = getElementPosition(v[1]) local distance = getDistanceBetweenPoints3D(cx,cy,cz,px,py,pz) local posx,posy = getScreenFromWorldPosition(x,y,z+0.020*distance+0.10) local elementtoignore1 = getPedOccupiedVehicle(getLocalPlayer()) or getLocalPlayer() local elementtoignore2 = getPedOccupiedVehicle(v[1]) or v[1] if posx and distance <= 45 and ( isLineOfSightClear(cx,cy,cz,px,py,pz,true,true,false,true,false,true,true,elementtoignore1) or isLineOfSightClear(cx,cy,cz,px,py,pz,true,true,false,true,false,true,true,elementtoignore2) ) and ( not maxbubbles or v[4] < maxbubbles ) then -- change this when multiple ignored elements can be specified local width = dxGetTextWidth(v[2],1,"default") dxDrawRectangle(posx - (3 + (0.5 * width)),posy - (2 + (v[4] * 20)),width + 5,19,tocolor(0,0,0,255)) dxDrawRectangle(posx - (6 + (0.5 * width)),posy - (2 + (v[4] * 20)),width + 11,19,tocolor(0,0,0,40)) dxDrawRectangle(posx - (8 + (0.5 * width)),posy - (1 + (v[4] * 20)),width + 15,17,tocolor(0,0,0,255)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (1 + (v[4] * 20)),width + 19,17,tocolor(0,0,0,40)) dxDrawRectangle(posx - (10 + (0.5 * width)),posy - (v[4] * 20) + 1,width + 19,13,tocolor(0,0,0,255)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (v[4] * 20) + 1,width + 23,13,tocolor(0,0,0,40)) dxDrawRectangle(posx - (12 + (0.5 * width)),posy - (v[4] * 20) + 4,width + 23,7,tocolor(0,0,0,255)) local r,g,b = 255,255,255 if v[3] == 2 then r,g,b = getTeamColor(getPlayerTeam(v[1])) end dxDrawText(v[2],posx - (0.5 * width),posy - (v[4] * 20),posx - (0.5 * width),posy - (v[4] * 20),tocolor(r,g,b,255),1,"default-bold","left","top",false,false,false) end end end end end end function getServerSettings() triggerServerEvent("onAskForBubbleSettings",getLocalPlayer()) end function saveSettings(settings) showtime = settings[1] characteraddition = settings[2] maxbubbles = settings[3] hideown = settings[4] addEvent("onChatbubblesMessageIncome",true) addEventHandler("onChatbubblesMessageIncome",getRootElement(),income) end function toggleBubblesOnOff() showthebubbles = not showthebubbles outputChatBox("Toggled chatbubbles " ..( not showthebubbles and "#FF0000off#FFFFFF." or "#00FF00on#FFFFFF." ),255,255,255,true) end addEventHandler("onClientPlayerQuit",getRootElement(),getTextsToRemove) addEventHandler("onClientRender",getRootElement(),handleDisplay) addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getServerSettings) addEvent("onBubbleSettingsReturn",true) addEvent("onChatIncome",true) addEventHandler("onBubbleSettingsReturn",getRootElement(),saveSettings) addCommandHandler("chatbubbles",toggleBubblesOnOff)
  9. السلام عليكم مشكلتي انو اللون مو شغال لصورة اللاعب العادي "Player" 'aclGroup: Everyone' local rr, gg, bb = call(getResourceFromName("Core"), "getReputationColor", reputation, class) dxDrawImage ( math.ceil(posW), math.ceil(sy - 32), 16, 16, "class/"..class..".png", 0, 0, 0, tocolor(rr, gg, bb, 255) ) هذا كود nametag و هذا كود الي يغير لون الصورة function getReputationColor(length, class) local r, g, b if class == "Player" then r, g, b = 0, 1, 1 else if (length < 0) then r, g, b = 1, 0, 0 elseif (length >= 0 and length < 10) then r,g,b = 1, 1, 1 elseif (length >= 10 and length < 76) then r, g, b = 0, (length + 76)/152 , 0 elseif (length >= 76 and length <= 150) then r, g, b = 0, (length + 76)/128, 1 elseif (length > 150 and length <= 225) then r, g, b = 0, (length + 225)/-300, 1 elseif (length > 225 and length <= 375) then r, g, b = (length + 375)/375,0,-(length + 375) elseif (length > 375 and length <= 425) then r, g, b = (length + 425)/425,0,-(length + 155),0 elseif (length > 425 and length <= 500) then r, g, b = 0,-(length + 500)-400,150 end return r*255, g*255, b*255 end و هذا سيرفر سايد الnametag addEventHandler( 'onPlayerLogin', root, function ( ) local account = getPlayerAccount( source ) if account and not isGuestAccount( account ) then local accountName = getAccountName( account ) if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Owner" ) ) then setElementData(source, "class", "Owner") return elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Root Developer" ) ) then setElementData(source, "class", "Root Dev") return elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Moderator" ) ) then setElementData(source, "class", "Moderator") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "SuperModerator" ) ) then setElementData(source, "class", "Super Moderator") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Administrator" ) ) then setElementData(source, "class", "Administrator") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Owner" ) ) then setElementData(source, "class", "Owner") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Community Manager" ) ) then setElementData(source, "class", "Community Manager") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Warden" ) ) then setElementData(source, "class", "Warden") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Quality Assurance" ) ) then setElementData(source, "class", "Quality Assurance") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Hero" ) ) then setElementData(source, "class", "Hero") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "VIP" ) ) then setElementData(source, "class", "Vip") elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Everyone" ) ) then setElementData(source, "class", "Player") end end end ) 0,1,1 المشكلة أنو لون الاعب ما يعطي لون و تصير الصورة سوداء
  10. loookin for a scripter to help me and i pay u 'paypal'
  11. rules table?معرف ال local rulesTable = { ['8.6'] = 'hacking/ddosing', ['8.7'] = 'scamming', ['9.3'] = 'leeching from the server', ['9.4'] = 'advertising', ['9.7'] = 'harming the server', } local ruleDescription = rulesTable[ruleNumber] هذا الكود كامل executeSQLQuery("CREATE TABLE IF NOT EXISTS punishments (serial TEXT, punishername TEXT, reason TEXT, duration NUMERIC, timestamp NUMERIC, muted INTEGER)") local rulesTable = { ['1.1'] = 'speaking non-english in global chat', ['2.1'] = 'annoying', ['3.1'] = 'offending', ['3.2'] = 'offending the server/staff', ['4.1'] = 'many short messages', ['4.2'] = 'crowding global chat with junk', ['4.3'] = 'congregating the chatbox', ['4.4'] = 'using console to spam commands', ['4.5'] = 'using binds to spam commands', ['5.1'] = 'disturbing no-dm players', ['5.2'] = 'disturbing other players while using nodm', ['5.3'] = 'disturbing busy staff', ['5.4'] = 'disturbing events', ['6.1'] = 'wearing offensive tag', ['6.2'] = 'wearing clan tag without permission', ['6.3'] = 'wearing staff related tags', ['6.4'] = 'impersonating', ['6.5'] = 'impersonating server staff', ['6.6'] = 'advertising via nick', ['7.1'] = 'account sharing', ['8.1'] = 'abusing IllusionRoam features', ['8.2'] = 'abusing GTA/MTA/IllusionRoam bugs', ['8.3'] = 'changing ip', ['8.4'] = 'xp farming', ['8.5'] = 'killing clanmates without tag', ['8.6'] = 'hacking/ddosing', ['8.7'] = 'scamming', ['9.3'] = 'leeching from the server', ['9.4'] = 'advertising', ['9.5'] = 'canceling donations', ['9.6'] = 'harming the server', ['9.7'] = 'harming the server', } function loadMuteDataFromDB() local query = executeSQLQuery("SELECT * FROM punishments WHERE muted = 1") for _, row in ipairs(query) do local playerSerial = row.serial local timestamp = tonumber(row.timestamp) local ruleNumber = row.reason local ruleDescription = rulesTable[ruleNumber] local currentTime = getRealTime().timestamp local remainingDuration = row.duration - (currentTime - timestamp) if remainingDuration > 0 then local player = findPlayerBySerial(playerSerial) if player then setPlayerMuted(player, true) mutedPlayers[playerSerial] = { duration = remainingDuration, startTime = timestamp } mutedPlayers[playerSerial].unmuteTimer = setTimer(unmutePlayer, remainingDuration * 1000, 1, playerSerial, "Console", ruleNumber, ruleDescription) outputChatBox("#FFFFFF".. getPlayerName(player) .. " #006600has been muted by #FFFFFFConsole. #006600[#FFFFFFReason: RULE #" .. ruleNumber .. ": " .. ruleDescription .. ". Duration: " .. formatTime(remainingDuration), getRootElement(), 255, 255, 255, true) end else executeSQLQuery("UPDATE punishments SET muted = 0, timestamp = 0 WHERE serial = ? AND reason = ?", playerSerial, ruleNumber) end end end loadMuteDataFromDB() loadMuteDataFromDB() local mutedPlayers = {} addEventHandler("onPlayerJoin", root, function() local player = source local playerName = getPlayerName(player) local playerSerial = getPlayerSerial(player) local query = executeSQLQuery("SELECT * FROM punishments WHERE serial = ? ORDER BY duration DESC LIMIT 1", playerSerial) if query and #query > 0 then local row = query[1] local totalDuration = tonumber(row.duration) local ruleNumber = row.reason local ruleDescription = rulesTable[ruleNumber] local currentTime = getRealTime().timestamp local timestamp = tonumber(row.timestamp) local remainingDuration = totalDuration - (currentTime - timestamp) if remainingDuration <= 0 then executeSQLQuery("DELETE FROM punishments WHERE serial = ? AND punishername = ? AND reason = ?", playerSerial, row.punishername, row.reason) else setElementData(player,"muted", true) setPlayerMuted(player, true) mutedPlayers[playerSerial] = { duration = remainingDuration, startTime = timestamp } mutedPlayers[playerSerial].unmuteTimer = setTimer(unmutePlayer, remainingDuration * 1000, 1, playerSerial, "Console", ruleNumber, ruleDescription) end end end) function findPlayerByPartialName(partialName) local matchedPlayer = nil for _, player in ipairs(getElementsByType("player")) do local playerName = getPlayerName(player) if string.find(playerName:lower(), partialName:lower()) then if matchedPlayer then return nil else matchedPlayer = player end end end return matchedPlayer end function handlePunishment(punisherName, partialName, ruleNumber) local targetPlayer = findPlayerByPartialName(partialName) if not isElement(targetPlayer) or getElementType(targetPlayer) ~= "player" then outputChatBox("• Player not found", source, 255, 0, 0, true) return end local ruleDescription = rulesTable[ruleNumber] if not ruleDescription then outputConsole("No description found for rule number: " .. ruleNumber) ruleDescription = "Unknown Rule" end local reputation = getElementData(targetPlayer, "Reputation") or 0 outputConsole("Rule Number: " .. ruleNumber) outputConsole("Rule Description: " .. tostring(ruleDescription)) if ruleNumber == '1.1' or ruleNumber == '2.1' or ruleNumber == '3.1' or ruleNumber == '3.2' then local duration = calculateMuteDuration(reputation, ruleNumber) mutePlayer(targetPlayer, punisherName, ruleNumber, ruleDescription, duration) setTimer(unmutePlayer, duration * 1000, 1, getPlayerSerial(targetPlayer), punisherName, ruleNumber, ruleDescription) elseif ruleNumber == '5.1' or ruleNumber == '5.2' or ruleNumber == '5.3' or ruleNumber == '5.4' or ruleNumber == '6.2' or ruleNumber == '6.4' or ruleNumber == '8.1' or ruleNumber == '8.2' then kickPlayer(targetPlayer, punisherName, ruleDescription) local playerName = getPlayerName(targetPlayer) if playerName then outputChatBox("#00FF00" .. playerName .. " has been kicked by #FFFFFF" .. punisherName .. " #006600[#FFFFFFReason: " .. ruleDescription .. "#006600]", getRootElement(), 255, 255, 255, true) else outputChatBox("• Failed to get player name for kick message.", source, 255, 0, 0, true) end else outputChatBox("• Invalid rule number", source, 255, 0, 0, true) return end end function kickPlayer(player, punisherName, ruleDescription) local playerName = getPlayerName(player) if not isElement(player) or getElementType(player) ~= "player" then outputConsole("Invalid player element in kickPlayer function.") return end outputChatBox("#00FF00" .. playerName .. " has been kicked by #FFFFFF" .. punisherName .. " #006600[#FFFFFFReason: " .. ruleDescription .. "#006600]", getRootElement(), 255, 255, 255, true) kickPlayer(player, "Kicked: " .. ruleDescription) -- Kick the player with a reason end function calculateMuteDuration(reputation, ruleNumber) if ruleNumber == '1.1' then if reputation <= -150.00 then return 3600 -- 1 hour elseif reputation <= -100.00 then return 2400 -- 2 hours elseif reputation <= -50.00 then return 1200 -- 1 hour elseif reputation <= -15.00 then return 600 -- 10 minutes elseif reputation >= 75.00 then return 300 -- 5 minutes else return 300 -- end elseif ruleNumber == '2.1' then if reputation <= -150.00 then -- return 7200 -- 2 hours elseif reputation <= -100.00 then return 3600 -- 1 hour elseif reputation <= -50.00 then return 1800 -- 30 minutes elseif reputation <= -15.00 then return 600 -- 10 minutes elseif reputation >= 75.00 then return 300 -- 5 minutes else return 600 end elseif ruleNumber == '3.1' then if reputation <= -200.00 then return 14400 -- 2 hours elseif reputation <= -100.00 then return 7200 -- 1 hour elseif reputation <= -50.00 then return 3600 -- 30 minutes elseif reputation <= -15.00 then return 3600 -- 10 minutes elseif reputation >= 75.00 then return 1200 -- 5 minutes else return 600 end elseif ruleNumber == '3.2' then if reputation <= -150.00 then return 28800 -- 2 hours elseif reputation <= -100.00 then return 14400 -- 1 hour elseif reputation <= -15.00 then return 7200 -- 30 minutes elseif reputation >= 0.00 then return 1800 -- 5 minutes elseif reputation >= 75.00 then return 1800 -- 5 minutes else return 600 end else return 300 end end function mutePlayer(player, punisherName, ruleNumber, ruleDescription, duration) local playerSerial = getPlayerSerial(player) local playerName = getPlayerName(player) local timestamp = getRealTime().timestamp local reputation2 = getElementData(player, "Reputation") or 0 if mutedPlayers[playerSerial] then outputChatBox("#ff0000• Player #ff0000is already muted. ", getRootElement(), 255, 255, 255, true) return end setPlayerMuted(player, true) setElementData(player, "muted", true) mutedPlayers[playerSerial] = { duration = duration, startTime = timestamp } outputChatBox("#006600• #FFFFFF".. playerName .. " #006600has been muted by #FFFFFF" .. punisherName .. " #006600[#FFFFFFReason: RULE #" .. ruleNumber .. ": " .. ruleDescription .. ". Duration: " .. formatTime(duration) .. " #006600]", getRootElement(), 255, 255, 255, true) executeSQLQuery("INSERT INTO punishments (serial, punishername, reason, duration, timestamp) VALUES (?, ?, ?, ?, ?)", playerSerial, punisherName, ruleNumber, duration, timestamp) setElementData(player, "Reputation", reputation2 - 15.00) mutedPlayers[playerSerial].unmuteTimer = setTimer(function() unmutePlayer(playerSerial, punisherName, ruleNumber, ruleDescription, true) end, duration * 1000, 1) end function findPlayerBySerial(serial) for _, player in ipairs(getElementsByType("player")) do if getPlayerSerial(player) == serial then return player end end return nil end function unmutePlayer(serial, punisherName, ruleNumber, ruleDescription, isAutomatic) local player = findPlayerBySerial(serial) if player then local playerSerial = getPlayerSerial(player) if mutedPlayers[playerSerial] then if mutedPlayers[playerSerial].unmuteTimer then killTimer(mutedPlayers[playerSerial].unmuteTimer) end local playerName = getPlayerName(player) setPlayerMuted(player, false) mutedPlayers[playerSerial] = nil executeSQLQuery("DELETE FROM punishments WHERE serial = ? AND reason = ?", playerSerial, ruleNumber) if not isAutomatic then outputChatBox("#006600• #FFFFFF" .. playerName .. " #006600has been unmuted by #FFFFFFConsole", player, 255, 255, 255, true) setElementData(player,"muted", false) end if isElement(player) and getElementType(player) == "player" and isAutomatic then outputChatBox("#006600• #FFFFFF" .. playerName .. " #006600has been unmuted by #FFFFFFConsole.", player, 255, 255, 255, true) setElementData(player,"muted", false) end else local playerName = getPlayerName(player) if not isAutomatic then outputConsole(playerName .. " is not currently muted.") end end else outputConsole("Player not found.") end end function formatTime(duration) local hours = math.floor(duration / 3600) local minutes = math.floor((duration % 3600) / 60) local seconds = duration % 60 local formattedTime = "" if hours > 0 then formattedTime = formattedTime .. hours .. " hour(s) " end if minutes > 0 then formattedTime = formattedTime .. minutes .. " minute(s) " end if seconds > 0 then formattedTime = formattedTime .. seconds .. " second(s)" end return formattedTime end function handleAUnmute(punisherName, playerName) local targetPlayer = findPlayerByPartialName(playerName) if not targetPlayer then outputChatBox("Player not found or multiple players match the partial name.") return end local playerNameTarget = getPlayerName(targetPlayer) local playerSerial = getPlayerSerial(targetPlayer) if mutedPlayers[playerSerial] then if mutedPlayers[playerSerial].unmuteTimer then killTimer(mutedPlayers[playerSerial].unmuteTimer) end setPlayerMuted(targetPlayer, false) mutedPlayers[playerSerial] = nil executeSQLQuery("DELETE FROM punishments WHERE serial = ?", playerSerial) outputChatBox("• #FFFFFF" .. playerNameTarget .. " #006600has been unmuted by #FFFFFF" .. punisherName .. "#006600", getRootElement(), 255, 255, 255, true) setElementData(targetPlayer, "muted", false) else outputChatBox(playerNameTarget .. " is not currently muted.", getRootElement(), 255, 255, 255, true) end end addCommandHandler("aunmute", function(player, _, playerName) local punisherName = getPlayerName(player) handleAUnmute(punisherName, playerName) end) addCommandHandler("action", function(player, _, playerName, ruleNumber) local punisherName = getPlayerName(player) handlePunishment(punisherName, playerName, ruleNumber) end) function checkRemainingMute(player, command, targetPlayerName) if not targetPlayerName then outputChatBox("Usage: /checkmute [playername]", player, 255, 255, 255, true) return end local targetPlayer = findPlayerByPartialName(targetPlayerName) if not targetPlayer then outputChatBox("Player not found or multiple players match the partial name.", player, 255, 255, 255, true) return end local playerSerial = getPlayerSerial(targetPlayer) if mutedPlayers[playerSerial] then local remainingDuration = mutedPlayers[playerSerial].duration - (getRealTime().timestamp - mutedPlayers[playerSerial].startTime) if remainingDuration <= 0 then outputChatBox(getPlayerName(targetPlayer) .. " is not currently muted.", player, 255, 255, 255, true) else outputChatBox(getPlayerName(targetPlayer) .. " is muted for another " .. formatTime(remainingDuration), player, 255, 255, 255, true) end else outputChatBox(getPlayerName(targetPlayer) .. " is not currently muted.", player, 255, 255, 255, true) end end addCommandHandler("checkmute", checkRemainingMute) function checkExpiredMutes() local currentTime = getRealTime().timestamp for playerSerial, data in pairs(mutedPlayers) do local remainingDuration = data.duration - (currentTime - data.startTime) if remainingDuration <= 0 then unmutePlayer(playerSerial, "Console", "", "", true) end end end addEventHandler("onResourceStart", resourceRoot, checkExpiredMutes)
  12. تم حل المشكل شكرا
×
×
  • Create New...