TigreBlanco Posted December 9, 2012 Share Posted December 9, 2012 Hola Muy Buenas a Todos , Tengo un Pequeño Problema con las Restrinciones/Permisos de Scripts para que lo Usen la Gente que no Sea Solo Admin, que Sea Tambien Moderador/Supermod/VIP/Yo Etc. Me Explico: Necesito que Unos Resources Fabricados por Mi no Queden Restringidos Para Todos los Grupos de ACL, es Decir, que los Puedan Usar Los Vips, Moderadores, Etc, Pero que no Los Puedan Usar la otra Gente del Server, como los Guest. Un Ejemplo de Resource No Fabricado por Mi (Water_Level): Water_Gui.lua: localPlayer = getLocalPlayer() allow_negative = "false" x,y = guiGetScreenSize() WaterWin = {} function isNumeric(a) return type(tonumber(a)) == "number" end WaterWin = guiCreateWindow(x/2 - 127,y/2 - 70,254,140,"Nivel de Agua",false) EditCurrLevel = guiCreateEdit(105,35,136,23,"",false,WaterWin) guiEditSetReadOnly(EditCurrLevel,true) EditObjLevel = guiCreateEdit(105,67,135,22,"",false,WaterWin) LblCurrentLevel = guiCreateLabel(10,38,87,22,"Nivel de Ahora",false,WaterWin) LblObjectiveLevel = guiCreateLabel(10,72,85,14,"Nivel Objetivo",false,WaterWin) guiLabelSetColor(LblObjectiveLevel,255,0,0) BtnCancel = guiCreateButton(171,111,69,20,"Cancelar",false,WaterWin) BtnOk = guiCreateButton(95,111,69,20,"Poner",false,WaterWin) guiSetVisible ( WaterWin, false ) function showWindow(level, neg, highlevel) guiSetText(EditCurrLevel, level) allow_negative = neg if (highlevel ~= nil) then if (isNumeric(highlevel)) then guiSetText(EditObjLevel, highlevel) changeWaterLevel() else showCursor(true) guiSetVisible(WaterWin, true) end else showCursor(true) guiSetVisible(WaterWin, true) end end addEvent("onShowWindow", true) addEventHandler("onShowWindow", getRootElement(), showWindow) function onClickBtn ( button, state ) if (button == "left" and state == "up") then if (source == BtnCancel) then --if he clicked Cancel showCursor(false) guiSetVisible ( WaterWin, false ) elseif (source == BtnOk) then --if he clicked Ok changeWaterLevel() end end end addEventHandler("onClientGUIClick", BtnOk, onClickBtn, false) addEventHandler("onClientGUIClick", BtnCancel, onClickBtn, false) function changeWaterLevel() if isNumeric(guiGetText(EditObjLevel)) then if ((allow_negative) == "false" and (tonumber(guiGetText(EditObjLevel)) < 0)) then guiEditSetCaretIndex ( EditObjLevel, 0 ) else triggerServerEvent( "onWaterLevel", localPlayer, localPlayer, guiGetText(EditObjLevel) ) showCursor(false) guiSetVisible ( WaterWin, false ) end else guiEditSetCaretIndex ( EditObjLevel, 0 ) end return true end bindKey("8", "6", changeWaterLevel) Water_level.lua: level = 0 highlevel = 0 floodWater1 = 0 function setAllWatersLevel(level) setWaterLevel(level) if isElement(floodWater1) then if (getElementType(floodWater1) == "water") then if (level > 0.2) then setWaterLevel(floodWater1, level) else setWaterLevel(floodWater1, -500) end end end end function checkLevel(glevel) local allow_negative = get("allow_negative") if ((allow_negative == "false") and (tonumber(glevel) < 0)) then return false end return true end function setFloodWeather() local flood_weather = get("flood_weather") if (flood_weather ~= "") then setWeather(tonumber(flood_weather)) end end function setFloodEndWeather() local flood_end_weather = get("flood_end_weather") if (flood_end_weather ~= "") then setWeather(tonumber(flood_end_weather)) end end function waterLevel ( source, glevel ) if ( checkLevel(glevel) == true ) then highlevel = tonumber ( glevel ) if (highlevel == nil) then highlevel = 0 end if (highlevel ~= level) then if ( isTimer(waterTimer)) then killTimer(waterTimer) end --water is going up if (highlevel > level) then setFloodWeather() waterTimer = setTimer ( addSomeWater, 100, 0, highlevel ) if (get("show_messages") == "true") then if (highlevel > -0.2) then outputChatBox ( "Alerta: Se Acerca un Tsunami a San Andreas, Nivel de "..tostring(highlevel).." metros", getRootElement(), 255, 0, 0 ) else outputChatBox ( "Informacion: El Nivel de Agua Esta Bajando a "..tostring(highlevel).." metros", getRootElement(), 0, 255, 0 ) end end else --water is going down setFloodEndWeather() waterTimer = setTimer ( removeSomeWater, 100, 0, highlevel ) if (get("show_messages") == "true") then if (highlevel > -0.2) then outputChatBox ( "Informacion: El Nivel de Agua Esta Bajando a "..tostring(highlevel).." metros", getRootElement(), 0, 255, 0 ) else outputChatBox ( "Alerta: Se Acerca un Tsunami a San Andreas, Nivel de "..tostring(highlevel).." metros", getRootElement(), 255, 0, 0 ) end end end outputDebugString ( "Nivel de Agua Cambiado Por " .. getPlayerName ( source ) .. " to a level " .. highlevel .. ".", 3 ) end end end addEvent( "onWaterLevel", true ) addEventHandler( "onWaterLevel", getRootElement(), waterLevel ) function showClientGui(source, command, highlevel) local neg = get("allow_negative") if (get("restrict_to") ~= "") then if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( get("restrict_to") ) ) ) then triggerClientEvent( source, "onShowWindow", getRootElement(), level, neg, highlevel) end else triggerClientEvent( source, "onShowWindow", getRootElement(), level, neg, highlevel) end end addCommandHandler("agua", showClientGui) function addSomeWater ( highlevel ) local thelevel = level local speed = tonumber(get("speed")) level = thelevel + tonumber(speed) setAllWatersLevel(level) if (level >= highlevel) then level = highlevel if ( isTimer(waterTimer)) then killTimer(waterTimer) end setFloodEndWeather() end end function removeSomeWater ( highlevel ) local thelevel = level local speed = tonumber(get("speed")) level = thelevel - speed setAllWatersLevel(level) if (level <= highlevel) then level = highlevel if ( isTimer(waterTimer)) then killTimer(waterTimer) end end end function initialize() setWaterLevel(0) floodWater1 = createWater ( -2998, -2998, -500, 2998, -2998, -500, -2998, 2998, -500, 2998, 2998, -500) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), initialize) function destroy() if ( isTimer(waterTimer)) then killTimer(waterTimer) end setWaterLevel(floodWater1, -500) setWaterLevel(0) setFloodEndWeather() end addEventHandler ( "onResourceStop", getRootElement(), destroy) function onPlayerJoin() setAllWatersLevel(level) end addEventHandler( "onPlayerJoin", getRootElement(), onPlayerJoin ) Meta.xml (Aqui es Donde Estan las Restrinciones): <meta> <info author="Dr4x" version="1.1.5" name="water_level" decription="Progressive Change of the Water Level" type="script" /> <script src="water_gui.lua" type="client" /> <script src="water_level.lua" type="server" /> <settings> <setting name="*show_messages" value="true" /> <setting name="*speed" value="0.01" /> <setting name="*allow_negative" value="true" /> <setting name="*restrict_to" value="Admin, Moderator, SuperModerator, VIP, Fundador" /> ---Las Restrinciones en mi Caso Aqui es Donde me Equivoco, no Quiero que lo Usen los Guests <setting name="*flood_weather" value="8" /> <setting name="*flood_end_weather" value="14" /> </settings> </meta> Un Ejemplo de Resource Fabricado por Mi: Atencion.lua: function sayMessage(source, command, ...) theText = {...} text = table.concat(theText, " ") playerAcc = getPlayerAccount(source) if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("Admin", Moderator, SuperModerator, Fundador, VIP")) then ---Aqui es Donde me Vuelvo a Equivocar if theText then if not (text == "") then outputChatBox("-> #FF0000Atencion: #FF4444"..text, getRootElement(), 0,153,255, true) else outputChatBox("-> #FF4444Escribe el mensaje",source, 0,153,255,true) end end end end addCommandHandler("atencion", sayMessage) Espero que me Ayuden Visiten mi Server si Quieren, es un Freeroam Buenisimo: Juramento Freeroam, Nuestro Blog por si Acaso: http://www.mtajuraserver.blogspot.com Foro: http://www.mtajuraserver.foroactivo.com Link to comment
Alexs Posted December 9, 2012 Share Posted December 9, 2012 Verifica si tienen el rango deseado con: https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup Link to comment
TigreBlanco Posted December 9, 2012 Author Share Posted December 9, 2012 Verifica si tienen el rango deseado con:https://wiki.multitheftauto.com/wiki/IsObjectInACLGroup Si lo Tengo, no me Entendistes , lo que Quiero es agregar mas Grupos de ACL, no Solo Admin, Quiero Agregar Tambien Mod, SuperMod, VIP, y Fundador Link to comment
Plate Posted December 10, 2012 Share Posted December 10, 2012 Proba haci function sayMessage(source, command, ...) theText = {...} text = table.concat(theText, " ") playerAcc = getPlayerAccount(source) if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("Admin, Moderator, SuperModerator, Fundador, VIP")) then ---Aqui es Donde me Vuelvo a Equivocar if theText then if not (text == "") then outputChatBox("-> #FF0000Atencion: #FF4444"..text, getRootElement(), 0,153,255, true) else outputChatBox("-> #FF4444Escribe el mensaje",source, 0,153,255,true) end end end end addCommandHandler("atencion", sayMessage) Link to comment
Sasu Posted December 10, 2012 Share Posted December 10, 2012 function sayMessage(source, command, ...) theText = {...} text = table.concat(theText, " ") playerAcc = getPlayerAccount(source) if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("Admin", "Moderator", "SuperModerator", "Fundador", "VIP")) then ---Aqui es Donde me Vuelvo a Equivocar if theText then if not (text == "") then outputChatBox("-> #FF0000Atencion: #FF4444"..text, getRootElement(), 0,153,255, true) else outputChatBox("-> #FF4444Escribe el mensaje",source, 0,153,255,true) end end end end addCommandHandler("atencion", sayMessage) Creo que seria asi ya que si no le pones "comillas" a cada grupo ACL te lo tomara como un solo grupo ACL. Atte Sasuke. Link to comment
Castillo Posted December 10, 2012 Share Posted December 10, 2012 aclGetGroup solo obtiene un grupo por ves, necesitas hacer un loop. Link to comment
Sasu Posted December 11, 2012 Share Posted December 11, 2012 (edited) function sayMessage(source, command, ...) theText = {...} text = table.concat(theText, " ") playerAcc = getPlayerAccount(source) if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("Admin") then end if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("Moderator") then end if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("SuperModerator") then end if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("Fundador") then end if isObjectInACLGroup("user."..getAccountName(playerAcc), aclGetGroup("VIP") then if theText then if not (text == "") then outputChatBox("-> #FF0000Atencion: #FF4444"..text, getRootElement(), 0,153,255, true) else outputChatBox("-> #FF4444Escribe el mensaje",source, 0,153,255,true) end end end end addCommandHandler("atencion", sayMessage) EDITADO: Tal vez asi. Edited December 11, 2012 by Guest Link to comment
Castillo Posted December 11, 2012 Share Posted December 11, 2012 Solo si el jugador esta en todos esos grupos funcionara el comando, no se si eso es lo que querias. Link to comment
Sasu Posted December 11, 2012 Share Posted December 11, 2012 Solo si el jugador esta en todos esos grupos funcionara el comando, no se si eso es lo que querias. No es como queria crear el script. Quiero hacerlo que el jugador este en "uno" de estos grupos. Link to comment
Castillo Posted December 11, 2012 Share Posted December 11, 2012 function sayMessage ( source, command, ... ) local theText = { ... } local text = table.concat ( theText, " " ) local playerAcc = getPlayerAccount ( source ) if ( theText ) then if ( text ~= "" ) then for _, group in ipairs ( { "Admin", "Moderator", "SuperModerator", "Fundador", "VIP" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( playerAcc ), aclGetGroup ( group ) ) then outputChatBox ( "-> #FF0000Atencion: #FF4444".. text, root, 0, 153, 255, true ) break end end else outputChatBox ( "-> #FF4444Escribe el mensaje", source, 0, 153, 255, true ) end end end addCommandHandler ( "atencion", sayMessage ) Con eso deberia funcionar. Link to comment
TigreBlanco Posted December 12, 2012 Author Share Posted December 12, 2012 function sayMessage ( source, command, ... ) local theText = { ... } local text = table.concat ( theText, " " ) local playerAcc = getPlayerAccount ( source ) if ( theText ) then if ( text ~= "" ) then for _, group in ipairs ( { "Admin", "Moderator", "SuperModerator", "Fundador", "VIP" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( playerAcc ), aclGetGroup ( group ) ) then outputChatBox ( "-> #FF0000Atencion: #FF4444".. text, root, 0, 153, 255, true ) break end end else outputChatBox ( "-> #FF4444Escribe el mensaje", source, 0, 153, 255, true ) end end end addCommandHandler ( "atencion", sayMessage ) Con eso deberia funcionar. Gracias a Todos, Asi que Es Asi, Poniendo Comillas mas Coma, Ya creo que Intente Hacerlo Hace Tiempo, Despues lo Intento otra Vez Cuando me Heche un Ciesta Link to comment
Castillo Posted December 12, 2012 Share Posted December 12, 2012 Solo para que sepas, no agrege comillas y comas nada mas. De nada. Link to comment
TigreBlanco Posted December 13, 2012 Author Share Posted December 13, 2012 una ultima pregunta, como lo puedo hacer en otros scripts por ejemplo water level, que tengo que poner aparte de las comillas comas etc, se que tiene algo que ver con isobjectaclgroup, ya que en el caso de water level, para permitir grupos se encuentra en meta.xml Link to comment
Sasu Posted December 13, 2012 Share Posted December 13, 2012 Cambia esto en water_level.lua if (get("restrict_to") ~= "") then if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( get("restrict_to") ) ) ) then por esto for _, group in ipairs ( { "Admin", "Moderator", "SuperModerator", "Fundador", "VIP" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( playerAcc ), aclGetGroup ( group ) ) then Link to comment
TigreBlanco Posted December 13, 2012 Author Share Posted December 13, 2012 Cambia esto en water_level.lua if (get("restrict_to") ~= "") then if ( isObjectInACLGroup ( "user." .. getAccountName ( getPlayerAccount ( source )), aclGetGroup ( get("restrict_to") ) ) ) then por esto for _, group in ipairs ( { "Admin", "Moderator", "SuperModerator", "Fundador", "VIP" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( playerAcc ), aclGetGroup ( group ) ) then No Funciona se me Estropeo el Resource Link to comment
Castillo Posted December 13, 2012 Share Posted December 13, 2012 for _, group in ipairs ( { "Admin", "Moderator", "SuperModerator", "Fundador", "VIP" } ) do if isObjectInACLGroup ( "user.".. getAccountName ( getPlayerAccount ( source ) ), aclGetGroup ( group ) ) then P.D: Vas a necesitar poner otro 'end' para cerrar el for-loop. Link to comment
Recommended Posts