• Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Ronit.GAMES RonEngine Support / Wsparcie dla RonEngine LUA/XML Scripting / Skryptowanie LUA/XML Outfity przy starcie (Zmiana wymagana)

 
  • 0 Vote(s) - 0 Average
Outfity przy starcie (Zmiana wymagana)
Meritus
Offline

Uzytkownik

Posts: 28
Threads: 19
Joined: Jun 2010
Reputation: 4
#1
12-04-2011, 01:21 PM (This post was last modified: 17-04-2011, 12:21 PM by Meritus.)
Hello,

W silniku RonIT kompilowanym po 12 kwietnia niezbędna jest modyfikacja systemu rozdawania startowych wyglądów. Silnik od tej pory nie będzie w ogóle ingerował i miał na stałe wpisane looktype postaci z obsługi czy zwykłych graczy zaczynających swoją przygodę.

W pliku /actions/triggers/onlogin.lua dodajemy:

PHP Code:
ON_LOGIN_ADD_OUTFITS = {
    -- 
Jezeli player ma juz dany outfit, to go nie doda
    
-- Pamiętaj ze jak gracz zaloguje juz do gry i doda mu outfit a usuniesz
    
-- dany wyglad to nie zostanie on usunienty graczu
    
-- looktype w tabelach ponizej jest to klucz w globalnej tablicy MALE_OUTFITS badz FEMALE_OUTFITS znajdujacej sie w global.lua
    
[GM] = {
        
outfits = {
            {
looktype = "TR", addons = 0},
            --(...)--
        },
        default = {
lock = 0, looktype = "TR", addon = 0, lookHead = 5, lookBody = 80, lookLegs = 40, lookFeet = 160}, 
    },
    [
CM] = {
        
outfits = {
            {
looktype = "TR", addons = 0},
            --(...)--
        },
        default = {
lock = 1, looktype = "TR", addon = 0, lookHead = 130, lookBody = 80, lookLegs = 30, lookFeet = 48}, 
    },
    [
TR] = {
        
outfits = {
            {
looktype = "TR", addons = 0},
            --(...)--
        },
        default = {
lock = 1, looktype = "TR", addon = 0, lookHead = 148, lookBody = 112, lookLegs = 154, lookFeet = 10}, 
    },
    [
BH] = {
        
outfits = {
            {
looktype = "TR", addons = 0},
            --(...)--
        },
        default = {
lock = 1, looktype = "TR", addon = 0, lookHead = 48, lookBody = 68, lookLegs = 79, lookFeet = 130}, 
    },
    [
PLAYER] = {
        
outfits = {
            {
looktype = "CITIZEN", addons = 0, pacc = 0, level = 0 }, 
            {
looktype = "HUNTER", addons = 0, pacc = 0, level = 0 }, 
            {
looktype = "MAGE", addons = 0, pacc = 0, level = 0 }, 
            {
looktype = "KNIGHT", addons = 0, pacc = 0, level = 0 }, 
            {
looktype = "NOBLEMAN", addons = 0, pacc = 1, level = 0 }, 
            {
looktype = "WIZARD", addons = 0, pacc = 1, level = 200 }, 
            {
looktype = "ORIENTAL", addons = 0, pacc = 1, level = 100 }, 
            {
looktype = "SHAMAN", addons = 0, pacc = 1, level = 150 }, 
            {
looktype = "DRUID", addons = 0, pacc = 1, level = 50 }, 
            {
looktype = "ORIENTAL", addons = 0, pacc = 1, level = 100 }, 
            --(...)--
        },
        default = {
lock = 0, looktype = "CITIZEN", addon = 0, lookHead = 100, lookBody = 100, lookLegs = 100, lookFeet = 100}, 
    }
    -- default: 
okresla Outfit ktory ma byc ustawiony po zalogowaniu, 
    -- 
JEŻELI lock jest ustawiony (1) to zawsze ustawi wyglad podany w default oraz go zablokuje, nie bedzie mozliwosci jego zmiany, jezeli nie ustawiony badz 0 to tylko przy 1 probie zalogowania do gry ustawi taki wyglad
    
-- i jezeli looktype podany w default  nie znajduje sie w tablicy outfits (znajdujacej sie nad default) to outfit zostanie dodany tylko do czasu jego zmiany ( nie bedzie mozliwosci ponownego ustawienia tego wygladu)
    -- 
lookHead, lookBody, lookLegs, lookFeet koloruje wyglad
    
-- addon, flaga okreslajaca jaki dodatek ma byc bazowo ustawiony (0 - sam outfit, 1 - pierwszy dodatek, 2 drugi dodatek, 3 - oba dodatki )
}

local PlayerInfoAccess = getPlayerAccess(cid)
local Playerlevel = getPlayerLevel(cid)
local PlayerPACC = getPlayerPACC(cid)
--
Ustawianie Outfitu
for key, val in pairs(ON_LOGIN_ADD_OUTFITS) do 
    if (
PlayerInfoAccess == key) then 
        
