demojoel Posted March 24, 2012 Posted March 24, 2012 I try to use a command and it comes back saying "[File Path]....attempt to concatenate local 'lz' (A nil value)" The code is: function matrix(thePlayer) if exports.global:isPlayerHeadAdmin( thePlayer ) then local x, y, z, lx, ly, lz = getCameraMatrix(thePlayer) outputChatBox(""..x..", "..y..", "..z..", "..lx..", "..ly..", "..lz.."", thePlayer) end end addCommandHandler ( "matrix", matrix ) Any help would be awesome, thanks.
drk Posted March 24, 2012 Posted March 24, 2012 getCameraMatrix ( server-side ) return 8 numbers. Is your script server-side?? EPT Team Server Development: 0% Learning C++ | C++ is amazing
drk Posted March 24, 2012 Posted March 24, 2012 (edited) You get any error? And are you HeadAdmin? Test this: addCommandHandler ( 'matrix', function ( _PED, _CMD ) if ( exports.global:isPlayerHeadAdmin ( _PED ) ) then outputChatBox ( 'passed if. Is HeadAdmin' ) local a, b, c, d, e, f, g, h = getCameraMatrix ( _PED ) outputChatBox ( a .. ', ' .. b .. ', ' .. c .. ', ' .. d .. ', ' .. e .. ', ' .. f .. ', ' .. g .. ', ' .. h, _PED, 255, 255, 255, false ) else outputChatBox ( 'youre not headadmin!' ) end end ) And tell me what output. Edited March 24, 2012 by Guest EPT Team Server Development: 0% Learning C++ | C++ is amazing
demojoel Posted March 24, 2012 Author Posted March 24, 2012 I get the Error: "[File Path]....attempt to concatenate local 'lz' (A nil value)" And I'm above Head Admin.
drk Posted March 24, 2012 Posted March 24, 2012 See my last reply again. EPT Team Server Development: 0% Learning C++ | C++ is amazing
demojoel Posted March 24, 2012 Author Posted March 24, 2012 Sorry about that, didn't see the code, anyway... outputChatBox ( 'passed if. Is HeadAdmin' ) -- Worked Error: "[File Path]....attempt to concatenate local 'h' (A nil value)"
Aibo Posted March 24, 2012 Posted March 24, 2012 the thing you should do is check if thePlayer is an element, like: outputChatBox(type(thePlayer)) -- should be 'userdata' maybe your script isnt server-side after all. and Draken: it doesnt matter how many values getCameraMatrix returns, you dont have to get them all. and if that head admin check wouldnt work, then there wouldn't be a concatenation error for lz var. you're wasting his time. ?
Jaysds1 Posted March 24, 2012 Posted March 24, 2012 Try this: addCommandHandler ( 'matrix',function ( _PED, _CMD ) if ( exports.global:isPlayerHeadAdmin ( _PED ) ) then outputChatBox ("Matrix:"..getCameraMatrix(_PED), _PED, 255, 255, 255, false ) else outputChatBox ( 'youre not headadmin!' ) end end) My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Aibo Posted March 24, 2012 Posted March 24, 2012 Try this:addCommandHandler ( 'matrix',function ( _PED, _CMD ) if ( exports.global:isPlayerHeadAdmin ( _PED ) ) then outputChatBox ("Matrix:"..getCameraMatrix(_PED), _PED, 255, 255, 255, false ) else outputChatBox ( 'youre not headadmin!' ) end end) this will only concatenate 1 value from getCameraMatrix return. ?
demojoel Posted March 24, 2012 Author Posted March 24, 2012 the thing you should do is check if thePlayer is an element, like: outputChatBox(type(thePlayer)) -- should be 'userdata'maybe your script isnt server-side after all. Not sure what you mean by that, (Not very good at LUA) but i assumed it's server-side due to it saying "" in the meta file. And Jaysds1: I got the error "[File Path..... attempt to concatenate a boolean value"
Kenix Posted March 24, 2012 Posted March 24, 2012 Server addCommandHandler ( 'matrix', function ( uPlayer ) if exports.global:isPlayerHeadAdmin ( uPlayer ) then outputChatBox ( 'passed if. Is HeadAdmin' ) outputChatBox( string.format( 'Matrix: %s,%s,%s,%s,%s,%s,%s,%s', getCameraMatrix ( uPlayer ) ), uPlayer, 255, 255, 255, true ) else outputChatBox ( 'youre not headadmin!' ) end end ) It's hard? http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
demojoel Posted March 24, 2012 Author Posted March 24, 2012 Server addCommandHandler ( 'matrix', function ( uPlayer ) if exports.global:isPlayerHeadAdmin ( uPlayer ) then outputChatBox ( 'passed if. Is HeadAdmin' ) outputChatBox( string.format( 'Matrix: %s,%s,%s,%s,%s,%s,%s,%s', getCameraMatrix ( uPlayer ) ), uPlayer, 255, 255, 255, true ) else outputChatBox ( 'youre not headadmin!' ) end end ) The "outputChatBox ( 'passed if. Is HeadAdmin'" Worked but got the error: "[File Path.... bad argument #2 to 'format' "
Aibo Posted March 24, 2012 Posted March 24, 2012 Server addCommandHandler ( 'matrix', function ( uPlayer ) if exports.global:isPlayerHeadAdmin ( uPlayer ) then outputChatBox ( 'passed if. Is HeadAdmin' ) outputChatBox( string.format( 'Matrix: %s,%s,%s,%s,%s,%s,%s,%s', getCameraMatrix ( uPlayer ) ), uPlayer, 255, 255, 255, true ) else outputChatBox ( 'youre not headadmin!' ) end end ) It's hard? FFS YOU'RE NOT FIXING HIS PROBLEM ALSO all you people do is showing off how cool you are with your cool syntax that doesnt even help. if it returns false and nil — no string fomatting gonna help it, god dammit. ?
demojoel Posted March 24, 2012 Author Posted March 24, 2012 Anyway, the original command gets... "[File Path]....attempt to concatenate local 'lz' (A nil value)" Original Command Code: function matrix(thePlayer) -- First define the function if exports.global:isPlayerHeadAdmin( thePlayer ) then local x, y, z, lx, ly, lz = getCameraMatrix(thePlayer) outputChatBox(""..x..", "..y..", "..z..", "..lx..", "..ly..", "..lz.."", thePlayer) end end addCommandHandler ( "matrix", matrix )
Jaysds1 Posted March 24, 2012 Posted March 24, 2012 FFS YOU'RE NOT FIXING HIS PROBLEM ALSOall you people do is showing off how cool you are with your cool syntax that doesnt even help. if it returns false and nil — no string fomatting gonna help it, god dammit. Wait, why isn't it working then? My in-game name: Jaysds1 Retired CMG Scripter World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/
Awwu Posted March 24, 2012 Posted March 24, 2012 function matrix(thePlayer) if exports.global:isPlayerHeadAdmin( thePlayer ) then local x, y, z, lx, ly, lz = getCameraMatrix(thePlayer) outputChatBox( tostring(x) .. ", " .. tostring(y) .. ", " .. tostring(z) .. ", " .. tostring(lx) .. ", " .. tostring(ly) .. ", " .. tostring(lz), thePlayer) end end addCommandHandler ( "matrix", matrix ) You should see what that outputs. It might be best if people actually read the wiki page and learn the command syntax of functions before trying to help people with their "knowledge".
Aibo Posted March 24, 2012 Posted March 24, 2012 your problem is that getCameraMatrix returns false, which means thePlayer is not an element. changing variable name to _PED wont fix it, and formatting false return through string.format also. do this: function matrix(thePlayer) -- First define the function outputChatBox("thePlayer: "..tostring(isElement(thePlayer) or type(thePlayer))) if exports.global:isPlayerHeadAdmin( thePlayer ) then local x, y, z, lx, ly, lz = getCameraMatrix(thePlayer) outputChatBox(""..x..", "..y..", "..z..", "..lx..", "..ly..", "..lz.."", thePlayer) end end addCommandHandler ( "matrix", matrix ) see what it'll show in player variable type ?
Kenix Posted March 24, 2012 Posted March 24, 2012 It's function bugged in server side. I test it. it's function return only 1 value only false. And not output debug errors. Test it if interesting. Aibo, Stop yell at me. So use it ( Tested ) Client addCommandHandler ( 'matrix', function ( ) if exports.global:isPlayerHeadAdmin ( uPlayer ) then -- Change this condition. Ex ( Check element data ( if player logged set him data 'Admin','Moderator' or something ) ) Something like: if getElementData( localPlayer, 'Staff' ) == 'Admin' then outputChatBox ( 'passed if. Is HeadAdmin' ) outputChatBox( string.format( 'Matrix: %s,%s,%s,%s,%s,%s,%s,%s', getCameraMatrix ( ) ), 255, 255, 255, true ) else outputChatBox ( 'youre not headadmin!' ) end end ) Read comment in code. http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Aibo Posted March 24, 2012 Posted March 24, 2012 yeah, server-side getCameraMatrix() looks broken, returns false always. better move to client for now. ?
demojoel Posted March 24, 2012 Author Posted March 24, 2012 How would I move it to client? and which code should I use?
Kenix Posted March 24, 2012 Posted March 24, 2012 I said it in last code Server addEventHandler( 'onPlayerLogin', root, function( _, uAccountCurrent ) setElementData( source, 'Group', isObjectInACLGroup( 'user.' .. getAccountName( uAccountCurrent ), aclGetGroup ( 'Admin' ) ) and 'Admin' or isObjectInACLGroup( 'user.' .. getAccountName( uAccountCurrent ), aclGetGroup ( 'Moderator' ) ) and 'Moderator' or -- TODO 'Everyone' ) end ) Client addCommandHandler ( 'matrix', function ( ) if getElementData( localPlayer, 'Group' ) == 'Admin' then -- If palyer admin. outputChatBox ( 'passed if. Is HeadAdmin' ) outputChatBox( string.format( 'Matrix: %s,%s,%s,%s,%s,%s,%s,%s', getCameraMatrix ( ) ), 255, 255, 255, true ) else outputChatBox ( 'youre not headadmin!' ) end end ) Example Updated again http://vk.com/the_kenix Вопросы задавайте на форуме, не пишите мне в личку. Please don't pm me.
Jector Posted March 24, 2012 Posted March 24, 2012 -- camera matrix -- client sided function matrix( ) if exports.global:isPlayerHeadAdmin( thePlayer ) then local a, b, c, d, e, f = getCameraMatrix( ) outputChatBox(a ..", ".. b ..", ".. c ..", ".. d ..", ".. e ..", ".. f, 255, 194, 14) end end addCommandHandler("matrix", matrix) Try that http://www.4shared.com/folder/KprdyGrd/MTARP_Scripts.html
drk Posted March 24, 2012 Posted March 24, 2012 No need to post again Jector .-. Kenix posted already. EPT Team Server Development: 0% Learning C++ | C++ is amazing
Jector Posted March 24, 2012 Posted March 24, 2012 It did not work for Joe lolcoz I am ingame with him http://www.4shared.com/folder/KprdyGrd/MTARP_Scripts.html
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