Jump to content

Seleccionar Un Skin Al Entrar.¿Como Hacerlo?


Recommended Posts

@mauro: Yo sabia que ivas a tener ese problema, podes usar una funcion que yo cree para que puedas obtener una dimension que no este usada.

function getFreeDimension ( ) 
    local dim = 0 
    local tempTable = { } 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        tempTable [ getElementDimension ( player ) ] = true 
    end 
  
    repeat 
        dim = dim + 1 
    until not tempTable [ dim ] 
     
    return tonumber ( dim ) 
end 

La cosa es que yo la uso server side, no se si va a funcionar bien client side.

Link to comment

Mira Puse Esto:

function camf() 
if (client) then 
setElementPosition( client,98.5163, 2246.3232, 125.1528 ) 
local rot = setPedRotation(client, 1)  
setCameraMatrix( client, 95.1860, 2239.7947, 126.7486, 98.5163, 2246.3232, 125.1528) 
end 
end 
addEvent("FrontCamera", true) 
addEventHandler("FrontCamera", getRootElement(), camf) 
  
function getFreeDimension ( ) 
    local dim = 0 
    local tempTable = { } 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        tempTable [ getElementDimension ( player ) ] = true 
    end 
  
    repeat 
        dim = dim + 1 
    until not tempTable [ dim ] 
    
    return tonumber ( dim ) 
end 
  
function selected() 
if (client) then 
fadeCamera(client, true) 
setCameraTarget(client, client) 
setElementDimension ( client, 0 ) 
local skin = getElementModel ( client ) 
spawnPlayer(client, -2026.5035, 156.7506, 29.0391, 269.1424, skin) 
outputChatBox("Skin successfully changed!", client) 
end 
end 
addEvent("SkinSelected", true) 
addEventHandler("SkinSelected", getRootElement(), selected) 
  
function skinright() 
local skin = getPedSkin(client) 
if (client) then 
if (skin == 0) then 
setPedSkin(client, 7) 
elseif (skin == 7) then 
setPedSkin(client, 9) 
elseif (skin == 41) then 
setPedSkin(client, 43) 
elseif (skin == 64) then 
setPedSkin(client, 66) 
elseif (skin == 85) then 
setPedSkin(client, 87) 
elseif(skin == 118) then 
setPedSkin(client, 120) 
elseif(skin == 148) then 
setPedSkin(client, 150) 
elseif(skin == 207) then 
setPedSkin(client, 209) 
elseif(skin == 238) then 
setPedSkin(client, 240) 
elseif(skin == 264) then 
setPedSkin(client, 274) 
elseif(skin == 288) then 
setPedSkin(client, 0) 
else 
setPedSkin(client, skin+1) 
end 
end 
end 
addEvent("SkinRight", true) 
addEventHandler("SkinRight", getRootElement(), skinright ) 
  
function skinleft() 
local skin = getPedSkin(client) 
if (client) then 
if (skin == 7) then 
setPedSkin(client, 0) 
elseif (skin == 9) then 
setPedSkin(client, 7) 
elseif (skin == 43) then 
setPedSkin(client, 41) 
elseif (skin == 66) then 
setPedSkin(client, 64) 
elseif (skin == 87) then 
setPedSkin(client, 85) 
elseif(skin == 120) then 
setPedSkin(client, 118) 
elseif(skin == 150) then 
setPedSkin(client, 148) 
elseif(skin == 209) then 
setPedSkin(client, 207) 
elseif(skin == 240) then 
setPedSkin(client, 238) 
elseif(skin == 274) then 
setPedSkin(client, 264) 
elseif(skin == 0) then 
setPedSkin(client, 288) 
else 
setPedSkin(client, skin-1) 
end 
end 
end 
addEvent("SkinLeft", true) 
addEventHandler("SkinLeft", getRootElement(), skinleft)  

Pero No Funciona.. ¿Hay Solucion? ¿Cual Es El Problema?

Link to comment

Fijate.. Te Lo Marque.

function camf() 
if (client) then 
setElementPosition( client,98.5163, 2246.3232, 125.1528 ) 
local rot = setPedRotation(client, 1)  
setCameraMatrix( client, 95.1860, 2239.7947, 126.7486, 98.5163, 2246.3232, 125.1528) 
end 
end 
addEvent("FrontCamera", true) 
addEventHandler("FrontCamera", getRootElement(), camf) 
  
------------------------------------------------------------------ 
function getFreeDimension ( ) 
    local dim = 0 
    local tempTable = { } 
    for index, player in ipairs ( getElementsByType ( "player" ) ) do 
        tempTable [ getElementDimension ( player ) ] = true   ----------AQUI Esta.  
    end 
  
    repeat 
        dim = dim + 1 
    until not tempTable [ dim ] 
    
    return tonumber ( dim ) 
end 
------------------------------------------------------------------------ 
function selected() 
if (client) then 
fadeCamera(client, true) 
setCameraTarget(client, client) 
setElementDimension ( client, 0 ) 
local skin = getElementModel ( client ) 
spawnPlayer(client, -2026.5035, 156.7506, 29.0391, 269.1424, skin) 
outputChatBox("Skin successfully changed!", client) 
end 
end 
addEvent("SkinSelected", true) 
addEventHandler("SkinSelected", getRootElement(), selected) 

¿ Como Puedo Solucionarlo?

Link to comment

Me parece que no entendiste como funciona, lo que marcaste no tiene sentido, la funcion devuelve un numero que no este siendo usado por otro jugador.

Seria asi:

local dimension = getFreeDimension  ( ) 
setElementDimension ( elJugador, dimension ) 

Link to comment
  • Recently Browsing   0 members

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