Lloyd Logan Posted January 4, 2013 Share Posted January 4, 2013 How can i make it so that there are 2 spawn points, and depending on which skin you have, you are spawned at one of the spawn points? Link to comment
uhm Posted January 4, 2013 Share Posted January 4, 2013 how would the player choose which skin he wants? I suggest a GUI: click on some button, then you can use the OnClientGUIClick event to do the spawning, which has a parameter for setting the skin check out Remps GUI creator for easy designing and for generating the code https://community.multitheftauto.com/index.php?p= ... ils&id=141 Link to comment
Anderl Posted January 4, 2013 Share Posted January 4, 2013 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. Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 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 Link to comment
Jaysds1 Posted January 5, 2013 Share Posted January 5, 2013 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
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 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
Anderl Posted January 5, 2013 Share Posted January 5, 2013 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 Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 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 Thanks I'll try!! Link to comment
Anderl Posted January 5, 2013 Share Posted January 5, 2013 Okay, and don't forget to change skin IDs and respective spawn positions in "g_pSkins" table. Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 Okay, and don't forget to change skin IDs and respective spawn positions in "g_pSkins" table. Thank You Link to comment
Anderl Posted January 5, 2013 Share Posted January 5, 2013 No problem. Have you tested it? Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 No problem.Have you tested it? I am extremely stuck with this, i want it so that if you have id 7, you will spawn at... 2745.5830078125, -1608.7109375, 290.84722900391, but absoulutley nothing happens when i select id 7? Link to comment
Anderl Posted January 5, 2013 Share Posted January 5, 2013 Did it work before you add my code? Do you get any errors? Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 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
Baseplate Posted January 5, 2013 Share Posted January 5, 2013 [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
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 [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
Anderl Posted January 5, 2013 Share Posted January 5, 2013 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
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 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
Anderl Posted January 5, 2013 Share Posted January 5, 2013 onPlayerLogin is server-side only. Add it server-side, create a client-side code to show the GUI and call it from server-side login event. Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 onPlayerLogin is server-side only.Add it server-side, create a client-side code to show the GUI and call it from server-side login event. I'll try, thanks Link to comment
Lloyd Logan Posted January 5, 2013 Author Share Posted January 5, 2013 onPlayerLogin is server-side only.Add it server-side, create a client-side code to show the GUI and call it from server-side login event. I am now confused as to what i am doing Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now