CodX Posted December 6, 2017 Posted December 6, 2017 (edited) Hello ! I've made this script: function buletin(thePlayer, commandName) if commandName == "buletin" then local nume_jucator = getPlayerName(thePlayer):gsub("_", " ") triggerEvent('sendAme', thePlayer, "duce mana dreapta catre buzunarul drept urmand s-o bage in el, apuca ce e acolo si scoate.") triggerEvent('sendAdo', thePlayer, "Se poate observa ca a scos un portofel.") triggerEvent('sendAme', thePlayer, "il deschide.") triggerEvent('sendAdo', thePlayer, "Se poate observa un buletin si alte acte.") triggerEvent('sendAme', thePlayer, "duce mana stanga catre buletin urmand sa-l scoata si sa-l citeasca, apoi baga buletinul inapoi, inchide portofelul si-l baga in buzunar.") outputChatBox("#C0C0C0San Andreas #66B2FFSan #FFFF33Andr#FF0000eas #C0C0C0San Andreas", thePlayer, 255, 255, 255, true) outputChatBox(" ", thePlayer, 0, 0, 0) outputChatBox("#FFFF66Nume si Prenume:#FFFFFF "..nume_jucator, thePlayer, 255, 255, 255, true) outputChatBox("#FFFF66Domiciliu:#FFFFFF Los Santos", thePlayer, 255, 255, 255, true) outputChatBox("#FFFF66Data Nasterii:#FFFFFF "..exports.global:getPlayerDoB(thePlayer), thePlayer, 255, 255, 255, true) end end addCommandHandler ("buletin", buletin) function askid(thePlayer, commandName, targetPlayer) if commandName == "askid" then local nume_jucator = getPlayerName(thePlayer):gsub("_", " ") if not (targetPlayer) then outputChatBox ("Comanda: /"..commandName.." [ID Jucator]", thePlayer, 255, 255, 255) else local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targerPlayer) outputChatBox("I-ai aratat buletinul lui "..tinta.. ".", thePlayer, 255, 178, 102) outputChatBox("Buletinul lui "..nume_jucator, tinta, 255, 178, 102) outputChatBox(" ", tinta, 0, 0, 0) outputChatBox("#C0C0C0San Andreas #66B2FFSan #FFFF33Andr#FF0000eas #C0C0C0San Andreas", targetPlayer, 255, 255, 255, true) outputChatBox(" ", targetPlayer, 0, 0, 0) outputChatBox("#FFFF66Nume si Prenume:#FFFFFF "..nume_jucator, targetPlayer, 255, 255, 255, true) outputChatBox("#FFFF66Domiciliu:#FFFFFF Los Santos", targetPlayer, 255, 255, 255, true) outputChatBox("#FFFF66Data Nasterii:#FFFFFF "..exports.global:getPlayerDoB(thePlayer), targetPlayer, 255, 255, 255, true) end end end addCommandHandler ("askid", askid) <meta> <script src="script.lua" type="server" /> </meta> When i type "/askid 3" or "/askid Vladus_Griffin", give me error and i don't know why. Error: ERROR: !buletin/script.lua:28: attempt to concatenate local 'tinta' (a nil value) Can you help me please ? Edited December 6, 2017 by CodX
Moderators IIYAMA Posted December 7, 2017 Moderators Posted December 7, 2017 (edited) I am not sure what exactly the problem is. Try to use call instead of exports if you are 100% sure the returned values of the function are correct. call https://wiki.multitheftauto.com/wiki/Call And always validate data, which you receive from a function before continuing executing more code. local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targerPlayer) < < < Validation moment: if targetPlayer and tinta then outputChatBox("I-ai aratat buletinul lui "..tinta.. ".", thePlayer, 255, 178, 102) outputChatBox("Buletinul lui "..nume_jucator, tinta, 255, 178, 102) outputChatBox(" ", tinta, 0, 0, 0) outputChatBox("#C0C0C0San Andreas #66B2FFSan #FFFF33Andr#FF0000eas #C0C0C0San Andreas", targetPlayer, 255, 255, 255, true) outputChatBox(" ", targetPlayer, 0, 0, 0) outputChatBox("#FFFF66Nume si Prenume:#FFFFFF "..nume_jucator, targetPlayer, 255, 255, 255, true) outputChatBox("#FFFF66Domiciliu:#FFFFFF Los Santos", targetPlayer, 255, 255, 255, true) outputChatBox("#FFFF66Data Nasterii:#FFFFFF "..exports.global:getPlayerDoB(thePlayer), targetPlayer, 255, 255, 255, true) < < < end Edited December 7, 2017 by IIYAMA Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
pa3ck Posted December 7, 2017 Posted December 7, 2017 local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targerPlayer) ---> local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) targerPlayer --> targetPlayer, just a small typo in your code.
CodX Posted December 7, 2017 Author Posted December 7, 2017 4 hours ago, pa3ck said: local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targerPlayer) ---> local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) targerPlayer --> targetPlayer, just a small typo in your code. Wow, i'm so stupid.. Now it work ! Thanks for help !
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