crismar Posted April 2, 2014 Share Posted April 2, 2014 So I have this script: function adminPM(thePlayer, theCMD, theTarget, ...) if theTarget ~= nil and hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") setElementData(theTargetElement, "lastpm", getPlayerName(thePlayer)) outputChatBox("#ff0000MESAJ DE LA UN ADMINISTRATOR: #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) else outputChatBox("/apm [Jucator] [Mesaje]", thePlayer, 255, 0, 0, true) end end end addCommandHandler("apm", adminPM, false) function adminReply(thePlayer, theCMD, theTarget, ...) local theTargetElement = getElementData(thePlayer, "lastpm") local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("#ff0000MESAJ DE LA "..getPlayerName(thePlayer)..": #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) end addCommandHandler("rpm", adminReply, false) Or well, part of script. The /apm part works perfectly. The /rpm part seems to do what it's supposed to be but theTargetElement doesn't get parassed as a target but as a string. Full Debugscript error is something like: outputChatBox expected element at argument 2, got string [ 'lastpm' value ] So it works, I just don't know how to convert theTargetElement from a string to a element. Any ideas ? Link to comment
iPrestege Posted April 2, 2014 Share Posted April 2, 2014 function adminPM(thePlayer, theCMD, theTarget, ...) if theTarget ~= nil and hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") setElementData( theTargetElement, "lastpm",thePlayer ) outputChatBox("#ff0000MESAJ DE LA UN ADMINISTRATOR: #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) else outputChatBox("/apm [Jucator] [Mesaje]", thePlayer, 255, 0, 0, true) end end end addCommandHandler("apm", adminPM, false) function adminReply(thePlayer, theCMD, theTarget, ...) local theTargetElement = getElementData(thePlayer, "lastpm") local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("#ff0000MESAJ DE LA "..getPlayerName(thePlayer)..": #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) end addCommandHandler("rpm", adminReply, false) Link to comment
crismar Posted April 2, 2014 Author Share Posted April 2, 2014 * Edit: I forgot to mention the error refers to this line: outputChatBox("#ff0000MESAJ DE LA "..getPlayerName(thePlayer)..": #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) Link to comment
crismar Posted April 2, 2014 Author Share Posted April 2, 2014 function adminPM(thePlayer, theCMD, theTarget, ...) if theTarget ~= nil and hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") setElementData( theTargetElement, "lastpm",thePlayer ) outputChatBox("#ff0000MESAJ DE LA UN ADMINISTRATOR: #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) else outputChatBox("/apm [Jucator] [Mesaje]", thePlayer, 255, 0, 0, true) end end end addCommandHandler("apm", adminPM, false) function adminReply(thePlayer, theCMD, theTarget, ...) local theTargetElement = getElementData(thePlayer, "lastpm") local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("#ff0000MESAJ DE LA "..getPlayerName(thePlayer)..": #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) end addCommandHandler("rpm", adminReply, false) Erm sorry but could you tell me what you changed to my code ? I'm trying to learn from my mistakes too Link to comment
iPrestege Posted April 2, 2014 Share Posted April 2, 2014 function adminPM(thePlayer, theCMD, theTarget, ...) if theTarget ~= nil and hasObjectPermissionTo(thePlayer, "function.kickPlayer", true) then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") setElementData( theTargetElement, "lastpm",thePlayer ) outputChatBox("#ff0000MESAJ DE LA UN ADMINISTRATOR: #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) else outputChatBox("/apm [Jucator] [Mesaje]", thePlayer, 255, 0, 0, true) end end end addCommandHandler("apm", adminPM, false) function adminReply(thePlayer, theCMD, theTarget, ...) local theTargetElement = getElementData(thePlayer, "lastpm") local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("#ff0000MESAJ DE LA "..getPlayerName(thePlayer)..": #FFFFFF"..tostring(theReason), theTargetElement, 255, 0, 0, true) end addCommandHandler("rpm", adminReply, false) Erm sorry but could you tell me what you changed to my code ? I'm trying to learn from my mistakes too I've just change this : setElementData( theTargetElement, "lastpm",getPlayerName (thePlayer) ) To : setElementData( theTargetElement, "lastpm",thePlayer ) Because player name return for a player name not a player .. Link to comment
crismar Posted April 2, 2014 Author Share Posted April 2, 2014 Great, it worked perfectly! Thank you a lot. 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