Jump to content

Random Skins


DjMixCuma

Recommended Posts

Posted (edited)

use

function randomSkin () 
setElementModel(source, math.random(7,288)) 
end 
addEventHandler("onPlayerJoin", root, randomSkin) 

Edited by Guest
Posted

... it's easier to change your'e spawn script.

syntax spawnplayer:

spawnPlayer ( player thePlayer, float x, float y, float z, [ int rotation = 0, int skinID = 0, int interior = 0, int dimension = 0, team theTeam = nil ] ) 

as you can see it's supported skinID changing, so change the skinID to math.random (7,288)

Posted

Why from 7 to 288? There are skins from 0 to over 300.

local fit = false; 
  
addEventHandler("onPlayerJoin", root, 
    function() 
        spawnPlayer(source, 0, 0, 3); 
        while(fit == false) do 
            if(setElementModel(source, math.random(0, 312))) then 
                fit = true; 
            end 
        end 
    end 
) 

Not tested.

Posted

Is easier to use: getValidPedModels to get all valid skin models. Also, the spawnPlayer function has a skin argument.

addEventHandler ( "onPlayerJoin", root, 
    function ( ) 
        spawnPlayer ( source, 0, 0, 3, 0, getValidPedModels ( ) [ math.random ( #getValidPedModels ( ) ) ] ) 
    end 
) 

Posted

Oh, I completely forgot that we had that valid skins functions, nice.

Oh yes, spawnPlayer does have a skin argument, but I tried to make the skin check a little more dedicated.

Posted
addEventHandler("onPlayerSpawn", getRootElement(), function() 
    setElementModel(source, math.random(312)) 
end) 

WORKING !!

Not really. Read posts above.

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