OnPlayerModInfo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 17: Line 17:
This example prints all information into the chatbox
This example prints all information into the chatbox
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
addEventHandler ( "onPlayerModInfo", root,
    function ( filename, itemList )
        -- Print player name and file name
        outputChatBox( getPlayerName(source) .. " " .. filename )


        -- Print details on each modification
function handleOnPlayerModInfo ( filename, itemList )
        for idx,item in ipairs(itemList) do
    -- Print player name and file name
            local line = tostring(idx) .. ")"
    outputChatBox( getPlayerName(source) .. " " .. filename )
            for k,v in pairs(item) do
 
                line = line .. " " .. tostring(k) .. "=" .. tostring(v)
    -- Print details on each modification
            end
    for idx,item in ipairs(itemList) do
            outputChatBox( line )
        local line = tostring(idx) .. ")"
        for k,v in pairs(item) do
            line = line .. " " .. tostring(k) .. "=" .. tostring(v)
         end
         end
 
        outputChatBox( line )
     end
     end
)
end
addEventHandler ( "onPlayerModInfo", getRootElement(),onPlayerModInfo )
addEventHandler ( "onPlayerModInfo", getRootElement(), handleOnPlayerModInfo )
</syntaxhighlight>
</syntaxhighlight>


{{See also/Server event|Player events}}
{{See also/Server event|Player events}}

Revision as of 14:33, 29 July 2011

This event is triggered when a player has modified certain files

Parameters

string filename, table itemlist
  • filename: An string with the filename of the modified file
  • itemlist: A table with the details of each modification within the file

Source

The source of this event is the player

Example

This example prints all information into the chatbox


function handleOnPlayerModInfo ( filename, itemList )
    -- Print player name and file name
    outputChatBox( getPlayerName(source) .. " " .. filename )

    -- Print details on each modification
    for idx,item in ipairs(itemList) do
        local line = tostring(idx) .. ")"
        for k,v in pairs(item) do
            line = line .. " " .. tostring(k) .. "=" .. tostring(v)
        end
        outputChatBox( line )
    end
end
	
addEventHandler ( "onPlayerModInfo", getRootElement(), handleOnPlayerModInfo )

See Also

Player events


Event functions