OnPlayerModInfo: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
Line 5: Line 5:
==Parameters==
==Parameters==
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
int category, table ids, table names
string filename, table itemlist
</syntaxhighlight>  
</syntaxhighlight>  


*'''category''': An integer indicating what category of file has been modified. Currently there is only one category:
*'''filename''': An string with the filename of the modified file
<div style="border:0px solid grey;margin-bottom:3px;padding-left:25px;">
*'''itemlist''': A table with the details of each modification within the file
<div style="border:1px solid grey;margin-bottom:3px;padding-left:5px;">
<div style="float:right;padding-right:5px;font-weight:bold;"></div>
*'''1:''' gta3.img
</div>
</div>
*'''ids''': A table with the id's of the parts of the file that have been modified
*'''names''': A table with the names of the parts of the file that have been modified


==Source==
==Source==
Line 22: Line 15:


==Example==  
==Example==  
This example asks awkward questions unless the player has only changed the radar graphic
This example prints all information into the chatbox
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function onPlayerModInfo ( category, ids, names )
addEventHandler ( "onPlayerModInfo", root,
if category == 'gta3.img' then
    function ( filename, itemList )
for k,v in pairs(names) do
        -- Print player name and file name
if not string.find( v, "radar" ) then
        outputChatBox( tostring(getPlayerName(source)) .. " " .. tostring(filename) )
outputChatBox( getPlayerName(source) .. ", why have you modified " .. v .. "?" )
 
end
        -- Print details on each modification
end
        for idx,item in ipairs(itemList) do
end
            local line = tostring(idx) .. ")"
end
            for k,v in pairs(item) do
                line = line .. " " .. tostring(k) .. "=" .. .. tostring(v)
            end
            outputChatBox( line )
        end
 
    end
)
addEventHandler ( "onPlayerModInfo", getRootElement(),onPlayerModInfo )
addEventHandler ( "onPlayerModInfo", getRootElement(),onPlayerModInfo )
</syntaxhighlight>
</syntaxhighlight>


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

Revision as of 14:21, 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

addEventHandler ( "onPlayerModInfo", root,
    function ( filename, itemList )
        -- Print player name and file name
        outputChatBox( tostring(getPlayerName(source)) .. " " .. tostring(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(),onPlayerModInfo )

See Also

Player events


Event functions