Jump to content

Skin Spawning?


Lloyd Logan

Recommended Posts

example:

local spawn = { [0]={0,0,3}, [218]={3,0,3} }--creates 2 arrays and a table in an array 
addEventHandler("onPlayerSpawn",root,function() 
     local skin = getElementModel(source) 
     if skin == 0 or skin == 218 then 
          local x,y,z = unpack(spawn[skin]) 
          setElementPosition(source,x,y,z) 
      end 
end) 

Link to comment
example:
local spawn = { [0]={0,0,3}, [218]={3,0,3} }--creates 2 arrays and a table in an array 
addEventHandler("onPlayerSpawn",root,function() 
     local skin = getElementModel(source) 
     if skin == 0 or skin == 218 then 
          local x,y,z = unpack(spawn[skin]) 
          setElementPosition(source,x,y,z) 
      end 
end) 

OKay, so i have a skin selector and i have made it so when you select a skin it spawns you to a point. Its not a gui tho, anyways it is Team DM and i was wonder in you were in the "RED" team you could have certain skins to choose from then spawn to the RED base?

Link to comment
Create an array, set index as skin ID and create another array for its value with the positions. Then get positions for a specific skin ID calling that array's index.

Array? :/ I'm sounding quite the noob here :|

An array is a table.

Just add this to your gamemode:

local g_pSkins =  
{ 
    [218] = { 0, 0, 0 }, 
    [219] = { 0, 0, 0 }, 
    [220] = { 0, 0, 0 } 
}; 
  
addEventHandler( "onPlayerSpawn", root, 
    function( _, _, _, _, _, nSkin ) 
        if ( g_pSkins[nSkin] ) then 
                local   pTeam, nRotation,  
                    nInterior, nDimension = getPlayerTeam( source ), getElementRotation( source ), 
                                getElementInterior( source ), 
                        getElementDimension( source ); 
                          
        spawnPlayer( source, 
                 g_pSkins[nSkin][1], g_pSkins[nSkin][2], g_pSkins[nSkin][3],  
                             nRotation, nSkin, nInterior, nDimension, pTeam ); 
        end 
    end 
); 

I didn't test the code, there might be an error.

P.S. Don't look at the identation, it's impossible to do anything with Notepad :P

Link to comment
Create an array, set index as skin ID and create another array for its value with the positions. Then get positions for a specific skin ID calling that array's index.

Array? :/ I'm sounding quite the noob here :|

An array is a table.

Just add this to your gamemode:

local g_pSkins =  
{ 
    [218] = { 0, 0, 0 }, 
    [219] = { 0, 0, 0 }, 
    [220] = { 0, 0, 0 } 
}; 
  
addEventHandler( "onPlayerSpawn", root, 
    function( _, _, _, _, _, nSkin ) 
        if ( g_pSkins[nSkin] ) then 
                local   pTeam, nRotation,  
                    nInterior, nDimension = getPlayerTeam( source ), getElementRotation( source ), 
                                getElementInterior( source ), 
                        getElementDimension( source ); 
                          
        spawnPlayer( source, 
                 g_pSkins[nSkin][1], g_pSkins[nSkin][2], g_pSkins[nSkin][3],  
                             nRotation, nSkin, nInterior, nDimension, pTeam ); 
        end 
    end 
); 

I didn't test the code, there might be an error.

P.S. Don't look at the identation, it's impossible to do anything with Notepad :P

Thanks I'll try!! ;)

Link to comment
Did it work before you add my code? Do you get any errors?

Not before i added your code, but here it is, with this i honestly have no idea what i'm doing....

local g_pSkins =  
{ 
    [7] = { 0, 0, 5 }, 
    [219] = { 0, 0, 0 }, 
    [220] = { 0, 0, 0 } 
}; 
  
