Jump to content

plz help vs script!


kalitonchik

Recommended Posts

local count = {}

addEventHandler("onResourceStart", getRootElement(), "clothesStart")

function clothesStart ( resourcename )

if resourcename ~= getThisResource () then return end

--we'll count how many clothes there are for each type and store the numbers in the 'count' table.

for type = 0, 17 do

local clothes = 0

--we count the clothes for that type by checking each item until no texture is returned.

while getClothesByTypeIndex ( type, clothes ) ~= false do clothes = clothes + 1 end

--then we store the number

count[type] = clothes

end

setTimer ( "doChangeClothes", 2000, 0 )

end

function doChangeClothes ()

--we store all players in a table

local players = getElementsByType ( "player" )

--for each player in that table,

for i, player in players do

--choose a random type from 0 to 17

type = math.random ( 0, 17 )

if type == 0 or type == 2 then removePlayerClothes ( player, 17 ) end

--types 4-12 don't exist

if type > 3 and type < 13 then type = math.random ( 0, 3 ) end

--we pick a random item from the chosen type

local clothing = math.random ( 0, count[type] )

--we get its texture and model via getClothesByTypeIndex

texture, model = getClothesByTypeIndex ( type, clothing )

--and we add that piece of clothing to the player.

if texture and model then addPlayerClothes ( player, texture, model, type ) end

end

end

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