Jump to content

Command Won't work.


demojoel

Recommended Posts

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.

Link to comment

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 by Guest
Link to comment

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.

Link to comment

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) 

Link to comment
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.

Link to comment
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"

Link to comment

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?

Link to comment
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' "

Link to comment
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.

Link to comment

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 ) 

Link to comment
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.

Wait, why isn't it working then?

Link to comment
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".

Link to comment

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

Link to comment

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. :mrgreen:

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.

Link to comment

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 :/

Link to comment
  
-- 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

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...