OnPlayerModInfo: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 18: | Line 18: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function handleOnPlayerModInfo ( filename, | function handleOnPlayerModInfo ( filename, modList ) | ||
-- Print player name and file name | -- Print player name and file name | ||
outputChatBox( getPlayerName(source) .. " " .. filename ) | outputChatBox( getPlayerName(source) .. " " .. filename ) | ||
-- Print details on each modification | -- Print details on each modification | ||
for idx, | for idx,mod in ipairs(modList) do | ||
local line = tostring(idx) .. ")" | local line = tostring(idx) .. ")" | ||
for k,v in pairs( | for k,v in pairs(mod) do | ||
line = line .. " " .. tostring(k) .. "=" .. tostring(v) | line = line .. " " .. tostring(k) .. "=" .. tostring(v) | ||
end | end | ||
outputChatBox( line ) | outputChatBox( line ) | ||
end | |||
end | |||
addEventHandler ( "onPlayerModInfo", getRootElement(), handleOnPlayerModInfo ) | |||
</syntaxhighlight> | |||
This example checks modified files against a list and prints a warning in the chatbox | |||
<syntaxhighlight lang="lua"> | |||
checkModels = { "m4.dff", "ak47.dff" } | |||
function handleOnPlayerModInfo ( filename, modList ) | |||
for _,mod in ipairs(modList) do -- Check each modified item | |||
for _,checkName in ipairs(checkModels) do | |||
if mod.name == checkName then -- See if modified item is in our check list | |||
outputChatBox ( "Not allowed to used modified weapons. Please restore " .. filename ) | |||
end | |||
end | |||
end | end | ||
end | end |
Revision as of 01:59, 19 November 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, modList ) -- Print player name and file name outputChatBox( getPlayerName(source) .. " " .. filename ) -- Print details on each modification for idx,mod in ipairs(modList) do local line = tostring(idx) .. ")" for k,v in pairs(mod) do line = line .. " " .. tostring(k) .. "=" .. tostring(v) end outputChatBox( line ) end end addEventHandler ( "onPlayerModInfo", getRootElement(), handleOnPlayerModInfo )
This example checks modified files against a list and prints a warning in the chatbox
checkModels = { "m4.dff", "ak47.dff" } function handleOnPlayerModInfo ( filename, modList ) for _,mod in ipairs(modList) do -- Check each modified item for _,checkName in ipairs(checkModels) do if mod.name == checkName then -- See if modified item is in our check list outputChatBox ( "Not allowed to used modified weapons. Please restore " .. filename ) end end end end addEventHandler ( "onPlayerModInfo", getRootElement(), handleOnPlayerModInfo )
See Also
Player events
- onPlayerACInfo
- onPlayerBan
- onPlayerChangeNick
- onPlayerChat
- onPlayerClick
- onPlayerCommand
- onPlayerConnect
- onPlayerContact
- onPlayerDamage
- onPlayerJoin
- onPlayerLogin
- onPlayerLogout
- onPlayerMarkerHit
- onPlayerMarkerLeave
- onPlayerModInfo
- onPlayerMute
- onPlayerNetworkStatus
- onPlayerPickupHit
- onPlayerPickupLeave
- onPlayerPickupUse
- onPlayerPrivateMessage
- onPlayerQuit
- onPlayerScreenShot
- onPlayerSpawn
- onPlayerStealthKill
- onPlayerTarget
- onPlayerUnmute
- onPlayerVehicleEnter
- onPlayerVehicleExit
- onPlayerVoiceStart
- onPlayerVoiceStop
- onPlayerWasted
- onPlayerWeaponFire
- onPlayerWeaponSwitch
Event functions
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled