KiritoAguiar Posted August 26, 2021 Posted August 26, 2021 to fazendo um script e preciso q ele pegue uma variavel q ta em outro script, outra resource msm, teria q pegar essa variavel exportando mas n to conseguindo fazer Exemplo: SERVER_PASSWORD = "Mw4U8Bq!##K%lBBXC0*BFLUgOTY!%Zkdv4MhD@CtP^D&ZUOfd3" function getServerPassword() -- Função q quero exportar exportada return SERVER_PASSWORD end Meta: <script src="SKServerIP.lua" type="server" /> <export function="getServerPassword" type="server" /> <min_mta_version server="1.5.6-9.18728" client="1.5.6-9.18728" /> <download_priority_group>2</download_priority_group> E no outro script q quero pegar o SERVER_PASSWORD ta assim: function teste () local senha = exports["SKServerIP"]:getServerPassword () or 0 if (senha ~= "Mw4U8Bq!##K%lBBXC0*BFLUgOTY!%Zkdv4MhD@CtP^D&ZUOfd3") then outputChatBox ("teste") end end addEventHandler ("onResourceStart", resourceRoot, teste) E no debug da esse erro se referindo a linha 2 desse ultimo script: Access denied @ "call" [string "?"]
Boechat Posted August 27, 2021 Posted August 27, 2021 20 hours ago, KiritoAguiar said: to fazendo um script e preciso q ele pegue uma variavel q ta em outro script, outra resource msm, teria q pegar essa variavel exportando mas n to conseguindo fazer Exemplo: SERVER_PASSWORD = "Mw4U8Bq!##K%lBBXC0*BFLUgOTY!%Zkdv4MhD@CtP^D&ZUOfd3" function getServerPassword() -- Função q quero exportar exportada return SERVER_PASSWORD end Meta: <script src="SKServerIP.lua" type="server" /> <export function="getServerPassword" type="server" /> <min_mta_version server="1.5.6-9.18728" client="1.5.6-9.18728" /> <download_priority_group>2</download_priority_group> E no outro script q quero pegar o SERVER_PASSWORD ta assim: function teste () local senha = exports["SKServerIP"]:getServerPassword () or 0 if (senha ~= "Mw4U8Bq!##K%lBBXC0*BFLUgOTY!%Zkdv4MhD@CtP^D&ZUOfd3") then outputChatBox ("teste") end end addEventHandler ("onResourceStart", resourceRoot, teste) E no debug da esse erro se referindo a linha 2 desse ultimo script: Access denied @ "call" [string "?"] O nome do resource é SKServerIP? Pois percebi que é o mesmo nome do arquivo .lua, talvez você tenha confundido... A sintaxe é assim: exports["NomeDoMod"]:getServerPassword () ou exports.NomeDoMod:getServerPassword ()
KiritoAguiar Posted August 28, 2021 Author Posted August 28, 2021 (edited) Sim a resource e o arquivo lua tem o mesmo nome, não é o motivo do erro msm escrevendo do outro jeito q vc disse o erro continua Edited August 28, 2021 by KiritoAguiar
Other Languages Moderators Lord Henry Posted August 31, 2021 Other Languages Moderators Posted August 31, 2021 Assim como lhe respondi no privado, o erro acontece pois ele não consegue modificar uma função nativa do MTA getServerPassword Troque o nome da função por alguma que não seja nativa, por exemplo getServerPass e o script funcionará normalmente.
Boechat Posted September 1, 2021 Posted September 1, 2021 15 hours ago, Lord Henry said: Assim como lhe respondi no privado, o erro acontece pois ele não consegue modificar uma função nativa do MTA getServerPassword Troque o nome da função por alguma que não seja nativa, por exemplo getServerPass e o script funcionará normalmente. Mas não é possível sobrescrever funções nativas? Pelo que eu li nesse tópico sobre proteção de scripts achei que fosse possível...
Other Languages Moderators Lord Henry Posted September 1, 2021 Other Languages Moderators Posted September 1, 2021 (edited) É possível de outra forma. Se utilizar call dai não funciona. Edited September 1, 2021 by Lord Henry 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now