keymetaphore Posted February 1, 2017 Share Posted February 1, 2017 function issueJail(source, command, targetPlayer, reason) local source = getPlayerFromName(source) local targetPlayer = getPlayerFromName(targetPlayer) if targetPlayer and reason then outputChatBox("Spēlētājs " ..targetPlayer.." ir saņēmis brīdinājumu par "..reason..".", source, 255,0, 0) outputChatBox("Jūs esat RP pārkāpuma ierakstu no administratora " .. source .. ".", targetPlayer, 255, 0, 0) outputChatBox("Sakrājot vairākus šādus brīdinājumus, jūs saņemsiet liegumu no servera.", targetPlayer, 255, 0, 0) outputChatBox("Jūsu pārkāpums: "..reason..".", targetPlayer, 255, 0, 0) outputChatBox("Vai brīdinājums ir izsniegts nepatiesi? Ziņo forumā!", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) else outputChatBox("Sintakse: /"..command.. " [Daļa no vārda/ID] [Iemesls]", source, 255, 194, 14) return false end end addCommandHandler("pwarn", issueJail) So, I wrote this code, and I keep getting this error - Attempt to concatenate local ' targetPlayer' (a userdata value) I tried to use it with getPlayerName() too, but it didn't work. Any hints? Link to comment
LoPollo Posted February 1, 2017 Share Posted February 1, 2017 addCommandHandler reading the wiki will be enough Link to comment
Dimos7 Posted February 1, 2017 Share Posted February 1, 2017 you are try use a name for example bloomed and do something to him or just want take a player with part of name if you try like blo it not work it need wrote whole name if has hexcode hexcode too Link to comment
keymetaphore Posted February 1, 2017 Author Share Posted February 1, 2017 13 minutes ago, LoPollo said: addCommandHandler reading the wiki will be enough player playerSource, string commandName, [string arg1, string arg2, ...] function issueJail(triggerer - source, commandname - command, arg1 -targetPlayer, arg2 -reason) Link to comment
Addlibs Posted February 1, 2017 Share Posted February 1, 2017 Line 6 should be getPlayerName(targetPlayer) while all the other targetPlayer can remain as they are. Link to comment
keymetaphore Posted February 3, 2017 Author Share Posted February 3, 2017 On 2/1/2017 at 19:25, MrTasty said: Line 6 should be getPlayerName(targetPlayer) while all the other targetPlayer can remain as they are. Got a warning - Bad argument @ 'getPlayerName'[Expected element at argument 1, got string 'James'] ( it's a full name ) function issueJail(source, command, targetPlayer, reason) if targetPlayer and reason then local targetPlayer = getPlayerName(targetPlayer) outputChatBox("Spēlētājs " ..targetPlayer.." ir saņēmis brīdinājumu par "..reason..".", source, 255,0, 0) outputChatBox("Jūs esat RP pārkāpuma ierakstu no administratora " .. source .. ".", targetPlayer, 255, 0, 0) outputChatBox("Sakrājot vairākus šādus brīdinājumus, jūs saņemsiet liegumu no servera.", targetPlayer, 255, 0, 0) outputChatBox("Jūsu pārkāpums: "..reason..".", targetPlayer, 255, 0, 0) outputChatBox("Vai brīdinājums ir izsniegts nepatiesi? Ziņo forumā!", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) else outputChatBox("Sintakse: /"..command.. " [Daļa no vārda/ID] [Iemesls]", source, 255, 194, 14) return false end end addCommandHandler("pwarn", issueJail) Link to comment
koragg Posted February 3, 2017 Share Posted February 3, 2017 (edited) Try : getPlayerFromPartialName (targetPlayer) https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName That's not a built-in mta function so you'll need to copy the whole wiki code into your file before using it. Edited February 3, 2017 by koragg Link to comment
keymetaphore Posted February 3, 2017 Author Share Posted February 3, 2017 5 hours ago, koragg said: Try : getPlayerFromPartialName (targetPlayer) https://wiki.multitheftauto.com/wiki/GetPlayerFromPartialName That's not a built-in mta function so you'll need to copy the whole wiki code into your file before using it. Did it, with the whole function. Attempt to concetanate (might be wrong) local targetPlayer(a userdata value) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function issueJail(source, command, targetPlayer, reason) if targetPlayer and reason then local targetPlayer = getPlayerFromPartialName(targetPlayer) outputChatBox("Spēlētājs " ..targetPlayer.." ir saņēmis brīdinājumu par "..reason..".", source, 255,0, 0) outputChatBox("Jūs esat RP pārkāpuma ierakstu no administratora " .. source .. ".", targetPlayer, 255, 0, 0) outputChatBox("Sakrājot vairākus šādus brīdinājumus, jūs saņemsiet liegumu no servera.", targetPlayer, 255, 0, 0) outputChatBox("Jūsu pārkāpums: "..reason..".", targetPlayer, 255, 0, 0) outputChatBox("Vai brīdinājums ir izsniegts nepatiesi? Ziņo forumā!", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) outputChatBox("", targetPlayer, 255, 0, 0) else outputChatBox("Sintakse: /"..command.. " [Daļa no vārda/ID] [Iemesls]", source, 255, 194, 14) return false end end addCommandHandler("pwarn", issueJail) rip, still need help Link to comment
Mr.Loki Posted February 3, 2017 Share Posted February 3, 2017 Line 18: outputChatBox("Spēlētājs " ..getPlayerName(targetPlayer).." ir saņēmis brīdinājumu par "..reason..".", source, 255,0, 0) 2 Link to comment
keymetaphore Posted February 3, 2017 Author Share Posted February 3, 2017 4 hours ago, loki2143 said: Line 18: outputChatBox("Spēlētājs " ..getPlayerName(targetPlayer).." ir saņēmis brīdinājumu par "..reason..".", source, 255,0, 0) Thank you, I just can't believe that I didn't try that. Lock please. @ccw Link to comment
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