Jump to content

[ayuda] skin selector


Mixters

Recommended Posts

Hola, alguien me podría ayudar con esto? :)

quiero que cuando el jugador elija un skin todos puedan verlo.

mi problema es que cuando lo eligen solo lo ven ellos los demás lo ven con el skin default ( CJ )

aqui les dejo lo que tengo hasta ahora..

client 1:

  
local screen =          {} 
screen.w, screen.h =    guiGetScreenSize() -- разрешение 
  
  
  
  
  
local default = {  
    text =      "", 
  
    font =      "default-bold", 
    scale =     1.0, 
    color =     tocolor(255,255,255,255), 
    bColor =    tocolor(0,0,0,255), 
    outline =   1, 
    alignX =    "left", 
    alignY =    "top", 
  
    clip =      false, 
    wordBreak = false, 
    postGUI =   false, 
  
    x =         0, 
    y =         0 
} 
  
local ms = {  
    locked =    false,  
    show =      false,  
  
    text =      "", 
  
    font =      "default-bold", 
    scale =     1.0, 
    color =     tocolor(255,255,255,255), 
    bColor =    tocolor(0,0,0,255), 
    outline =   1, 
  
    x =         0, 
    y =         0 
} 
  
  
  
  
  
local hideTimer = false  
  
  
  
  
  
function dxMessages_onRender ( ) 
    if ms.show then  
        -- обводка 
        if ms.outline > 0 then 
            dxDrawText( ms.text, ms.x + ms.outline, ms.y + ms.outline, ms.x, ms.y, ms.bColor, ms.scale, ms.font, default.alignX, default.alignY, default.clip, default.wordBreak, default.postGUI ) 
            dxDrawText( ms.text, ms.x - ms.outline, ms.y - ms.outline, ms.x, ms.y, ms.bColor, ms.scale, ms.font, default.alignX, default.alignY, default.clip, default.wordBreak, default.postGUI ) 
            dxDrawText( ms.text, ms.x + ms.outline, ms.y - ms.outline, ms.x, ms.y, ms.bColor, ms.scale, ms.font, default.alignX, default.alignY, default.clip, default.wordBreak, default.postGUI ) 
            dxDrawText( ms.text, ms.x - ms.outline, ms.y + ms.outline, ms.x, ms.y, ms.bColor, ms.scale, ms.font, default.alignX, default.alignY, default.clip, default.wordBreak, default.postGUI ) 
        end 
  
        -- текст 
        dxDrawText( ms.text, ms.x, ms.y, ms.x, ms.y, ms.color, ms.scale, ms.font, default.alignX, default.alignY, default.clip, default.wordBreak, default.postGUI ) 
    end 
end 
  
addEventHandler( "onClientResourceStart", getResourceRootElement(), 
    function ( ) 
        addEventHandler( "onClientRender", getRootElement(), dxMessages_onRender ) 
    end 
) 
  
  
  
  
  
  
  
  
  
  
  
  
  
function showMessage ( text, x, y, font, scale, color, backColor, outline, hideDelay, lock ) 
  
     
    if ms.locked then return end 
  
  
    if isTimer(hideTimer) then killTimer(hideTimer) end 
  
  
    if type(text) ~=      "string" then text =      default["text"]    end 
    if type(x) ~=         "number" then x =         default["x"]       end 
    if type(y) ~=         "number" then y =         default["y"]       end 
    if type(font) ~=      "string" then font =      default["font"]    end 
    if type(scale) ~=     "number" then scale =     default["scale"]   end 
    if type(color) ~=     "number" then color =     default["color"]   end 
    if type(backColor) ~= "number" then backColor = default["bColor"]  end 
    if type(outline) ~=   "number" then outline =   default["outline"] end 
  
    if x > 0 and x < 1 then x = x * screen.w end 
    if y > 0 and y < 1 then y = y * screen.h end 
  
  
    ms["show"] =    false  
    ms["x"] =       x 
    ms["y"] =       y 
    ms["text"] =    text 
    ms["font"] =    font 
    ms["scale"] =   scale 
    ms["color"] =   color 
    ms["bColor"] =  backColor 
    ms["outline"] = outline 
    ms["show"] =    true  
  
    if lock then ms["locked"] = true else ms["locked"] = false end 
  
  
    if type(hideDelay) == "number" and hideDelay > 0 then 
        hideTimer = setTimer( hideMessage, hideDelay, 1 ) 
    end 
  
end 
  
  
function hideMessage ( ) 
  
    ms.show =   false 
    ms.locked = false 
  
end 
  
  
function lockMessage ( ) 
    ms.locked = true 
end 
  
  
function unlockMessage ( ) 
    ms.locked = false 
end 
  

Client 2:

local me = getLocalPlayer()  
  
  
  
  
local skins = { 
0,1,9,10,11,12,13,14,15,16,17,18,19,20, 
21,23,24,25,26,27,28,29,31,32,33,34,36, 
37,38,40,41,43,44,45,46,48,49,50,51,52, 
53,56,57,58,59,60,61,62,63,p64,66,69,71, 
72,75,76,79,80,81,82,83,85,87,88,90,91, 
93,96,98,99,100,101,102,103,104,106, 
107,108,109,110,111,112,113,114,115,116, 
117,118,121,122,123,124,125,126,127,128, 
129,131,132,133,134,136,137,138,139,140, 
141,142,143,144,145,146,147,148,150,151, 
152,153,154,155,156,157,158,159,160,161, 
162,163,164,167,168,169,170,171,172,173, 
174,175,176,177,178,180,181,183,184,186, 
187,190,192,193,194,195,196,197,198,199, 
201,202,203,204,205,206,207,209,210,211, 
112,113,114,115,116,218,219,221,222,223, 
224,225,226,227,228,229,230,232,233,234, 
235,237,238,239,240,241,242,243,244,245, 
246,247,248,249,250,251,252,254,255,256, 
257,258,259,260,261,262,263,264,268,269, 
270,271,272,274,274,276,277,278,279,290, 
291,292,295,296,297,298,299,300,301, 
302,303,304,305,306,307,308,309,310,311 
} 
  
  
  
  
  
  
local maxSkinPos = #skins -- 
local curSkinPos = 1  
--  
local function getNextSkinPos ( curPos ) 
    triggerServerEvent ( "onSkins1", getLocalPlayer() )  
    curPos = curPos + 1 
    if curPos > maxSkinPos then curPos = 1 end 
  
    return curPos 