addEventHandler( "onPlayerSpawn", root, 
    function( _, _, _, _, _, nSkin ) 
        if ( g_pSkins[nSkin] ) then 
                local   pTeam, nRotation,  
                    nInterior, nDimension = getPlayerTeam( source ), getElementRotation( source ), 
                                getElementInterior( source ), 
                        getElementDimension( source );                    
        spawnPlayer( source, 
                 g_pSkins[nSkin][1], g_pSkins[nSkin][2], g_pSkins[nSkin][3],  
                             nRotation, nSkin, nInterior, nDimension, pTeam ); 
        end 
    end 
); 

I am not sure about the rotation, but the posistion is a i sead before and the dimension is 0

Link to comment
[7] = { 0, 0, 5 }, -- change 0, 0, 5 to the X Y Z that you want to be set that Skin ID 7 
    [219] = { 0, 0, 0 }, -- change 0, 0, 0 to the X Y Z that you want to be set that Skin ID 219 
    [220] = { 0, 0, 0 } -- change 0, 0, 0 to the X Y Z that you want to be set that Skin ID 220 

Link to comment
[7] = { 0, 0, 5 }, -- change 0, 0, 5 to the X Y Z that you want to be set that Skin ID 7 
    [219] = { 0, 0, 0 }, -- change 0, 0, 0 to the X Y Z that you want to be set that Skin ID 219 
    [220] = { 0, 0, 0 } -- change 0, 0, 0 to the X Y Z that you want to be set that Skin ID 220 

I done that but nothing, could this be messing it up?

local spawnX, spawnY, spawnZ = 2745.5830078125, -1608.7109375, 290.84722900391 
function joinHandler() 
    spawnPlayer(source, spawnX, spawnY, spawnZ) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    outputChatBox("Welcome to One In the Chamber", source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 
  
addEventHandler( "onPlayerWasted", getRootElement( ), 
    function() 
        setTimer( spawnPlayer, 2000, 1, source, 2745.5830078125, -1608.7109375, 290.84722900391 ) 
    end 
) 
  

Link to comment

It might be, comment these lines with "--[[" for start and "]]" to finish and then restart the whole script.

Example:

--[[local g_bLikePoneys = true; 
if ( g_bIsOpen ) then 
    outputChatBox( "Game menu is open." ); 
end]] 

Anything commented won't be run, this way you don't need to delete the code but it also won't be run.

Link to comment
It might be, comment these lines with "--[[" for start and "]]" to finish and then restart the whole script.

Example:

--[[local g_bLikePoneys = true; 
if ( g_bIsOpen ) then 
    outputChatBox( "Game menu is open." ); 
end]] 

Anything commented won't be run, this way you don't need to delete the code but it also won't be run.

Right it is working, but how will i make it so that when the player passes the Login screen the gui will show?

I tried onPlayerLogin, but i couldn't get it

function CreateSelectorWindow() 
wdwselector = guiCreateWindow(0.438,0.880,0.15,0.10,"Skinslector v1.0",true) 
guiWindowSetMovable(wdwselector,false) 
btnLeft = guiCreateButton(0.0,0.4,0.200,0.350,"<-",true,wdwselector) 
btnRight = guiCreateButton(0.76,0.4,0.200,0.350,"->",true,wdwselector) 
btnSelect = guiCreateButton(0.30,0.4,0.400,0.350,"Select",true,wdwselector) 
guiSetVisible(wdwselector, false) 
end 
  
function selectorenable () 
CreateSelectorWindow() 
 addEventHandler("onClientGUIClick", btnLeft, clientSkinLeft, false) 
 addEventHandler("onClientGUIClick", btnSelect, clientSkinSelect, false) 
 addEventHandler("onClientGUIClick", btnRight, clientSkinRight, false) 
            if (wdwselector ~= nil) then 
                 guiSetVisible(wdwselector, true) 
                 triggerServerEvent("FrontCamera", getRootElement()) 
            end  
            showCursor(true) 
    end 
addEventHandler("onPlayerLogin", rootElement, selectorenable) 

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