Quenix
Members-
Posts
32 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Quenix
-
That is correct, thank you for your assistance
-
Where exactly do i put this in the code?
-
Hey so this is my code and i get Expect argument and got nil at setElementAlpha so im wondering how i can use timer function correctly in this code? Here is the code regarding to the error: bindKey("aim_weapon", "both", function(key, press) if (getPedWeapon(localPlayer) == 34) then if (press == "down") then for i = 1, 4 do if (i ~= 3) then local tohide = getElementData(localPlayer, "tohide"..tostring(i)) or "NONE"; if (tohide ~= "NONE") then setElementAlpha(tohide, 0); end end end elseif (press == "up") then for i = 1, 4 do if (i ~= 3) then local tohide = getElementData(localPlayer, "tohide"..tostring(i)) or "NONE"; if (tohide ~= "NONE") then setElementAlpha(tohide, 255); end end end end end end);
-
The problem is, i dont know what col my script has because its a script where you make protection for other bases using /polymake1-4 so you make the 4 polygoncorners and it turns it into one area. And dont know what that is called after its finnished
-
so @JeViCo this is what i did, i added the below script to the Server side script which ive provided aswell, but the godmode enables on every col and not the one around the base, which is the protection polygon, this polygon is called handlepoly i think according to the script is there a way to make only godmode get enabled/disabled on entering/leaving just this colshape that this script is making or has made? The vehicle godmode: function vehicleGodMod(player) if isPedInVehicle ( player ) and getPedOccupiedVehicleSeat( player ) == 0 then vehicle = getPedOccupiedVehicle ( player ) setVehicleDamageProof( vehicle, true ) outputChatBox ( "#FFFFFFVehicle godmode #00FF00enabled", getRootElement(), 255, 0, 0, true ) end end addEventHandler("onColShapeHit", root, vehicleGodMod) function vehicleGodMod2(player) if isPedInVehicle ( player ) and getPedOccupiedVehicleSeat( player ) == 0 then setVehicleDamageProof( vehicle, false ) outputChatBox ( "Vehicle godmode #FF0004disabled", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onColShapeLeave", root, vehicleGodMod2) The serverside script with the car godmode in it which is working but works on all polygons: --- Definire Poligon (phy) function createZone(thePlayer, theCMD, accType, ...) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then local clanFile = xmlLoadFile("security.xml") if not clanFile then outputChatBox("Sistemul nu a putut fi activat!", thePlayer, 255, 0, 0) return end local accRuleTable = {...} local accRule = table.concat(accRuleTable, " ") if tonumber(accType) == 1 then outputChatBox("Tipul de acces a fost setat la _Cont pentru "..tostring(accRule), thePlayer, 255, 155, 0, false) elseif tonumber(accType) == 2 then outputChatBox("Tipul de acces a fost setat la _Clan pentru "..tostring(accRule), thePlayer, 255, 155, 0, false) elseif tonumber(accType) == 3 then outputChatBox("Tipul de acces a fost setat la _Grup ACL pentru "..tostring(accRule), thePlayer, 255, 155, 0, false) elseif tonumber(accType) == 4 then outputChatBox("Tipul de acces a fost setat la _Zona Sigura!", thePlayer, 255, 155, 0, false) else outputChatBox("Tipul de acces este invalid!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Cont | 2 - Clan | 3 - Grup ACL | 4 - Zona Sigura", thePlayer, 255, 155, 0) return end if accRule == nil then outputChatBox("Regula de acces este gresita!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL | 4 - Zona Sigura", thePlayer, 255, 155, 0) return end local findClan = xmlFindChild(clanFile, "id", 0) local id = xmlNodeGetValue(findClan) local thisClan = xmlCreateChild (clanFile, "clan") local x, y, z = getElementPosition(thePlayer) --- Colt 1 local x1 = getElementData(thePlayer, "x1") or false local y1 = getElementData(thePlayer, "y1") or false --- Colt 2 local x2 = getElementData(thePlayer, "x2") or false local y2 = getElementData(thePlayer, "y2") or false --- Colt 3 local x3 = getElementData(thePlayer, "x3") or false local y3 = getElementData(thePlayer, "y3") or false --- Colt 4 local x4 = getElementData(thePlayer, "x4") or false local y4 = getElementData(thePlayer, "y4") or false --- Validarea Datelor [x1, y1, z1] if x1 == false and y1 == false then outputChatBox("Coltul #1 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end --- Validarea Datelor [x2, y2, z2] if x2 == false and y2 ~= false then outputChatBox("Coltul #2 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end --- Validarea Datelor [x3, y3, z3] if x3 == false and y3 == false then outputChatBox("Coltul #3 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end --- Validarea Datelor [x4, y4, z4] if x4 == false and y4 == false then outputChatBox("Coltul #4 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end xmlNodeSetAttribute (thisClan, "id", tonumber(id) + 1) --- Pozitia unde va fi dat afara! xmlNodeSetAttribute (thisClan, "x", x) xmlNodeSetAttribute (thisClan, "y", y) xmlNodeSetAttribute (thisClan, "z", z) --- Coltul 1 xmlNodeSetAttribute (thisClan, "xa", x1) xmlNodeSetAttribute (thisClan, "ya", y1) --- Coltul 2 xmlNodeSetAttribute (thisClan, "xb", x2) xmlNodeSetAttribute (thisClan, "yb", y2) --- Coltul 3 xmlNodeSetAttribute (thisClan, "xc", x3) xmlNodeSetAttribute (thisClan, "yc", y3) --- Coltul 4 xmlNodeSetAttribute (thisClan, "xd", x4) xmlNodeSetAttribute (thisClan, "yd", y4) --- Configurare xmlNodeSetAttribute (thisClan, "accType", accType) xmlNodeSetAttribute (thisClan, "accRule", accRule) local clanId = tostring(tonumber(id) + 1) xmlNodeSetValue (findClan, clanId) xmlSaveFile(clanFile) xmlUnloadFile(clanFile) local clanProtection = createColPolygon(x, y, tonumber(x1), tonumber(y1), tonumber(x2), tonumber(y2), tonumber(x3), tonumber(y3), tonumber(x4), tonumber(y4)) setElementData(clanProtection, "accId", clanId) setElementData(clanProtection, "accType", accType) setElementData(clanProtection, "accRule", accRule) setElementData(clanProtection, "exportX", x) setElementData(clanProtection, "exportY", y) setElementData(clanProtection, "exportZ", z) reloadClans() end end addCommandHandler("makepoly", createZone) --- Creare Poligon function createPoligonalCorners(thePlayer, theCMD, theNode) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then local id = tonumber(theNode) if id == 1 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) elseif id == 2 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) elseif id == 3 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) elseif id == 4 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) else outputChatBox("The polygon can have up to 4 corners!", thePlayer, 255, 0, 0) end end end addCommandHandler("polynode", createPoligonalCorners, false) --- Resetare Poligon function resetPoligonalCorners(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then setElementData(thePlayer, "x1", false) setElementData(thePlayer, "y1", false) setElementData(thePlayer, "x2", false) setElementData(thePlayer, "y2", false) setElementData(thePlayer, "x3", false) setElementData(thePlayer, "y3", false) setElementData(thePlayer, "x4", false) setElementData(thePlayer, "y4", false) outputChatBox("Colturile poligonale au fost resetate!", thePlayer, 255, 155, 0) end end addCommandHandler("resetpoly", resetPoligonalCorners, false) --- Re-configurare Poligon function rebuildZoneAccess(thePlayer, theCMD, theZoneId, newAccType, ...) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then local clanFile = xmlLoadFile("security.xml") local findZone = xmlFindChild(clanFile, "clan", tonumber(theZoneId) - 1) local accRuleTable = {...} local newAccRule = table.concat(accRuleTable, " ") xmlNodeSetAttribute(findZone, "accType", newAccType) xmlNodeSetAttribute(findZone, "accRule", newAccRule) xmlSaveFile(clanFile) xmlUnloadFile(clanFile) outputChatBox("Accesul zonei cu ID "..theZoneId.." a fost modificat!", thePlayer, 255, 155, 0) reloadClans() end end addCommandHandler("rebuildpoly", rebuildZoneAccess) -- Functii de Creare/Distrugere function loadClans() local clanFile = xmlLoadFile("security.xml") if (clanFile) then local clans = xmlNodeGetChildren(clanFile) for i,v in ipairs(clans) do local clanId = xmlNodeGetAttribute (v, "id") local x = xmlNodeGetAttribute (v, "x") local y = xmlNodeGetAttribute (v, "y") local z = xmlNodeGetAttribute (v, "z") local x1 = xmlNodeGetAttribute (v, "xa") local y1 = xmlNodeGetAttribute (v, "ya") local x2 = xmlNodeGetAttribute (v, "xb") local y2 = xmlNodeGetAttribute (v, "yb") local x3 = xmlNodeGetAttribute (v, "xc") local y3 = xmlNodeGetAttribute (v, "yc") local x4 = xmlNodeGetAttribute (v, "xd") local y4 = xmlNodeGetAttribute (v, "yd") local accType = xmlNodeGetAttribute (v, "accType") local accRule = xmlNodeGetAttribute (v, "accRule") if x then local clanProtection = createColPolygon(x, y, tonumber(x1), tonumber(y1), tonumber(x2), tonumber(y2), tonumber(x3), tonumber(y3), tonumber(x4), tonumber(y4)) setElementData(clanProtection, "accId", clanId) setElementData(clanProtection, "accType", accType) setElementData(clanProtection, "accRule", accRule) setElementData(clanProtection, "exportX", x) setElementData(clanProtection, "exportY", y) setElementData(clanProtection, "exportZ", z) end end xmlUnloadFile(clanFile) end end -- Destroy Poligon function destroyClans() allClans = getElementsByType("colShape") for i,v in ipairs(allClans) do if tonumber(getElementData(v, "accType")) == 1 or tonumber(getElementData(v, "accType")) == 2 or tonumber(getElementData(v, "accType")) == 3 or tonumber(getElementData(v, "accType")) == 4 then destroyElement(v) end end end -- Reload Poligon function reloadClans() destroyClans() loadClans() end function preloadClans(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then destroyClans() loadClans() outputChatBox("Sistemul de securitate a actualizat zonele de securitate!", thePlayer, 255, 155, 0) end end addCommandHandler("reloadpoly", preloadClans, false) -- Secure Polygon function getSimplestTaskOf(thePlayer) getServerPedTask(thePlayer) return getElementData(thePlayer, "simplestTask") or "TASK_UNASSIGNED" end function getServerPedTask(thePlayer) triggerClientEvent(thePlayer, "onServerGetPedSimplestTask", thePlayer) end function getServerSimplestTask(theTask) setElementData(client, "simplestTask", theTask) end addEvent("onSimplestTaskReturned", true) addEventHandler("onSimplestTaskReturned", resourceRoot, getServerSimplestTask) function updateTask(thePlayer) getServerPedTask(thePlayer) end addEventHandler("onVehicleStartEnter", root, updateTask) addEventHandler("onVehicleStartExit", root, updateTask) addEventHandler("onVehicleEnter", root, updateTask) addEventHandler("onVehicleExit", root, updateTask) function vehicleGodMod(player) if isPedInVehicle ( player ) and getPedOccupiedVehicleSeat( player ) == 0 then vehicle = getPedOccupiedVehicle ( player ) setVehicleDamageProof( vehicle, true ) outputChatBox ( "#FFFFFFVehicle godmode #00FF00enabled", getRootElement(), 255, 0, 0, true ) end end addEventHandler("onColShapeHit", root, vehicleGodMod) function vehicleGodMod2(player) if isPedInVehicle ( player ) and getPedOccupiedVehicleSeat( player ) == 0 then setVehicleDamageProof( vehicle, false ) outputChatBox ( "Vehicle godmode #FF0004disabled", getRootElement(), 255, 255, 255, true ) end end addEventHandler("onColShapeLeave", root, vehicleGodMod2) function handlePoly(thePlayer) local currentPoly = getElementData(source, "accId") or false if currentPoly then local polyAccType = getElementData(source, "accType") local polyAccRule = getElementData(source, "accRule") if getElementType(thePlayer) == "player" and isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then outputChatBox("Because you're an administrator, you will not be affected by zone settings!", thePlayer, 255, 155, 0) if tonumber(polyAccType) == 1 then outputChatBox("ID: "..currentPoly.." | Acces: "..polyAccRule.." | Tip Acces: Cont", thePlayer, 255, 155, 0) elseif tonumber(polyAccType) == 2 then outputChatBox("ID: "..currentPoly.." | Acces: "..polyAccRule.." | Tip Acces: Clan", thePlayer, 255, 155, 0) elseif tonumber(polyAccType) == 3 then outputChatBox("ID: "..currentPoly.." | Acces: "..polyAccRule.." | Tip Acces: Grup ACL", thePlayer, 255, 155, 0) elseif tonumber(polyAccType) == 4 then outputChatBox("ID: "..currentPoly.." | Acces: --- | Tip Acces: Zona Sigura", thePlayer, 255, 155, 0) else outputChatBox("ID: "..currentPoly.." | Zona nu este configurata corect!", thePlayer, 255, 0, 0) end else if tonumber(polyAccType) == 1 then if getElementType(thePlayer) == "player" and getAccountName(getPlayerAccount(thePlayer)) ~= tostring(polyAccRule) or isGuestAccount(getPlayerAccount(thePlayer)) then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a incercat sa patrunda intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Cont | Regula de Acces: "..tostring(polyAccRule)) local exportX = getElementData(source, "exportX") local exportY = getElementData(source, "exportY") local exportZ = getElementData(source, "exportZ") setTimer(function(thePlayer, theZone) warpOutIfStillIn(thePlayer, theZone) end, 2000, 1, thePlayer, source) if not isPedInVehicle(thePlayer) then setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) else if getSimplestTaskOf(thePlayer) == "TASK_SIMPLE_CAR_DRIVE" then if getElementModel(getPedOccupiedVehicle(thePlayer)) == 487 or getElementModel(getPedOccupiedVehicle(thePlayer)) == 497 then local px, py, pz = getElementPosition(thePlayer) setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ + 25) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) else setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) end else removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) end end else call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Cont | Regula de Acces: "..tostring(polyAccRule)) end elseif tonumber(polyAccType) == 2 then if tostring(getElementData(thePlayer, "gang")) ~= tostring(polyAccRule) then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a incercat sa patrunda intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Clan | Regula de Acces: "..tostring(polyAccRule)) local exportX = getElementData(source, "exportX") local exportY = getElementData(source, "exportY") local exportZ = getElementData(source, "exportZ") setTimer(function(thePlayer, theZone) warpOutIfStillIn(thePlayer, theZone) end, 2000, 1, thePlayer, source) if not isPedInVehicle(thePlayer) then setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else if getSimplestTaskOf(thePlayer) == "TASK_SIMPLE_CAR_DRIVE" then if getElementModel(getPedOccupiedVehicle(thePlayer)) == 487 or getElementModel(getPedOccupiedVehicle(thePlayer)) == 497 then local px, py, pz = getElementPosition(thePlayer) setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ + 25) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) end else removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) outputChatBox(getSimplestTaskOf(thePlayer), thePlayer, 255, 155, 0) end end else call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Clan | Regula de Acces: "..tostring(polyAccRule)) end elseif tonumber(polyAccType) == 3 then if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup(tostring(polyAccRule))) then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a incercat sa patrunda intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Grup ACL | Regula de Acces: "..tostring(polyAccRule)) local exportX = getElementData(source, "exportX") local exportY = getElementData(source, "exportY") local exportZ = getElementData(source, "exportZ") setTimer(function(thePlayer, theZone) warpOutIfStillIn(thePlayer, theZone) end, 2000, 1, thePlayer, source) if not isPedInVehicle(thePlayer) then setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else if getSimplestTaskOf(thePlayer) == "TASK_SIMPLE_CAR_DRIVE" then if getElementModel(getPedOccupiedVehicle(thePlayer)) == 487 or getElementModel(getPedOccupiedVehicle(thePlayer)) == 497 then local px, py, pz = getElementPosition(thePlayer) setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ + 25) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) end else removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) end end else call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Grup ACL | Regula de Acces: "..tostring(polyAccRule)) end elseif tonumber(polyAccType) == 4 then if getElementType(thePlayer) == "player" then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona sigura!") outputChatBox("Ai patruns intr-o zona sigura! Armele tale au fost dezactivate temporar!", thePlayer, 255, 155, 0) toggleControl (thePlayer, "fire", false) toggleControl (thePlayer, "next_weapon", false) toggleControl (thePlayer, "previous_weapon", false) toggleControl (thePlayer, "aim_weapon", false) toggleControl (thePlayer, "vehicle_fire", false) setPlayerHudComponentVisible (thePlayer, "ammo", false) setPlayerHudComponentVisible (thePlayer, "weapon", false) end end end end end addEventHandler("onColShapeHit", resourceRoot, handlePoly) function resetAntiPvP(thePlayer) local accType = getElementData(source, "accType") if tonumber(accType) == 4 and getElementType(thePlayer) == "player" then outputChatBox("Ai parasit zona sigura! Armele tale au fost re-activate!", thePlayer, 255, 155, 0) toggleControl (thePlayer, "fire", true) toggleControl (thePlayer, "next_weapon", true) toggleControl (thePlayer, "previous_weapon", true) toggleControl (thePlayer, "aim_weapon", true) toggleControl (thePlayer, "vehicle_fire", true) setPlayerHudComponentVisible (thePlayer, "ammo", true) setPlayerHudComponentVisible (thePlayer, "weapon", true) end end addEventHandler("onColShapeLeave", resourceRoot, resetAntiPvP) function warpOutIfStillIn(thePlayer, theZone) if isElement(thePlayer) and isElementWithinColShape(thePlayer, theZone) then local exportX = getElementData(theZone, "exportX") local exportY = getElementData(theZone, "exportY") local exportZ = getElementData(theZone, "exportZ") removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) end end
-
oooo, alrighty ill try this. thanks buddy @JeViCo
-
Could you detail your answer a bit more please? @LyricalMM
-
So i have a proection script for bases, i want the vehicles that are inside this zone will keep the HP they had when they first came in, so people wont throw nades or shoot the vehicles outside the zone. I take no credits for the script as it is not mine! Server --- Definire Poligon (phy) function createZone(thePlayer, theCMD, accType, ...) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then local clanFile = xmlLoadFile("security.xml") if not clanFile then outputChatBox("Sistemul nu a putut fi activat!", thePlayer, 255, 0, 0) return end local accRuleTable = {...} local accRule = table.concat(accRuleTable, " ") if tonumber(accType) == 1 then outputChatBox("Tipul de acces a fost setat la _Cont pentru "..tostring(accRule), thePlayer, 255, 155, 0, false) elseif tonumber(accType) == 2 then outputChatBox("Tipul de acces a fost setat la _Clan pentru "..tostring(accRule), thePlayer, 255, 155, 0, false) elseif tonumber(accType) == 3 then outputChatBox("Tipul de acces a fost setat la _Grup ACL pentru "..tostring(accRule), thePlayer, 255, 155, 0, false) elseif tonumber(accType) == 4 then outputChatBox("Tipul de acces a fost setat la _Zona Sigura!", thePlayer, 255, 155, 0, false) else outputChatBox("Tipul de acces este invalid!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Cont | 2 - Clan | 3 - Grup ACL | 4 - Zona Sigura", thePlayer, 255, 155, 0) return end if accRule == nil then outputChatBox("Regula de acces este gresita!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL | 4 - Zona Sigura", thePlayer, 255, 155, 0) return end local findClan = xmlFindChild(clanFile, "id", 0) local id = xmlNodeGetValue(findClan) local thisClan = xmlCreateChild (clanFile, "clan") local x, y, z = getElementPosition(thePlayer) --- Colt 1 local x1 = getElementData(thePlayer, "x1") or false local y1 = getElementData(thePlayer, "y1") or false --- Colt 2 local x2 = getElementData(thePlayer, "x2") or false local y2 = getElementData(thePlayer, "y2") or false --- Colt 3 local x3 = getElementData(thePlayer, "x3") or false local y3 = getElementData(thePlayer, "y3") or false --- Colt 4 local x4 = getElementData(thePlayer, "x4") or false local y4 = getElementData(thePlayer, "y4") or false --- Validarea Datelor [x1, y1, z1] if x1 == false and y1 == false then outputChatBox("Coltul #1 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end --- Validarea Datelor [x2, y2, z2] if x2 == false and y2 ~= false then outputChatBox("Coltul #2 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end --- Validarea Datelor [x3, y3, z3] if x3 == false and y3 == false then outputChatBox("Coltul #3 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end --- Validarea Datelor [x4, y4, z4] if x4 == false and y4 == false then outputChatBox("Coltul #4 nu a fost setat!", thePlayer, 255, 0, 0) outputChatBox("SINTAXA: /makemark [Tip Acces] [Regula Acces]", thePlayer, 255, 155, 0) outputChatBox("TIPURI ACCES: 1 - Jucator | 2 - Clan | 3 - Grup ACL", thePlayer, 255, 155, 0) return end xmlNodeSetAttribute (thisClan, "id", tonumber(id) + 1) --- Pozitia unde va fi dat afara! xmlNodeSetAttribute (thisClan, "x", x) xmlNodeSetAttribute (thisClan, "y", y) xmlNodeSetAttribute (thisClan, "z", z) --- Coltul 1 xmlNodeSetAttribute (thisClan, "xa", x1) xmlNodeSetAttribute (thisClan, "ya", y1) --- Coltul 2 xmlNodeSetAttribute (thisClan, "xb", x2) xmlNodeSetAttribute (thisClan, "yb", y2) --- Coltul 3 xmlNodeSetAttribute (thisClan, "xc", x3) xmlNodeSetAttribute (thisClan, "yc", y3) --- Coltul 4 xmlNodeSetAttribute (thisClan, "xd", x4) xmlNodeSetAttribute (thisClan, "yd", y4) --- Configurare xmlNodeSetAttribute (thisClan, "accType", accType) xmlNodeSetAttribute (thisClan, "accRule", accRule) local clanId = tostring(tonumber(id) + 1) xmlNodeSetValue (findClan, clanId) xmlSaveFile(clanFile) xmlUnloadFile(clanFile) local clanProtection = createColPolygon(x, y, tonumber(x1), tonumber(y1), tonumber(x2), tonumber(y2), tonumber(x3), tonumber(y3), tonumber(x4), tonumber(y4)) setElementData(clanProtection, "accId", clanId) setElementData(clanProtection, "accType", accType) setElementData(clanProtection, "accRule", accRule) setElementData(clanProtection, "exportX", x) setElementData(clanProtection, "exportY", y) setElementData(clanProtection, "exportZ", z) reloadClans() end end addCommandHandler("makepoly", createZone) --- Creare Poligon function createPoligonalCorners(thePlayer, theCMD, theNode) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then local id = tonumber(theNode) if id == 1 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) elseif id == 2 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) elseif id == 3 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) elseif id == 4 then local x, y, z = getElementPosition(thePlayer) setElementData(thePlayer, "x"..id, x) setElementData(thePlayer, "y"..id, y) outputChatBox("The corner #"..id.." was created!", thePlayer, 255, 155, 0) else outputChatBox("The polygon can have up to 4 corners!", thePlayer, 255, 0, 0) end end end addCommandHandler("polynode", createPoligonalCorners, false) --- Resetare Poligon function resetPoligonalCorners(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then setElementData(thePlayer, "x1", false) setElementData(thePlayer, "y1", false) setElementData(thePlayer, "x2", false) setElementData(thePlayer, "y2", false) setElementData(thePlayer, "x3", false) setElementData(thePlayer, "y3", false) setElementData(thePlayer, "x4", false) setElementData(thePlayer, "y4", false) outputChatBox("Colturile poligonale au fost resetate!", thePlayer, 255, 155, 0) end end addCommandHandler("resetpoly", resetPoligonalCorners, false) --- Re-configurare Poligon function rebuildZoneAccess(thePlayer, theCMD, theZoneId, newAccType, ...) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then local clanFile = xmlLoadFile("security.xml") local findZone = xmlFindChild(clanFile, "clan", tonumber(theZoneId) - 1) local accRuleTable = {...} local newAccRule = table.concat(accRuleTable, " ") xmlNodeSetAttribute(findZone, "accType", newAccType) xmlNodeSetAttribute(findZone, "accRule", newAccRule) xmlSaveFile(clanFile) xmlUnloadFile(clanFile) outputChatBox("Accesul zonei cu ID "..theZoneId.." a fost modificat!", thePlayer, 255, 155, 0) reloadClans() end end addCommandHandler("rebuildpoly", rebuildZoneAccess) -- Functii de Creare/Distrugere function loadClans() local clanFile = xmlLoadFile("security.xml") if (clanFile) then local clans = xmlNodeGetChildren(clanFile) for i,v in ipairs(clans) do local clanId = xmlNodeGetAttribute (v, "id") local x = xmlNodeGetAttribute (v, "x") local y = xmlNodeGetAttribute (v, "y") local z = xmlNodeGetAttribute (v, "z") local x1 = xmlNodeGetAttribute (v, "xa") local y1 = xmlNodeGetAttribute (v, "ya") local x2 = xmlNodeGetAttribute (v, "xb") local y2 = xmlNodeGetAttribute (v, "yb") local x3 = xmlNodeGetAttribute (v, "xc") local y3 = xmlNodeGetAttribute (v, "yc") local x4 = xmlNodeGetAttribute (v, "xd") local y4 = xmlNodeGetAttribute (v, "yd") local accType = xmlNodeGetAttribute (v, "accType") local accRule = xmlNodeGetAttribute (v, "accRule") if x then local clanProtection = createColPolygon(x, y, tonumber(x1), tonumber(y1), tonumber(x2), tonumber(y2), tonumber(x3), tonumber(y3), tonumber(x4), tonumber(y4)) setElementData(clanProtection, "accId", clanId) setElementData(clanProtection, "accType", accType) setElementData(clanProtection, "accRule", accRule) setElementData(clanProtection, "exportX", x) setElementData(clanProtection, "exportY", y) setElementData(clanProtection, "exportZ", z) end end xmlUnloadFile(clanFile) end end -- Destroy Poligon function destroyClans() allClans = getElementsByType("colShape") for i,v in ipairs(allClans) do if tonumber(getElementData(v, "accType")) == 1 or tonumber(getElementData(v, "accType")) == 2 or tonumber(getElementData(v, "accType")) == 3 or tonumber(getElementData(v, "accType")) == 4 then destroyElement(v) end end end -- Reload Poligon function reloadClans() destroyClans() loadClans() end function preloadClans(thePlayer) if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then destroyClans() loadClans() outputChatBox("Sistemul de securitate a actualizat zonele de securitate!", thePlayer, 255, 155, 0) end end addCommandHandler("reloadpoly", preloadClans, false) -- Secure Polygon function getSimplestTaskOf(thePlayer) getServerPedTask(thePlayer) return getElementData(thePlayer, "simplestTask") or "TASK_UNASSIGNED" end function getServerPedTask(thePlayer) triggerClientEvent(thePlayer, "onServerGetPedSimplestTask", thePlayer) end function getServerSimplestTask(theTask) setElementData(client, "simplestTask", theTask) end addEvent("onSimplestTaskReturned", true) addEventHandler("onSimplestTaskReturned", resourceRoot, getServerSimplestTask) function updateTask(thePlayer) getServerPedTask(thePlayer) end addEventHandler("onVehicleStartEnter", root, updateTask) addEventHandler("onVehicleStartExit", root, updateTask) addEventHandler("onVehicleEnter", root, updateTask) addEventHandler("onVehicleExit", root, updateTask) function handlePoly(thePlayer) local currentPoly = getElementData(source, "accId") or false if currentPoly then local polyAccType = getElementData(source, "accType") local polyAccRule = getElementData(source, "accRule") if getElementType(thePlayer) == "player" and isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then outputChatBox("Because you're an administrator, you will not be affected by zone settings!", thePlayer, 255, 155, 0) if tonumber(polyAccType) == 1 then outputChatBox("ID: "..currentPoly.." | Acces: "..polyAccRule.." | Tip Acces: Cont", thePlayer, 255, 155, 0) elseif tonumber(polyAccType) == 2 then outputChatBox("ID: "..currentPoly.." | Acces: "..polyAccRule.." | Tip Acces: Clan", thePlayer, 255, 155, 0) elseif tonumber(polyAccType) == 3 then outputChatBox("ID: "..currentPoly.." | Acces: "..polyAccRule.." | Tip Acces: Grup ACL", thePlayer, 255, 155, 0) elseif tonumber(polyAccType) == 4 then outputChatBox("ID: "..currentPoly.." | Acces: --- | Tip Acces: Zona Sigura", thePlayer, 255, 155, 0) else outputChatBox("ID: "..currentPoly.." | Zona nu este configurata corect!", thePlayer, 255, 0, 0) end else if tonumber(polyAccType) == 1 then if getElementType(thePlayer) == "player" and getAccountName(getPlayerAccount(thePlayer)) ~= tostring(polyAccRule) or isGuestAccount(getPlayerAccount(thePlayer)) then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a incercat sa patrunda intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Cont | Regula de Acces: "..tostring(polyAccRule)) local exportX = getElementData(source, "exportX") local exportY = getElementData(source, "exportY") local exportZ = getElementData(source, "exportZ") setTimer(function(thePlayer, theZone) warpOutIfStillIn(thePlayer, theZone) end, 2000, 1, thePlayer, source) if not isPedInVehicle(thePlayer) then setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) else if getSimplestTaskOf(thePlayer) == "TASK_SIMPLE_CAR_DRIVE" then if getElementModel(getPedOccupiedVehicle(thePlayer)) == 487 or getElementModel(getPedOccupiedVehicle(thePlayer)) == 497 then local px, py, pz = getElementPosition(thePlayer) setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ + 25) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) else setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) end else removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu esti detinatorul bazei!", thePlayer, 255, 155, 0, true) end end else call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Cont | Regula de Acces: "..tostring(polyAccRule)) end elseif tonumber(polyAccType) == 2 then if tostring(getElementData(thePlayer, "gang")) ~= tostring(polyAccRule) then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a incercat sa patrunda intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Clan | Regula de Acces: "..tostring(polyAccRule)) local exportX = getElementData(source, "exportX") local exportY = getElementData(source, "exportY") local exportZ = getElementData(source, "exportZ") setTimer(function(thePlayer, theZone) warpOutIfStillIn(thePlayer, theZone) end, 2000, 1, thePlayer, source) if not isPedInVehicle(thePlayer) then setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else if getSimplestTaskOf(thePlayer) == "TASK_SIMPLE_CAR_DRIVE" then if getElementModel(getPedOccupiedVehicle(thePlayer)) == 487 or getElementModel(getPedOccupiedVehicle(thePlayer)) == 497 then local px, py, pz = getElementPosition(thePlayer) setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ + 25) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) end else removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("You were teleported because you do not belong to the clan #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) outputChatBox(getSimplestTaskOf(thePlayer), thePlayer, 255, 155, 0) end end else call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Clan | Regula de Acces: "..tostring(polyAccRule)) end elseif tonumber(polyAccType) == 3 then if not isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup(tostring(polyAccRule))) then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a incercat sa patrunda intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Grup ACL | Regula de Acces: "..tostring(polyAccRule)) local exportX = getElementData(source, "exportX") local exportY = getElementData(source, "exportY") local exportZ = getElementData(source, "exportZ") setTimer(function(thePlayer, theZone) warpOutIfStillIn(thePlayer, theZone) end, 2000, 1, thePlayer, source) if not isPedInVehicle(thePlayer) then setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else if getSimplestTaskOf(thePlayer) == "TASK_SIMPLE_CAR_DRIVE" then if getElementModel(getPedOccupiedVehicle(thePlayer)) == 487 or getElementModel(getPedOccupiedVehicle(thePlayer)) == 497 then local px, py, pz = getElementPosition(thePlayer) setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ + 25) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) else setElementPosition(getPedOccupiedVehicle(thePlayer), exportX, exportY, exportZ) setElementVelocity(getPedOccupiedVehicle(thePlayer), 0, 0, 0) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) end else removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) outputChatBox("Ai fost teleportat deoarece nu apartii grupului #FFFFFF"..polyAccRule, thePlayer, 255, 155, 0, true) end end else call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona de acces!") call(getResourceFromName("logsys"), "outputLog", "Tipul de Acces: Grup ACL | Regula de Acces: "..tostring(polyAccRule)) end elseif tonumber(polyAccType) == 4 then if getElementType(thePlayer) == "player" then call(getResourceFromName("logsys"), "outputLog", "Securitate: "..getPlayerName(thePlayer).." a intrat intr-o zona sigura!") outputChatBox("Ai patruns intr-o zona sigura! Armele tale au fost dezactivate temporar!", thePlayer, 255, 155, 0) toggleControl (thePlayer, "fire", false) toggleControl (thePlayer, "next_weapon", false) toggleControl (thePlayer, "previous_weapon", false) toggleControl (thePlayer, "aim_weapon", false) toggleControl (thePlayer, "vehicle_fire", false) setPlayerHudComponentVisible (thePlayer, "ammo", false) setPlayerHudComponentVisible (thePlayer, "weapon", false) end end end end end addEventHandler("onColShapeHit", resourceRoot, handlePoly) function resetAntiPvP(thePlayer) local accType = getElementData(source, "accType") if tonumber(accType) == 4 and getElementType(thePlayer) == "player" then outputChatBox("Ai parasit zona sigura! Armele tale au fost re-activate!", thePlayer, 255, 155, 0) toggleControl (thePlayer, "fire", true) toggleControl (thePlayer, "next_weapon", true) toggleControl (thePlayer, "previous_weapon", true) toggleControl (thePlayer, "aim_weapon", true) toggleControl (thePlayer, "vehicle_fire", true) setPlayerHudComponentVisible (thePlayer, "ammo", true) setPlayerHudComponentVisible (thePlayer, "weapon", true) end end addEventHandler("onColShapeLeave", resourceRoot, resetAntiPvP) function warpOutIfStillIn(thePlayer, theZone) if isElement(thePlayer) and isElementWithinColShape(thePlayer, theZone) then local exportX = getElementData(theZone, "exportX") local exportY = getElementData(theZone, "exportY") local exportZ = getElementData(theZone, "exportZ") removePedFromVehicle(thePlayer) setElementPosition(thePlayer, exportX, exportY, exportZ) end end I know you can enable godmode like this, but how can i use this on the script above? elseif getElementType ( theElement ) == "vehicle" then SetVehicleGodMode(theElement,true) end end function ExitPlace ( theElement ) if getElementType ( theElement ) == "vehicle" then SetVehicleGodMode(theElement,false) end end
-
Thank you both @DeadthStrock and @LyricalMM I thing its better to use relative as it is in percentage, meaning it will always be the same percantage on all resoultions instead of using absolute as that is almost like Pixels. It will be diffferent to each resolution. Thanks!
-
Hey Forum, i need to fit this money showing script to alll resoultions, some players with 1280 x 720 are having problems seeing their money in game. The money is located on top right of the screen. I visited https://wiki.multitheftauto.com/wiki/GuiGetScreenSize and saw some examples but its a bit confusing to be honest. Would appreciate if anyone could get me to understand the GuiGetScreenSize and help me make this script fit all resolutions. Below ive added the script: addEventHandler("onClientResourceStart", resourceRoot, function() end ) addEventHandler("onClientRender", root, function() local cash = getPlayerMoney( getLocalPlayer() ) dxDrawText("KBK Points", 1785, 100, 688, 128, tocolor(30, 247, 7, 255), 0.50, "bankgothic", "left", "top", false, false, false, false, false) dxDrawText(""..cash, 1785, 115, 796,123, tocolor(255, 255, 255, 255), 0.50, "bankgothic", "left", "top", false, false, false, false, false) end ) Tell me if you need more of the code!
-
This is huge, how can i thank you except a like?? Thank you so much @DeadthStrock for all this help man, i can imagine its hard fixing all this buggs im throwing in the thread. Holy :~! ++++rep
-
but im having problems, i added a close button to the gui, when ever i press it the gui closes but the active image at that moment is not getting destroyed? Here is the scripts with the close button added Client side: local items = { --items,cena(K.B.K Points) porsion1List = { {"M1911",50}, {"PDW",150}, {"Winchester 1866",150}, {"AK-107",300}, {"Lee Enfield",400}, {"M4A1 Holo",300}, {"MK 48 Mod 0",450}, {"CZ550",300}, {"DMR",400} }, porsion2List = { {"M1911 Mag",50}, {"PDW Mag",100}, {"1866 Slug",125}, {"AK-107 Mag",100}, {"M4A1 Holo Mag",50}, {"MK 48 Mod 0 Mag",200}, {"Lee Enfield Mag",70}, {"CZ550 Mag",50}, {"DMR Mag",25}, {"Water Bottle",15}, {"Burger",15} }, porsion3List = { {"Tire",75}, {"Engine",125}, {"Tank Parts",50} }, porsion4List = { {"Medic Kit",50}, {"Painkiller",10}, {"Morphine",10}, {"Bandage",5} }, porsion5List = { {"Camouflage Clothing",100}, {"Army Clothing",150}, {"Ghost Clothing",200}, {"K.B.K Backpack",150}, {"Ghillie Suit",200}, {"Civilian Clothing",30}, {"GPS",15}, {"Tent",60}, {"Map",15}, {"Toolbox",25} } } SHOP = { button = {}, window = {}, label = {}, tabpanel = {}, tab = {}, panel = {} } addEventHandler("onClientResourceStart", resourceRoot, function () SHOP.window[1] = guiCreateWindow(0.16, 0.26, 0.65, 0.55, "Kill Or Be Killed Shop", true) guiWindowSetMovable(SHOP.window[1], false) guiWindowSetSizable(SHOP.window[1], false) guiSetProperty(SHOP.window[1], "CaptionColour", "FFFF0000") SHOP.label[1] = guiCreateLabel(0.02, 0.69, 0.97, 0.08, "Select item which you want to buy! \nThe shop value is K.B.K Points", true, SHOP.window[1]) guiSetFont(SHOP.label[1], "default-bold-small") guiLabelSetHorizontalAlign(SHOP.label[1], "center", true) guiLabelSetVerticalAlign(SHOP.label[1], "center") SHOP.button[1] = guiCreateButton(0.35, 0.79, 0.30, 0.12, "BUY", true, SHOP.window[1]) SHOP.button[2] = guiCreateButton(0.98, 0.07, 0.02, 0.03, "X", true, SHOP.window[1]) guiSetFont(SHOP.button[1], "default-bold-small") SHOP.tabpanel[1] = guiCreateTabPanel(40, 33, 587, 240, false, SHOP.window[1]) SHOP.tab[1] = guiCreateTab("Weapons", SHOP.tabpanel[1]) SHOP.panel[1] = guiCreateGridList(0.01, 0.03, 0.98, 0.92, true, SHOP.tab[1]) guiGridListAddColumn(SHOP.panel[1], "Item", 0.5) guiGridListAddColumn(SHOP.panel[1], "Price", 0.5) for i,v in pairs ( items.porsion1List ) do local row = guiGridListAddRow ( SHOP.panel[1] ) guiGridListSetItemText ( SHOP.panel[1], row, 1, v[1], false, false ) guiGridListSetItemText ( SHOP.panel[1], row, 2, v[2].."", false, false ) end SHOP.tab[2] = guiCreateTab("Mags", SHOP.tabpanel[1]) SHOP.panel[2] = guiCreateGridList(0.01, 0.03, 0.97, 0.92, true, SHOP.tab[2]) guiGridListAddColumn(SHOP.panel[2], "Item", 0.5) guiGridListAddColumn(SHOP.panel[2], "Price", 0.5) for i,v in pairs ( items.porsion2List ) do local row = guiGridListAddRow ( SHOP.panel[2] ) guiGridListSetItemText ( SHOP.panel[2], row, 1, v[1], false, false ) guiGridListSetItemText ( SHOP.panel[2], row, 2, v[2].."", false, false ) end SHOP.tab[3] = guiCreateTab("Car Parts", SHOP.tabpanel[1]) SHOP.panel[3] = guiCreateGridList(0.01, 0.03, 0.97, 0.92, true, SHOP.tab[3]) guiGridListAddColumn(SHOP.panel[3], "Item", 0.5) guiGridListAddColumn(SHOP.panel[3], "Price", 0.5) for i,v in pairs ( items.porsion3List ) do local row = guiGridListAddRow ( SHOP.panel[3] ) guiGridListSetItemText ( SHOP.panel[3], row, 1, v[1], false, false ) guiGridListSetItemText ( SHOP.panel[3], row, 2, v[2].."", false, false ) end SHOP.tab[4] = guiCreateTab("Medics", SHOP.tabpanel[1]) SHOP.panel[4] = guiCreateGridList(0.01, 0.03, 0.97, 0.92, true, SHOP.tab[4]) guiGridListAddColumn(SHOP.panel[4], "Item", 0.5) guiGridListAddColumn(SHOP.panel[4], "Price", 0.5) for i,v in pairs ( items.porsion4List ) do local row = guiGridListAddRow ( SHOP.panel[4] ) guiGridListSetItemText ( SHOP.panel[4], row, 1, v[1], false, false ) guiGridListSetItemText ( SHOP.panel[4], row, 2, v[2].."", false, false ) end SHOP.tab[5] = guiCreateTab("Items", SHOP.tabpanel[1]) SHOP.panel[5] = guiCreateGridList(0.01, 0.03, 0.97, 0.92, true, SHOP.tab[5]) guiGridListAddColumn(SHOP.panel[5], "Item", 0.5) guiGridListAddColumn(SHOP.panel[5], "Price", 0.5) for i,v in pairs ( items.porsion5List ) do local row = guiGridListAddRow ( SHOP.panel[5] ) guiGridListSetItemText ( SHOP.panel[5], row, 1, v[1], false, false ) guiGridListSetItemText ( SHOP.panel[5], row, 2, v[2].."", false, false ) end guiSetVisible(SHOP.window[1],false) addEventHandler ( "onClientGUIClick", SHOP.panel[1], click ) addEventHandler ( "onClientGUIClick", SHOP.panel[2], click ) addEventHandler ( "onClientGUIClick", SHOP.panel[3], click ) addEventHandler ( "onClientGUIClick", SHOP.panel[4], click ) addEventHandler ( "onClientGUIClick", SHOP.panel[5], click ) addEventHandler ( "onClientGUIClick", SHOP.button[1], buttonClick ) addEventHandler ( "onClientGUIClick", SHOP.button[2], buttonClick ) end ) bindKey ( "f4", "down", function() if getElementData(localPlayer, "logedin") then local state = ( not guiGetVisible (SHOP.window[1]) ) if not getElementData(localPlayer,"shop.viewing") then setElementData(localPlayer,"shop.viewing",1) end guiSetVisible ( SHOP.window[1], state ) showCursor ( state ) if guiGetVisible(SHOP.window[1]) == false then removeEventHandler ( "onClientGUIClick", root, onSwitch ) if isElement(itemImage) then destroyElement(itemImage) end else addEvent( "onClientGUIClick", true ) addEventHandler ( "onClientGUIClick", root, onSwitch ) end end end ) function buttonClick(button,state) if getElementData(localPlayer, "logedin") then if button == "left" and state == "up" then if getElementData(localPlayer,"shop.viewing") then o = getElementData(localPlayer,"shop.viewing") local nRow, nColumn = guiGridListGetSelectedItem( SHOP.panel[o] ) if nRow ~= -1 and nColumn ~= - 1 then local selectedItem = guiGridListGetItemText ( SHOP.panel[o], guiGridListGetSelectedItem ( SHOP.panel[o] ), 1 ) local price = guiGridListGetItemText ( SHOP.panel[o], guiGridListGetSelectedItem ( SHOP.panel[o] ), 2 ) local money = getPlayerMoney(thePlayer) if (money) >= tonumber(price) then guiLabelSetColor( SHOP.label[1],255,255,255) -- guiSetText( SHOP.label[1],"pietiek nauda") setPlayerMoney(money -tonumber(price)) if selectedItem == "MK 48 Mod 0 Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+100) elseif selectedItem == "M4A1 Holo Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+20) elseif selectedItem == "AK-107 Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+30) elseif selectedItem == "DMR Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+5) elseif selectedItem == "CZ550 Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+10) elseif selectedItem == "PDW Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+30) elseif selectedItem == "M1911 Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+10) elseif selectedItem == "1866 slug" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+7) elseif selectedItem == "Lee Enfield Mag" then setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+10) else setElementData(getLocalPlayer(),selectedItem,getElementData(getLocalPlayer(),selectedItem)+1) end guiLabelSetColor( SHOP.label[1],10,255,10) guiSetText( SHOP.label[1],"You succesfully bought "..selectedItem.." and you still have "..(money -tonumber(price)).." K.B.K Points") else outputChatBox("no enough money !",255,0,0) end end else guiLabelSetColor( SHOP.label[1],255,10,10) guiSetText( SHOP.label[1],"You are missing "..(price -tonumber(money)).." K.B.K Points") end else guiSetText( SHOP.label[1],"Select something first") guiLabelSetColor( SHOP.label[1],255,255,255) end end addEventHandler ( "onClientGUIClick", SHOP.button[1], false ) addEventHandler ( "onClientGUIClick", SHOP.button[2], function() guiSetVisible(SHOP.window[1], false) showCursor(false) end, false ) end function onSwitch() if source == SHOP.panel[1] then setElementData(localPlayer,"shop.viewing",1) elseif source == SHOP.panel[2] then setElementData(localPlayer,"shop.viewing",2) elseif source == SHOP.panel[3] then setElementData(localPlayer,"shop.viewing",3) elseif source == SHOP.panel[4] then setElementData(localPlayer,"shop.viewing",4) elseif source == SHOP.panel[5] then setElementData(localPlayer,"shop.viewing",5) end end function click () if source == SHOP.panel[1] or source == SHOP.panel[2] or source == SHOP.panel[3] or source == SHOP.panel[4] or source == SHOP.panel[5] then local selectedItem = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ) local price = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 2 ) guiSetText( SHOP.label[1],"To buy "..selectedItem.." for "..price.." K.B.K Points press button below") guiLabelSetColor( SHOP.label[1],255,255,255) if isElement(itemImage) then destroyElement(itemImage) itemImage = guiCreateStaticImage( 1050, 350, 450, 250, selectedItem..".png", false ) elseif isElement () then destroyElement(itemImage) else itemImage = guiCreateStaticImage( 1050, 350, 450, 250, selectedItem..".png", false ) end end end function Windows() guiSetVisible(SHOP.panel[1], true) guiSetVisible(SHOP.window[1],true) showCursor(true) setElementData(localPlayer,"shop.viewing",1) end addEvent("openWindow1",true) addEventHandler("openWindow1", getRootElement(), Windows) Server side: addEventHandler("onPlayerLogin",root, function () setElementData(source,"PDW",0) setElementData(source,"Winchester 1866",0) setElementData(source,"M1911",0) setElementData(source,"AK-107",0) setElementData(source,"M4A1 Holo",0) setElementData(source,"DMR",0) setElementData(source,"CZ550",0) setElementData(source,"MK 48 Mod 0",0) setElementData(source,"M4A1 Holo Mag",0) setElementData(source,"DMR Mag",0) setElementData(source,"CZ550 Mag",0) setElementData(source,"M1911 Mag",0) setElementData(source,"PDW Mag",0) setElementData(source,"1866 Slug",0) setElementData(source,"MK 48 Mod 0 Mag",0) setElementData(source,"Medic Kit",0) setElementData(source,"Painkiller",0) setElementData(source,"Morphine",0) setElementData(source,"Bandage",0) setElementData(source,"Water Bottle",0) setElementData(source,"Burger",0) setElementData(source,"Tire",0) setElementData(source,"Engine",0) setElementData(source,"Tank Parts",0) setElementData(source,"Camouflage Clothing",0) setElementData(source,"Army Clothing",0) setElementData(source,"Ghost Clothing",0) setElementData(source,"K.B.K Backpack",0) setElementData(source,"Ghillie Suit",0) setElementData(source,"Civilian Clothing",0) setElementData(source,"GPS",0) setElementData(source,"Map",0) setElementData(source,"Toolbox",0) end )addEventHandler("onPlayerLogin",root, function () setElementData(source,"PDW",0) setElementData(source,"Winchester 1866",0) setElementData(source,"M1911",0) setElementData(source,"AK-107",0) setElementData(source,"M4A1 Holo",0) setElementData(source,"DMR",0) setElementData(source,"CZ550",0) setElementData(source,"MK 48 Mod 0",0) setElementData(source,"M4A1 Holo Mag",0) setElementData(source,"DMR Mag",0) setElementData(source,"CZ550 Mag",0) setElementData(source,"M1911 Mag",0) setElementData(source,"PDW Mag",0) setElementData(source,"1866 Slug",0) setElementData(source,"MK 48 Mod 0 Mag",0) setElementData(source,"Medic Kit",0) setElementData(source,"Painkiller",0) setElementData(source,"Morphine",0) setElementData(source,"Bandage",0) setElementData(source,"Water Bottle",0) setElementData(source,"Burger",0) setElementData(source,"Tire",0) setElementData(source,"Engine",0) setElementData(source,"Tank Parts",0) setElementData(source,"Camouflage Clothing",0) setElementData(source,"Army Clothing",0) setElementData(source,"Ghost Clothing",0) setElementData(source,"K.B.K Backpack",0) setElementData(source,"Ghillie Suit",0) setElementData(source,"Civilian Clothing",0) setElementData(source,"GPS",0) setElementData(source,"Map",0) setElementData(source,"Toolbox",0) end ) marker1 = createMarker ( 177.13320922852, 2818.298828125, 68.174095153809, "cylinder", 1.5, 30, 212, 5 ) function HitMark(hitPlayer) triggerClientEvent (hitPlayer,"openWindow1",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit", marker1, HitMark)
-
Well with some working around i fixed this this is what I added to Client script: function Windows() guiSetVisible(SHOP.panel[1], true) guiSetVisible(SHOP.window[1],true) showCursor(true) setElementData(localPlayer,"shop.viewing",1) end addEvent("openWindow1",true) addEventHandler("openWindow1", getRootElement(), Windows) And into server side: marker1 = createMarker ( 177.13320922852, 2818.298828125, 68.174095153809, "cylinder", 1.5, 30, 212, 5 ) function HitMark(hitPlayer) triggerClientEvent (hitPlayer,"openWindow1",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit", marker1, HitMark)
-
So @DeadthStrock i tried triggering the shop with a marker, when the player goes in the marker, the shop gui pops up for the player. I tried with hitmark but in debugscript it says that server triggered clientside event, but event is not marked as remotly triggerable. So my guess is it cant start an event from the client script becuse we are using serverside or? This is a bit of the serverside code where i added the lines below, havnt touched anything else. marker1 = createMarker(182.59259033203, 2821.6428222656, 67.378341674805, "cylinder", 1.5, 4, 156, 14 ) function HitMark(hitPlayer) triggerClientEvent (hitPlayer,"onClientGUIClick",getRootElement(),hitPlayer) end addEventHandler("onMarkerHit", marker1, HitMark) Or maybe the defined "onClientGUIClick" is wrong?
-
Nevermind, hadnt added the source of the images wich were in a folder but removed thet folder now so all works fine!
-
@DeadthStrock Could i send you the whole script somewhere private? apperantly only ak-107 is showing even tho ive added picture for other stuff..
-
yes true! I always try sometimes i succed, but most of the times i dont. but when i do succed or get help i actually learn how to use those stuff so next time i know better
-
Works Like a charm. This is exactly what i did earlier, but the files with space between them, for example MK 48 Mod 0 has alot of spaces in its name, but i cant put spaces in the png names because it doesnt detect them somehow @DeadthStrock And when you choose the weapons and press f4 to close the gui. the picture is still drawn hmm
-
Ok so this is what i came to after you gave me the tips, its working when i click on mk mod or ak it shows those pictures, but the pictures overlap eachother and dont dissapear after i close the gui, how do i check if the customer is clicking another item so the first picture gets destroyed and when gui closes the image also destroys/gets removed? function click () if source == SHOP.panel[1] or source == SHOP.panel[2] or source == SHOP.panel[3] or source == SHOP.panel[4] or source == SHOP.panel[5] then local selectedItem = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ) local price = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 2 ) guiSetText( SHOP.label[1],"To buy "..selectedItem.." for "..price.." K.B.K Points press button below") guiLabelSetColor( SHOP.label[1],255,255,255) guiCreateStaticImage( 500, 500, 400, 400, selectedItem..".png", false ) end end
-
I was thinking about using this function which is already in the client sided code. But i think i need to make a table for each item, and their picture name. is that correcT? function click () if source == SHOP.panel[1] or source == SHOP.panel[2] or source == SHOP.panel[3] then local selectedItem = guiGridListGetItemText ( source, guiGridListGetSelectedItem ( source ), 1 ) end end
-
@DeadthStrock Yes i understand correctly, the porsionlists are different tabs, ill categories the items correct. THank you so much for all this help!!! @DeadthStrock, if i want to dxDrawImage on the right when you click an item, for example you click ak and it draws an ak picture on the right so you can see what you are buying, how do i do this together with the click button code?