if trigger.optionid == 0 then
            LUAsetCurrentOutfit
(cid, val.default.looktype, val.default.lookHead, val.default.lookBody, val.default.lookLegs, val.default.lookFeet, val.default.addon)
        
end
        
if LUAgetOutfit(cid, "TR", 0) == TRUE and PlayerInfoAccess == 0 then
            LUAremOutfit
(cid, "TR", 255,1) -- Usuwam wyglad TRa, nie wazne kim jestem
            changeOutfitUnlock
(cid)
            
LUAsetCurrentOutfit(cid, "CITIZEN", 0, 0, 0, 0,0)
        
end
        
if val.default.lock == 1 then
            changeOutfitUnlock
(cid)
            
LUAsetCurrentOutfit(cid, val.default.looktype, val.default.lookHead, val.default.lookBody, val.default.lookLegs, val.default.lookFeet, val.default.addon)
            
changeOutfitLock(cid)
        else
            
changeOutfitUnlock(cid)
        
end
        
        
for _, outfit in pairs(val.outfits) do
            
flag = true
            
if outfit.pacc == 1 then
                
if PlayerPACC == LUA_FALSE then
                    flag 
= false
                end
            end
            
if outfit.level ~= nil then
                
if Playerlevel < outfit.level then
                    flag 
= false
                end
            end
            
if (flag) then 
                LUAaddOutfit
(cid, outfit.looktype, outfit.addons)
            
end
        end
    end
end
if PlayerPACC == LUA_FALSE then
    
--Ukrywanie outfitow jezeli skonczylo sie premium
    TO_HIDE_OUTFITS 
= {
        
"NOBLEMAN", "SUMMONER", "WARRIOR", "JESTER",
        
"BOB" ,"NIGHTMARE", "SNOWMAN", "BARBARIAN", 
        
"DRUID", "WIZARD", "ORIENTAL", "PIRATE", "ASSASSIN", 
        
"BEGGAR", "SHAMAN", "DEMONHUNTER", "YALAHAR", 
        
"WARMASTER", "WEDDING", "WAYFARER", "SLAYER"    
    
}
    
LUAhideOutfits(cid, TO_HIDE_OUTFITS)
end 

Sprawdzamy czy w pliku global.lua są zdefiniowane makra(zmienne):

PHP Code:
FEMALE_OUTFITS = {
    [
"CITIZEN"] = 139,
    [
"HUNTER"] = 140,
    [
"MAGE"] = 144,
    [
"KNIGHT"] = 142,
    [
"NOBLEMAN"] = 143,
    [
"SUMMONER"] = 141,
    [
"WARRIOR"] = 145,
    [
"JESTER"] = 146,
    [
"BOB"] = 147,
    [
"NIGHTMARE"] = 148,
    [
"SNOWMAN"] = 149,
    [
"BARBARIAN"] = 278,
    [
"DRUID"] = 277,
    [
"WIZARD"] = 276,
    [
"ORIENTAL"] = 275,
    [
"PIRATE"] = 274,
    [
"ASSASSIN"] = 273,
    [
"BEGGAR"] = 272,
    [
"SHAMAN"] = 271,
    [
"DEMONHUNTER"] = 270,
    [
"YALAHAR"] = 279,
    [
"WARMASTER"] = 325,
    [
"WEDDING"] = 314,
    [
"WAYFARER"] = 364,
    [
"SLAYER"] = 292,    
    [
"KING"] = 298,
    [
"TR"] = 371,
}

MALE_OUTFITS = {
    [
"CITIZEN"] = 128,
    [
"HUNTER"] = 129,
    [
"MAGE"] = 130,
    [
"KNIGHT"] = 131,
    [
"NOBLEMAN"] = 132,
    [
"SUMMONER"] = 133,
    [
"WARRIOR"] = 134,
    [
"DRUID"] = 268,    
    [
"WIZARD"] = 267,    
    [
"ORIENTAL"] = 266,
    [
"JESTER"] = 135,
    [
"BOB"] = 136,
    [
"NIGHTMARE"] = 137,
    [
"SNOWMAN"] = 138,
    [
"BARBARIAN"] = 269,
    [
"PIRATE"] = 265,
    [
"ASSASSIN"] = 264,
    [
"BEGGAR"] = 263,
    [
"SHAMAN"] = 262,
    [
"DEMONHUNTER"] = 261,
    [
"YALAHAR"] = 280,
    [
"WARMASTER"] = 324,
    [
"WEDDING"] = 313,
    [
"WAYFARER"] = 365,
    [
"SLAYER"] = 292,
    [
"KING"] = 298,
    [
"TR"] = 371,
}