end 
  
--  
local function getPrevSkinPos ( curPos ) 
    triggerServerEvent ( "onSkins2", getLocalPlayer() )  
    curPos = curPos - 1 
    if curPos < 1 then curPos = maxSkinPos end 
  
    return curPos 
end 
  
  
  
  
  
local ssms = { --  
    whileSelecting = { --  
        text =    "ENGLISH  \n" .. 
                    "LEFT / RIGHT arrow keys - change skin,  \n" .. 
                    "ENTER key - apply skin.  \n" .. 
                        "SPANISH  \n" .. 
                        "IZQUIERDA / DERECHA teclas de flechas - Para cambiar el skin,  \n" .. 
                        "Presiona Enter Para ponerte el skin. ", 
  
        font =      "default-bold", 
        scale =     1.0, 
        color =     tocolor(0xFF,0x8D,0x42,255), 
        bColor =    tocolor(0,0,0,200), 
        outline =   1, 
  
        x =         0.25, 
        y =         0.83 
    }, 
  
    afterSelecting = { --  
        text =    "ENGLISH  \n" .. 
                    "You can change your skin to another one if you want.. \n" .. 
                    "F4 - To change your skin  \n" .. 
                       "SPANISH  \n" .. 
                       "Usted puede cambiar su piel a otra si quieres ..  \n" .. 
                       "F4 - Para cambiar tu skin.  ", 
  
        font =      "default-bold", 
        scale =     1.0, 
        color =     tocolor(255,255,255,200), 
        bColor =    tocolor(0,0,0,200), 
        outline =   1, 
  
        x =         0.25, 
        y =         0.83, 
  
        hideDelay = 4000 -- мсек 
    } 
} 
  
  
  
  
  
function setNextSkinForMe ( ) 
    curSkinPos = getNextSkinPos(curSkinPos) 
    triggerServerEvent ( "onSkins1", getLocalPlayer() )  
    setElementModel( me, skins[curSkinPos] ) 
end 
  
function setPrevSkinForMe ( ) 
    curSkinPos = getPrevSkinPos(curSkinPos) 
    triggerServerEvent ( "onSkins2", getLocalPlayer() )  
    setElementModel( me, skins[curSkinPos] ) 
end 
  
  
  
  
  
local selecting = false 
  
function startSkinSelection ( ) 
  
    if selecting then return end 
    selecting = true 
  
    toggleAllControls( false, true, false ) 
  
    bindKey( "arrow_l", "up", setPrevSkinForMe ) 
    bindKey( "arrow_r", "up", setNextSkinForMe ) 
    bindKey( "enter",   "up", stopSkinSelection ) 
  
    showMessage( ssms["whileSelecting"]["text"], ssms["whileSelecting"]["x"], ssms["whileSelecting"]["y"], ssms["whileSelecting"]["font"], ssms["whileSelecting"]["scale"], ssms["whileSelecting"]["color"], ssms["whileSelecting"]["bColor"], ssms["whileSelecting"]["outline"], 0, true ) 
  
end 
  
function stopSkinSelection ( ) 
  
    -- если не выбирает, ничо не надо делать 
    if not selecting then return end 
    selecting = false 
  
    toggleAllControls( true, true, false ) 
  
    unbindKey( "arrow_l", "up", setPrevSkinForMe ) 
    unbindKey( "arrow_r", "up", setNextSkinForMe ) 
    unbindKey( "enter",   "up", stopSkinSelection ) 
  
    unlockMessage() 
    showMessage( ssms["afterSelecting"]["text"], ssms["afterSelecting"]["x"], ssms["afterSelecting"]["y"], ssms["afterSelecting"]["font"], ssms["afterSelecting"]["scale"], ssms["afterSelecting"]["color"], ssms["afterSelecting"]["bColor"], ssms["afterSelecting"]["outline"], ssms["afterSelecting"]["hideDelay"] ) 
  
    triggerServerEvent( "saveMySkin", me, skins[curSkinPos] ) 
  
end 
  
  
  
  
  
addEventHandler( "onClientResourceStart", getResourceRootElement(), 
    function ( ) 
        bindKey( "F4", "up", startSkinSelection ) 
    end 
) 
  

Server :

  
-- skin 
 = {} 
  
  
  
  
--  
addEvent( "saveMySkin", true ) 
  
addEventHandler( "saveMySkin", getRootElement(), 
    function ( playerSkin ) 
        skin[source] = playerSkin 
  
        setElementModel( source, playerSkin ) 
    end 
) 
  
  
  
  
addEventHandler( "onPlayerJoin", getRootElement(), function() skin[source] = 0 end ) 
addEventHandler( "onPlayerQuit", getRootElement(), function() skin[source] = nil end ) 
  

¿ Me ayudan ? :cry:

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...