Сообщений: 1511
|
Опубликовано: 06.01.2016, 04:00:21
Скрипт берет имя 4-го червя, и если оно в виде:
То черви получат шляпы, каждый со своим индексом, а последний червь получит имя WormName.
Вот сам скрипт.
Код
function splithat(name) local result = {"name","0","0","0","0"} local delimiter = "," local from = 1 local ind = 1 local delim_from, delim_to = string.find( name, delimiter, from ) if delim_from ~= nil then while delim_from do result[ind] = string.sub( name, from , delim_from-1 ) from = delim_to + 1 ind = ind + 1 delim_from, delim_to = string.find( name, delimiter, from ) end result[ind] = string.sub( name, from ) end return result end
function SetHat(PlayerIndex,hatindex,index) WFHats = { "Hat.Medieval1","Hat.Medieval2","Hat.Medieval3","Hat.Medieval4", "Hat.Egyptian1","Hat.Egyptian2","Hat.Egyptian3","Hat.Egyptian4", "Hat.Roman1","Hat.Roman2","Hat.Roman3","Hat.Roman4", "Hat.Oriental1","Hat.Oriental2","Hat.Oriental3","Hat.Oriental4", "Hat.Witch","Hat.Wizard","Hat.Guinevere","Hat.Helen" } local Worm = GetWormData(PlayerIndex,index) Worm.HatOverride = WFHats[tonumber(hatindex)+1] end
function SetDifficulty()
local Worm local hats local indexplayer = 0 local player = GetPlayerData(indexplayer) while player.PlayerIndex ~= -1 do Worm = GetWormData(player.PlayerIndex,3) if string.find(Worm.Name,",") ~= nil then hats = splithat(Worm.Name) Worm.Name = hats[1] SetHat(player.PlayerIndex,hats[2],0) SetHat(player.PlayerIndex,hats[3],1) SetHat(player.PlayerIndex,hats[4],2) SetHat(player.PlayerIndex,hats[5],3) end indexplayer = indexplayer+1 player = GetPlayerData(indexplayer) end end
Проверено, работает даже в онлайне!!!
|
|
|
|