Sign in to follow this  
anufis_ok

set skin

Recommended Posts

Where is the error in the code?

local validSkins = {29, 30, 100, 101, 102, 104, 106, 107, 108, 109, 110, 114, 115, 116, 118, 144, 165, 173, 174, 175, 280, 283, 285, 286, 287, 294}

local function spawn(player)
	if player and isElement(player) then
		validSkins[math.random(1,#validSkins)],0,0)
	end
end

 

<meta>
	<info author="Yolo" description="This is script, setting skins." version="1.0.0" type="script" />
	<script src="setskin.lua"/>
</meta>

 

Share this post


Link to post

validSkins [math.random(1,#validSkins)], 0, 0 ) : missing the first parenthesis

validSkins[math.random(1,#validSkins)] : table

0, 0 : argument ?

Maybe you forgot to use the function before the table.

Share this post


Link to post

Probably this is what you wanna do:

local validSkins = {29, 30, 100, 101, 102, 104, 106, 107, 108, 109, 110, 114, 115, 116, 118, 144, 165, 173, 174, 175, 280, 283, 285, 286, 287, 294}

function spawnOnJoin()
    local rndSkin = validSkins[math.random(0,#validSkins)] -- get random valid skin from the table
    spawnPlayer(source, 0,0, 5, 0, rndSkin) -- spawn a player when he joins the server
    fadeCamera(source, true)
    setCameraTarget(source, source)
	end
end
addEventHandler("onPlayerJoin", root, spawnOnJoin)

 

Edited by NeverUnbeatable

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.