NotAvailable Posted September 30, 2011 Share Posted September 30, 2011 Hi, i'm currently scripting a Spawn Menu. But when i click on the first location i get teleported to other location, nor do i get the same skin everytime. Script(Client): skins = { {"Ghost", "No", 285, false}, {"Juggernaut", "Yes", 311, true} } bases = { {"Helios One", "Hasbury, San Fierro", -2455.91015625, -135.7685546875, 26.113286972046}, {"Helios Two", "TEST BASE", 0, 0, 3} } jij = getLocalPlayer() function spawnFunc() if (getElementType(jij) == "player" ) then if (guiGetVisible(baseWnd)) then showCursor(false) guiSetVisible(baseWnd, false) guiSetVisible(skinWnd, false) guiSetVisible(spawnButt, false) removeEventHandler("onClientRender",root, drawFunc) else showCursor(true) baseWnd = guiCreateWindow(13,195,214,284,"Choose a base",false) guiWindowSetSizable(baseWnd,false) baseGrid = guiCreateGridList(10,24,194,251,false,baseWnd) guiGridListSetSelectionMode(baseGrid,2) guiGridListAddColumn(baseGrid,"Base",0.5) guiGridListAddColumn(baseGrid,"Location",0.7) guiGridListAddColumn(baseGrid,"X",0.7) guiGridListAddColumn(baseGrid,"Y",0.7) guiGridListAddColumn(baseGrid,"Z",0.7) skinWnd = guiCreateWindow(802,190,214,284,"Choose a skin",false) guiWindowSetSizable(skinWnd,false) skinGrid = guiCreateGridList(9,26,196,249,false,skinWnd) guiGridListSetSelectionMode(skinGrid,2) guiGridListAddColumn(skinGrid,"Skin",0.6) guiGridListAddColumn(skinGrid,"VIP",0.4) spawnButt = guiCreateButton(363,602,311,51,"",false) guiSetAlpha(spawnButt,0.30000001192093) triggerEvent("fillBaseGridlist", getLocalPlayer()) triggerEvent("fillSkinGridlist", getLocalPlayer()) addEventHandler("onClientGUIClick", spawnButt, spawnHim, false) addEventHandler("onClientRender",root, drawFunc) end end end bindKey("=", "Down", spawnFunc) function spawnHim (button, state, absoluteX, absoluteYe) if (source == spawnButt) and (guiGridListGetSelectedItem (baseGrid)) and (guiGridListGetSelectedItem (skinGrid)) then showCursor(false) guiSetVisible(baseWnd, false) guiSetVisible(skinWnd, false) guiSetVisible(spawnButt, false) removeEventHandler("onClientRender",root, drawFunc) local baseName = guiGridListGetItemText (baseGrid, guiGridListGetSelectedItem (baseGrid), 1) local skinName = guiGridListGetItemText (skinGrid, guiGridListGetSelectedItem (skinGrid), 1) for i,v in ipairs (bases) do baseX = guiGridListGetItemText (baseGrid, guiGridListGetSelectedItem (baseGrid), v[1]) baseY = guiGridListGetItemText (baseGrid, guiGridListGetSelectedItem (baseGrid), v[2]) baseZ = guiGridListGetItemText (baseGrid, guiGridListGetSelectedItem (baseGrid), v[3]) end for i,v in ipairs (skins) do skin = guiGridListGetItemText (baseGrid, guiGridListGetSelectedItem (baseGrid), 1) end triggerServerEvent ("spawnServer", getLocalPlayer(), baseName, skinName, baseX, baseY, baseZ, skin) else outputChatBox("* ERROR", 255, 0, 0, false) return end end function baseGridlistFunc() for i,v in ipairs (bases) do local row = guiGridListAddRow ( baseGrid ) guiGridListSetItemText ( baseGrid, row, 1, v[1], false, false ) guiGridListSetItemText ( baseGrid, row, 2, v[2], false, false ) guiGridListSetItemText ( baseGrid, row, 3, v[3], false, false ) guiGridListSetItemText ( baseGrid, row, 4, v[4], false, false ) guiGridListSetItemText ( baseGrid, row, 5, v[5], false, false ) end end addEvent("fillBaseGridlist", true) addEventHandler("fillBaseGridlist", getLocalPlayer(), baseGridlistFunc) function skinGridlistFunc() for i,v in ipairs (skins) do local row = guiGridListAddRow ( skinGrid ) guiGridListSetItemText ( skinGrid, row, 1, v[1], false, false ) guiGridListSetItemText ( skinGrid, row, 2, v[2], false, false ) end end addEvent("fillSkinGridlist", true) addEventHandler("fillSkinGridlist", getLocalPlayer(), skinGridlistFunc) function drawFunc() dxDrawRectangle(367.0,606.0,302.0,43.0,tocolor(0,0,0,140),false) dxDrawText("SPAWN",456.0,611.0,585.0,644.0,tocolor(255,200,0,255),1.0,"bankgothic","left","top",false,false,false) end Script(Server): function spawnGuy(baseName, skinName, baseX, baseY, baseZ, skin) local survivorTeam = getTeamFromName("Survivors") spawnPlayer(source, baseX, baseY, baseZ, 0, skin, 0, 0, survivorTeam) outputChatBox("* You spawned at base: "..baseName.."!", source, 0, 255, 0, false) outputChatBox("* You spawned as (a): "..skinName.."!", source, 0, 255, 0, false) end addEvent("spawnServer", true) addEventHandler("spawnServer", getRootElement(), spawnGuy) Link to comment
karlis Posted September 30, 2011 Share Posted September 30, 2011 (edited) you don't need to loop trough the bases to get current one, the reason of failure is that loop are getting kin/pos of last spawn, not current. Edited September 30, 2011 by Guest Link to comment
NotAvailable Posted September 30, 2011 Author Share Posted September 30, 2011 skin is a number, not a table/string.you are sending the name of skin, not id.don't call gridlistgettitemtext, just call the current selected table also, you don't need to loop trough the bases to get current one PS: ever heard of /debugscript 3? that should save post. I always use debugscript. I'll try to fix it. Link to comment
karlis Posted September 30, 2011 Share Posted September 30, 2011 i edited, re-read it. i failed a bit with the 1st part Link to comment
NotAvailable Posted September 30, 2011 Author Share Posted September 30, 2011 i edited, re-read it.i failed a bit with the 1st part Yeah i figured that out to ^^ Should this work? for i=1, #skins do local skin = skins[i][3] end Link to comment
karlis Posted September 30, 2011 Share Posted September 30, 2011 no, what's point of looping trough the table, if you can just get value from the gridlist itself once gridlist is made, u can forget about those tables. Link to comment
NotAvailable Posted September 30, 2011 Author Share Posted September 30, 2011 no, what's point of looping trough the table, if you can just get value from the gridlist itselfonce gridlist is made, u can forget about those tables. Ahh.. Thanks. 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