Jump to content

Modinfo


Msypon

Recommended Posts

I want to /modinfo But it doesnt work what is wrong?

function handleOnPlayerModInfo ( source, cmd, target, filename, modList ) 
    if ( target ) then 
        local targetplayer = getPlayerFromName ( target ) 
       outputChatBox( getPlayerName(targetplayer) .. " " .. filename ) 
        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 ) 
        addEventHandler ( "onPlayerModInfo", getRootElement(), handleOnPlayerModInfo ) 
        end 
    end 
end 
addCommandHandler("modinfo",handleOnPlayerModInfo) 
  

Link to comment
So its impossible to make a /modinfo ?

basically, because the event is the only thing that could send the mod info

but I know a way :D

EDITED: Server

addCommandHandler("modinfo",function(source,_,pName) 
    if isObjectInACLGroup("user."..getAccountName(getAccount(source)),aclGetGroup("admin"))then 
        local player = getPlayerFromName(pName) 
        if not player then 
            outputChatBox("Sorry, but there's no one named "..pName,source,100,0,0) 
            return 
        end 
        triggerClientEvent(player,"getModInfo",player,source) 
    end 
end) 
addEvent("receiveModInfo",true) 
addEventHandler("receiveModInfo",root,function(file) 
    if file then 
        if outputConsole(fileRead("mods.txt",fileGetSize("mods.txt")),client) then 
            outputChatBox("Mods Loaded, Check Console for mods info.",client,0,100,0) 
        end 
    else 
        outputChatBox("There's no mods available!",client,100,0,0) 
    end 
end) 
  
addEventHandler("onPlayerModInfo",root,function(filename, modList) 
    triggerClientEvent(source,"saveModInfo",source,filename,modList) 
end) 

Client

addEvent("getModInfo",true) 
addEventHandler("getModInfo",root,function(rPlayer) 
    triggerServerEvent("receiveModInfo",rPlayer,fileOpen("mods.txt")) 
end) 
addEvent("saveModInfo",true) 
addEventHandler("saveModInfo",root,function(filename,modList) 
    local file=fileCreate("mods.txt") 
    if file then 
        local mod = "File: "..filename.." Contents:\n" 
        for _,v in ipairs(modList)do 
            mod = mod.." "..v 
        end 
        fileWrite("mods.txt",mod) 
        fileClose(file) 
    end 
end) 

Link to comment

Server-side only:

local DataPlayer = { } 
  
function onPlayerCommand ( player, command, target ) 
    local tp = getPlayerFromName ( target ) 
    if ( target ) then 
        if ( DataPlayer[tp] ) then 
            outputChatBox( getPlayerName(tp) .. " " .. DataPlayer[tp]["filename"] ) 
            for idx, mod in ipairs ( DataPlayer[tp]["list"] ) do 
                local line = tostring ( idx ) .. ")" 
                for k, v in pairs ( mod ) do 
                    line = line .. " " .. tostring ( k ) .. "=" .. tostring ( v ) 
                end 
                outputChatBox( line ) 
            end 
        end 
    end 
end 
addCommandHandler ( "modinfo", onPlayerCommand ) 
  
function onPlayerModInfo ( filename, modlist ) 
    if ( not DataPlayer[source] ) then 
        DataPlayer[source] = { ["filename"] = filename, ["list"] = modlist } 
    end 
end 
addEventHandler ( "onPlayerModInfo", getRootElement ( ), onPlayerModInfo ) 

Not tested yet.

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