Bilal135 Posted February 2, 2016 Share Posted February 2, 2016 Since its been a long time I was inactive and didn't script anything for quite a while, so I forgot a few things. I created a spawn manager system which should spawn the player at the particular place with the skin he selects. I can't seem to find the problem, but it does spawn the player at the right place, but doesn't set the right one skin. Full script code: Client: addEvent("OnLogin", true) function onPlayerLogin() window = guiCreateWindow(321, 153, 538, 441, "L4D: Spawn Manager", false) guiWindowSetSizable(window, false) guiSetAlpha(window, 1.00) label = guiCreateLabel(11, 25, 716, 19, "Select a spawn location and a skin.", false, window) gridlist = guiCreateGridList(10, 54, 519, 327, false, window) spawn_column = guiGridListAddColumn(gridlist, "Location", 0.9) for i = 1, 2 do guiGridListAddRow(gridlist) end guiGridListSetItemText(gridlist, 0, 1, "Pershing Square", false, false) guiGridListSetItemText(gridlist, 1, 1, "Idlewood Gas Station", false, false) btn_spawn = guiCreateButton(10, 391, 131, 35, "Spawn", false, window) label_tip = guiCreateLabel(151, 401, 300, 15, "Tip: You MUST choose a skin and a location to spawn.", false, window) guiSetFont(label_tip, "default-bold-small") skin_window = guiCreateWindow(857, 153, 201, 441, "Skin", false) guiWindowSetSizable(skin_window, false) guiSetAlpha(skin_window, 1.00) skin_gridlist = guiCreateGridList(9, 53, 182, 327, false, skin_window) skin_column = guiGridListAddColumn(skin_gridlist, "Skin", 0.9) for i = 1, 2 do guiGridListAddRow(skin_gridlist) end guiGridListSetItemText(skin_gridlist, 0, 1, "CJ", false, false) guiGridListSetItemText(skin_gridlist, 1, 1, "Test", false, false) showCursor(true) end addEventHandler("OnLogin", root, onPlayerLogin) function onClickButtonSpawn() if (source == btn_spawn) then local row_spawn = guiGridListGetSelectedItem( gridlist ) local name_spawn = guiGridListGetItemText( gridlist , row_spawn, spawn_column) local row_skin = guiGridListGetSelectedItem( skin_gridlist ) local name_skin = guiGridListGetItemText( skin_gridlist , row_skin, skin_column) if name_spawn == "Pershing Square" then triggerServerEvent("SpawnPlayer_PershingSquare", localPlayer) guiSetVisible(window, false) guiSetVisible(skin_window, false) end if name_spawn == "Idlewood Gas Station" then triggerServerEvent("SpawnPlayer_IGS", localPlayer) guiSetVisible(window, false) guiSetVisible(skin_window, false) end if name_skin == "CJ" then setElementModel(localPlayer, 0) end if name_skin == "Test" then setElementModel(localPlayer, 20) end end end addEventHandler("onClientGUIClick", root, onClickButtonSpawn) Server: addEvent("SpawnPlayer_PershingSquare", true) addEvent("SpawnPlayer_IGS", true) local PershingSquare_spawnX, PershingSquare_spawnY, PershingSquare_spawnZ = 1536.2517089844, -1683.3726806641, 13.546875 function joinHandler_PershingSquare() spawnPlayer(source, PershingSquare_spawnX, PershingSquare_spawnY, PershingSquare_spawnZ) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("SpawnPlayer_PershingSquare", getRootElement(), joinHandler_PershingSquare) local IGS_spawnX, IGS_spawnY, IGS_spawnZ = 1959.55, -1714.46, 10 function joinHandler_IGS() spawnPlayer(source, IGS_spawnX, IGS_spawnY, IGS_spawnZ) fadeCamera(source, true) setCameraTarget(source, source) end addEventHandler("SpawnPlayer_IGS", getRootElement(), joinHandler_IGS) function onLogin() triggerClientEvent(source, "OnLogin", source) end addEventHandler("onPlayerLogin", root, onLogin) function hideCursor() showCursor(source, false) end addEventHandler("onPlayerSpawn", root, hideCursor) Thanks in advance. Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 Don't use setElementModel clientsided, else only the client can see it. Use the Skin-ID in spawnPlayer. Link to comment
Bilal135 Posted February 2, 2016 Author Share Posted February 2, 2016 Actually it is supposed to spawn player with the skin which player selects in the skin_window GUI. So what should I use to get to know what skin the player has selected in the skin_window GUI? Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 Then you have to trigger it in triggerServerEvent and use the skin-ID in spawnPlayer Link to comment
Bilal135 Posted February 2, 2016 Author Share Posted February 2, 2016 Then you have to trigger it in triggerServerEvent and use the skin-ID in spawnPlayer Can you edit my code for me so I can understand properly? Link to comment
Bonus Posted February 2, 2016 Share Posted February 2, 2016 Just use name_skin in triggerServerEvent, put skin in the function joinHandler_... and get the skin-ID. In your code the player can choose "CJ". But "CJ" is not a model-ID, so you have to use the model-ID instead. Link to comment
Bilal135 Posted February 3, 2016 Author Share Posted February 3, 2016 Still didn't get you, tried many ways but couldn't make it work. I am sorry but if you can fix the code for me, that will help me a lot to understand how things like this have to be done. Link to comment
Mann56 Posted February 3, 2016 Share Posted February 3, 2016 As bonus said just add the skin's at the time player spawns Client addEvent("OnLogin", true) function onPlayerLogin() window = guiCreateWindow(321, 153, 538, 441, "L4D: Spawn Manager", false) guiWindowSetSizable(window, false) guiSetAlpha(window, 1.00) label = guiCreateLabel(11, 25, 716, 19, "Select a spawn location and a skin.", false, window) gridlist = guiCreateGridList(10, 54, 519, 327, false, window) spawn_column = guiGridListAddColumn(gridlist, "Location", 0.9) for i = 1, 2 do guiGridListAddRow(gridlist) end guiGridListSetItemText(gridlist, 0, 1, "Pershing Square", false, false) guiGridListSetItemText(gridlist, 1, 1, "Idlewood Gas Station", false, false) btn_spawn = guiCreateButton(10, 391, 131, 35, "Spawn", false, window) label_tip = guiCreateLabel(151, 401, 300, 15, "Tip: You MUST choose a skin and a location to spawn.", false, window) guiSetFont(label_tip, "default-bold-small") skin_window = guiCreateWindow(857, 153, 201, 441, "Skin", false) guiWindowSetSizable(skin_window, false) guiSetAlpha(skin_window, 1.00) skin_gridlist = guiCreateGridList(9, 53, 182, 327, false, skin_window) skin_column = guiGridListAddColumn(skin_gridlist, "Skin", 0.9) for i = 1, 2 do guiGridListAddRow(skin_gridlist) end guiGridListSetItemText(skin_gridlist, 0, 1, "CJ", false, false) guiGridListSetItemText(skin_gridlist, 1, 1, "Test", false, false) showCursor(true) end addEventHandler("OnLogin", root, onPlayerLogin) function onClickButtonSpawn() if (source == btn_spawn) then local row_spawn = guiGridListGetSelectedItem( gridlist ) local name_spawn = guiGridListGetItemText( gridlist , row_spawn, spawn_column) local row_skin = guiGridListGetSelectedItem( skin_gridlist ) local name_skin = guiGridListGetItemText( skin_gridlist , row_skin, skin_column) if name_spawn == "Pershing Square" then triggerServerEvent("SpawnPlayer_PershingSquare", localPlayer,name_skin) guiSetVisible(window, false) guiSetVisible(skin_window, false) end if name_spawn == "Idlewood Gas Station" then triggerServerEvent("SpawnPlayer_IGS", localPlayer,name_skin) guiSetVisible(window, false) guiSetVisible(skin_window, false) end end end addEventHandler("onClientGUIClick", root, onClickButtonSpawn) Server addEvent("SpawnPlayer_PershingSquare", true) addEvent("SpawnPlayer_IGS", true) local PershingSquare_spawnX, PershingSquare_spawnY, PershingSquare_spawnZ = 1536.2517089844, -1683.3726806641, 13.546875 function joinHandler_PershingSquare(name_skin) if name_skin == "CJ" then spawnPlayer(source, PershingSquare_spawnX, PershingSquare_spawnY, PershingSquare_spawnZ,0,0) fadeCamera(source, true) setCameraTarget(source, source) else spawnPlayer(source, PershingSquare_spawnX, PershingSquare_spawnY, PershingSquare_spawnZ,0,20) fadeCamera(source, true) setCameraTarget(source, source) end end addEventHandler("SpawnPlayer_PershingSquare", getRootElement(), joinHandler_PershingSquare) local IGS_spawnX, IGS_spawnY, IGS_spawnZ = 1959.55, -1714.46, 10 function joinHandler_IGS(name_skin) if name_skin == "CJ" then spawnPlayer(source, IGS_spawnX, IGS_spawnY, IGS_spawnZ,0,0) fadeCamera(source, true) setCameraTarget(source, source) else spawnPlayer(source, IGS_spawnX, IGS_spawnY, IGS_spawnZ,0,20) fadeCamera(source, true) setCameraTarget(source, source) end end addEventHandler("SpawnPlayer_IGS", getRootElement(), joinHandler_IGS) function onLogin() triggerClientEvent(source, "OnLogin", source) end addEventHandler("onPlayerLogin", root, onLogin) function hideCursor() showCursor(source, false) end addEventHandler("onPlayerSpawn", root, hideCursor) I just added argument name_skin in the triggers and the skin id would be as mentioned in spawnPlayer. Hope it helps... 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