GM = 1
CM 
= 2
TR 
= 3
BH 
= 4
PLAYER 
= 0 

oraz funkcje:

PHP Code:
function LUAgetOutfit(cid, outfit_name, nr)

    if 
getSex(cid) == 0 then
        outfit_table 
= FEMALE_OUTFITS
    
else
        
outfit_table = MALE_OUTFITS
    end

    
for _, i in pairs(outfit_table) do 
        if 
outfit_name == _ then
            ret 
= getOutfit(cid,i,nr)
            --
log(cid, "ret == "..ret.."")
            return 
ret
        end
    end
    log
(cid, "<SET_OUTFIT> ERROR outfit name = "..outfit_name.." do not exist!")
    return -
1

end 

function LUAhideOutfits(cid, to_hide)
    
local outfit_table = {}
    
local PlayerPACC = getPlayerPACC(cid)
    if 
getSex(cid) == 0 then
        outfit_table 
= FEMALE_OUTFITS
    
else
        
outfit_table = MALE_OUTFITS
    end
    
for _, i in pairs(to_hide) do
        
hideOutfit(cid, outfit_table[i])
    
end
end

function LUAgetOutfitLookTypeByName(cid, outfit_name)
    
local outfit_table = {}
    if 
getSex(cid) == 0 then
        outfit_table 
= FEMALE_OUTFITS
    
else
        
outfit_table = MALE_OUTFITS
    end
    
    
return outfit_table[outfit_name:upper()]
end 
 
 
function LUAremOutfit(cid, outfit_name, nr, logs)
        
    if 
getSex(cid) == 0 then
        outfit_table 
= FEMALE_OUTFITS
    
else
        
outfit_table = MALE_OUTFITS
    end

    
for _, i in pairs(outfit_table) do 
        if 
outfit_name == _ then
            remOutfit
(cid,i,nr)
            if 
logs == 1 then
                log
(cid, "<REM_OUTFIT> outfit name = "..outfit_name.." looktype = "..i.." nr = "..nr.." successfull")
            
end
            
return 1
        end
    end
    log
(cid, "<SET_OUTFIT> ERROR outfit name = "..outfit_name.." do not exist!")
    return -
1

end  
 
function LUAaddOutfit(cid, outfit_name, nr)

    if 
LUAgetOutfit(cid, outfit_name, nr) == 1 then
        
--log(cid, "<SET_OUTFIT> outfit name = "..outfit_name.." nr = "..nr.." error: player already have this outfit")
        return -
1
    end
            
    
if getSex(cid) == 0 then
        outfit_table 
= FEMALE_OUTFITS
    
else
        
outfit_table = MALE_OUTFITS
    end

    
for _, i in pairs(outfit_table) do 
        if 
outfit_name == _ then
            ret 
= addOutfit(cid,i,nr)
            if 
ret == 1 then
                log
(cid, "<SET_OUTFIT> outfit name = "..outfit_name.." looktype = "..i.." nr = "..nr.." successfull: addOutfit returned "..ret.."")
            else
                
log(cid, "<SET_OUTFIT> outfit name = "..outfit_name.." looktype = "..i.." nr = "..nr.." fail: addOutfit returned "..ret.."")
            
end            
            
return 1
        end
    end
    log
(cid, "<SET_OUTFIT> ERROR outfit name = "..outfit_name.." do not exist!")
    return -
1

end 

function LUAsetCurrentOutfit(cid, outfit_name, lookHead, lookBody, lookLegs, lookFeet, nr)
    if 
getSex(cid) == 0 then -- FEMALE
        outfit_table 
= FEMALE_OUTFITS
    
else
        
outfit_table = MALE_OUTFITS
    end
    
for _, i in pairs(outfit_table) do 
        if 
outfit_name == _ then
            setCurrentOutfit
(cid, i, lookHead, lookBody, lookLegs, lookFeet, nr)
            
log(cid, "<SET_CURRENT_OUTFIT> outfit_name = "..outfit_name.." looktype = "..i.." lookHead = "..lookHead.." lookBody = "..lookBody.." lookLegs = "..lookLegs.." lookFeet = "..lookFeet.." addon = "..nr.."")
            return 
1
        end
    end
    log
(cid, "<SET_CURRENT_OUTFIT> ERROR outfit name = "..outfit_name.." do not exist!")
    return -
1    
end 

jeżeli nie ma dopisujemy je.

Oczywiście tablice konfiguracyjną zgodne z opisami możemy modyfikować pod nasze wymagania Smile

Pozdrawiam,
Meritus
« Next Oldest | Next Newest »

Users browsing this thread: 1 Guest(s)



Messages In This Thread
Outfity przy starcie (Zmiana wymagana) - by Meritus - 12-04-2011, 01:21 PM

  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Designed by D&D - Powered by MyBB

Linear Mode
Threaded Mode