Traitement.. Comment avoir le !setmodel

Alexx.

Membre 🏅
Level 2

Torrents Stats

Messages
80
J'aime
18
Trophées
25
Inscrit
22 Août 2017
upload_2018-2-18_11-22-31.jpeg

Bonjour a tous ,
Aujourd’hui je vais seulement vous apprendre a avoir le !setmodel sur son serveur .

A placé dans :
/garrysmod/addons/ulx/lua/ulx/modules/sh/customcommands.lua (Tu créer ce fichier)

Code :​
Code:
function ulx.setmodel( calling_ply, target_plys, model )
 
    for k,v in pairs( target_plys ) do
 
        if ( not v:Alive() ) then
      
            ULib.tsayError( calling_ply, v:Nick() .. " is dead", true )
      
        else
      
            v:SetModel( model )

        end
      
    end
 
    ulx.fancyLogAdmin( calling_ply, "#A set the model for #T to #s", target_plys, model )
 
end
local setmodel = ulx.command( "Utility", "ulx setmodel", ulx.setmodel, "!setmodel" )
setmodel:addParam{ type=ULib.cmds.PlayersArg }
setmodel:addParam{ type=ULib.cmds.StringArg, hint="model" }
setmodel:defaultAccess( ULib.ACCESS_ADMIN )
setmodel:help( "Set a player's model." )
 

Cypher

Nouveau 🌱
Level 1

Torrents Stats

Messages
16
J'aime
2
Trophées
3
Inscrit
17 Février 2018
Tiens j'ai fait une autre version plus optimisé et qui permet de remettre le model par défaut en laissant vide
Code:
local function setmodelFunc( calling_ply, target_plys, model )
    if !model || string.Trim(model) == "" then
        model = false
    end
    for i=1, #target_plys do
        local v = target_plys[i]
        if !IsValid(v) then continue end
        if !v:Alive() then
            ULib.tsayError( calling_ply, "Can't setmodel on " .. v:Nick() .. ", he's dead", true )
            continue
        end
        if model then
            v:SetModel( model )
        else
            v:SetModel() -- set back to default
        end
    end
    if model then
        ulx.fancyLogAdmin( calling_ply, "#A set the model for #T to #s", target_plys, model )
    else
        ulx.fancyLogAdmin( calling_ply, "#A set the model for #T to default", target_plys )
    end
end
local setmodel = ulx.command( "Utility", "ulx setmodel", setmodelFunc, "!setmodel" )
setmodel:addParam{ type=ULib.cmds.PlayersArg }
setmodel:addParam{ type=ULib.cmds.StringArg, hint="model", ULib.cmds.optional }
setmodel:defaultAccess( ULib.ACCESS_ADMIN )
setmodel:help( "Set a player's model." )
 
Haut Bas