GTX Posted July 27, 2015 Posted July 27, 2015 You forgot to add music to meta: <file src="music/music.mp3"/> Should look like this: <meta> <info name="SpawnPanel" author="Shaman" description="None" version="1.0" type="script"></info> <script src="client.lua" type="client"></script> <script src="server.lua" type="server"></script> <file src="music/music.mp3"/> </meta> Server: function onlogin() triggerClientEvent(source, "showGUI", source) end addEventHandler("onPlayerLogin", getRootElement(), onlogin) function createAxisTeam () AxisTeam = createTeam ("Axis", 40, 40, 40) end addEventHandler ("onResourceStart", resourceRoot, createAxisTeam) function createUSATeam () USATeam = createTeam ("USA", 255, 255, 31) end addEventHandler ("onResourceStart", resourceRoot, createUSATeam) function joinTiger() setPlayerTeam(source,AxisTeam) setPlayerNametagColor ( source, 255, 200, 0 ) spawnPlayer (source, -2117.46, -2340.69, 30.2872810, 0,19, 0, 0) local x,y,z = getElementPosition(source) local vehicle = createVehicle(432,-2117.46, -2340.69, 30.2872810 + 3) warpPedIntoVehicle(source,vehicle) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("You have spawned with Tiger I Aufs E. tank!",source,0,200,0) end addEvent("spawn_tiger", true) addEventHandler("spawn_tiger",root,joinTiger) function joinSherman() setPlayerTeam(source,USATeam) setPlayerNametagColor ( source, 255, 200, 0 ) spawnPlayer (source, -2117.46, -2340.69, 30.2872810, 0,31, 0, 0) local x,y,z = getElementPosition(source) local vehicle = createVehicle(601,-2770.91, -2299.95, 4.52309 + 3) warpPedIntoVehicle(source,vehicle) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("You have spawned with M4 Sherman tank!",source,0,200,0) end addEvent("spawn_sherman", true) addEventHandler("spawn_sherman",root,joinSherman) function joinPershing() setPedSkin ( source, 33 ) local x,y,z = getElementPosition(source) local vehicle = createVehicle(455,-1067, -1207, 128.5 + 1) warpPedIntoVehicle(source,vehicle) outputChatBox("You have spawned with M26 Pershing tank!",source,0,200,0) end addEvent("spawn_pershing", true) addEventHandler("spawn_pershing",root,joinPershing) function joinTiger2() setPedSkin ( source, 12 ) local x,y,z = getElementPosition(source) local vehicle = createVehicle(450,-1067, -1207, 128.5 + 1) warpPedIntoVehicle(source,vehicle) outputChatBox("You have spawned with King Tiger II tank!",source,0,200,0) end addEvent("spawn_tiger2", true) addEventHandler("spawn_tiger2",root,joinTiger2) function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) triggerClientEvent(source, "showGUI", source) end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) function setCameraOnPlayerJoin () fadeCamera(source, true, 5) setCameraMatrix(source, -1231.6711, -273.84088, 22.8733, -1345.63241, -477.8543588, 12.8733) end addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) function setCameraOnPlayerWasted () fadeCamera(source, true, 5) setCameraMatrix(source, -1244.6711, -287.84088, 15.8733, -1345.63241, -477.8543588, 12.8733) end addEventHandler("onPlayerWasted", getRootElement(), setCameraOnPlayerWasted) function OnPlayerSpawn () showPlayerHudComponent("radar", true) end addEventHandler("onPlayerSpawn", getRootElement(), OnPlayerSpawn) -- Hide some of the hud components when a player joins the server addEventHandler ( "onPlayerWasted", root, function () setPlayerHudComponentVisible ( source, "ammo", false ) -- Hide the ammo displays for the newly joined player setPlayerHudComponentVisible ( source, "weapon", false ) -- Hide the weapon displays for the newly joined player end ) Client: classWnd = guiCreateWindow(185, 129, 479, 407, "Spawn Panel", false) guiWindowSetSizable(classWnd, false) guiSetVisible(classWnd, false) spawnG = guiCreateGridList(5, 27, 167, 160, false, classWnd) guiGridListAddColumn(spawnG, "Allies", 0.9) skins = { {"M4 Sherman", 287}, {"M26 Pershing (not available)", 171}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG) guiGridListSetItemText(spawnG, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG, row, 1, tostring(skins[2])) end guiGridListAddRow(spawnG) spawnbtn = guiCreateButton(35, 200, 102, 44, "To battle!", false, classWnd) desc = guiCreateMemo(10, 260, 459, 140, "Welcome to World of Tanks MTA server! Choose your team!", false, classWnd) guiMemoSetReadOnly(desc, true) guiCreateLabel(166, 242, 136, 13, "Spawn Panel By Shaman", false, classWnd) function joinAllies() if ( source == spawnbtn ) then local row, col = guiGridListGetSelectedItem( spawnG ) local name = guiGridListGetItemText( spawnG, row, col ) if name == "M4 Sherman" then local id = 287 triggerServerEvent("spawn_sherman", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) elseif name == "M26 Pershing" then local id = 171 triggerServerEvent("spawn_pershing", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) end end end addEventHandler("onClientGUIClick",root,joinAllies) addEventHandler("onClientGUIClick",root,joinSurvivor) spawnG2 = guiCreateGridList(302, 27, 167, 160, false, classWnd) guiGridListAddColumn(spawnG2, "Axis", 0.9) skins = { {"Tiger I Ausf E", 270}, {"King Tiger II (not available)", 127}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG2) guiGridListSetItemText(spawnG2, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG2, row, 1, tostring(skins[2])) end guiGridListAddRow(spawnG2) spawnbtn2 = guiCreateButton(330, 200, 102, 44, "To battle!", false, classWnd) function joinAxis() if ( source == spawnbtn2 ) then local row, col = guiGridListGetSelectedItem( spawnG2 ) local name = guiGridListGetItemText( spawnG2, row, col ) if name == "Tiger I Ausf E" then local id = 270 triggerServerEvent("spawn_tiger", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) elseif name == "King Tiger II" then local id = 127 triggerServerEvent("spawn_tiger2", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) end end end addEventHandler("onClientGUIClick",root,joinAxis) addEventHandler("onClientGUIClick",root,joinSwag) addEvent("showGUI", true) function guishow(player) guiSetVisible(classWnd, true) showCursor(true) end addEventHandler("showGUI",getRootElement(),guishow) --music local sound function startSound (killer, weapon, bodypart) sound = playSound("music/music.mp3") setSoundVolume(sound, 0.5) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), startSound) function destroySound() if isElement(sound) then stopSound(sound) end end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), destroySound) Tested, works fine.
#RooTs Posted July 27, 2015 Posted July 27, 2015 I tested and removed the bugs from your script Meta.xml "SpawnPanel" author="Shaman" description="None" version="1.0" type="script" /> Client.lua classWnd = guiCreateWindow(185, 129, 479, 407, "Spawn Panel", false) guiWindowSetSizable(classWnd, false) guiSetVisible(classWnd, false) spawnG = guiCreateGridList(5, 27, 167, 160, false, classWnd) guiGridListAddColumn(spawnG, "Allies", 0.9) skins = { {"M4 Sherman", 287}, {"M26 Pershing (not available)", 171}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG) guiGridListSetItemText(spawnG, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG, row, 1, tostring(skins[2])) end guiGridListAddRow(spawnG) spawnbtn = guiCreateButton(35, 200, 102, 44, "To battle!", false, classWnd) desc = guiCreateMemo(10, 260, 459, 140, "Welcome to World of Tanks MTA server! Choose your team!", false, classWnd) guiMemoSetReadOnly(desc, true) guiCreateLabel(166, 242, 136, 13, "Spawn Panel By Shaman", false, classWnd) function joinAllies() if ( source == spawnbtn ) then local row, col = guiGridListGetSelectedItem( spawnG ) local name = guiGridListGetItemText( spawnG, row, col ) if name == "M4 Sherman" then local id = 287 triggerServerEvent("spawn_sherman", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) elseif name == "M26 Pershing" then local id = 171 triggerServerEvent("spawn_pershing", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) end end end addEventHandler("onClientGUIClick",root,joinAllies) spawnG2 = guiCreateGridList(302, 27, 167, 160, false, classWnd) guiGridListAddColumn(spawnG2, "Axis", 0.9) skins = { {"Tiger I Ausf E", 270}, {"King Tiger II (not available)", 127}, } for i,skins in ipairs(skins) do row = guiGridListAddRow(spawnG2) guiGridListSetItemText(spawnG2, row, 1, tostring(skins[1]), false, false) guiGridListSetItemData(spawnG2, row, 1, tostring(skins[2])) end guiGridListAddRow(spawnG2) spawnbtn2 = guiCreateButton(330, 200, 102, 44, "To battle!", false, classWnd) function joinAxis() if ( source == spawnbtn2 ) then local row, col = guiGridListGetSelectedItem( spawnG2 ) local name = guiGridListGetItemText( spawnG2, row, col ) if name == "Tiger I Ausf E" then local id = 270 triggerServerEvent("spawn_tiger", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) elseif name == "King Tiger II" then local id = 127 triggerServerEvent("spawn_tiger2", getLocalPlayer(), id) guiSetVisible(classWnd, false) showCursor(false) end end end addEventHandler("onClientGUIClick",root,joinAxis) addEvent("showGUI", true) function guishow(player) guiSetVisible(classWnd, true) showCursor(true) end addEventHandler("showGUI",getRootElement(),guishow) function startSound (killer, weapon, bodypart) sound = playSound("music/music.mp3", true) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), startSound) function destroySound() if isElement(sound) then stopSound(sound) end end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), destroySound) Server.lua function onlogin() triggerClientEvent(source, "showGUI", source) end addEventHandler("onPlayerLogin", getRootElement(), onlogin) function createAxisTeam () AxisTeam = createTeam ("Axis", 40, 40, 40) end addEventHandler ("onResourceStart", resourceRoot, createAxisTeam) function createUSATeam () USATeam = createTeam ("USA", 255, 255, 31) end addEventHandler ("onResourceStart", resourceRoot, createUSATeam) function joinTiger() setPlayerTeam(source,AxisTeam) setPlayerNametagColor ( source, 255, 200, 0 ) spawnPlayer (source, -2117.46, -2340.69, 30.2872810, 0,19, 0, 0) local x,y,z = getElementPosition(source) local vehicle = createVehicle(432,-2117.46, -2340.69, 30.2872810 + 3) warpPedIntoVehicle(source,vehicle) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("You have spawned with Tiger I Aufs E. tank!",source,0,200,0) end addEvent("spawn_tiger", true) addEventHandler("spawn_tiger",root,joinTiger) function joinSherman() setPlayerTeam(source,USATeam) setPlayerNametagColor ( source, 255, 200, 0 ) spawnPlayer (source, -2117.46, -2340.69, 30.2872810, 0,31, 0, 0) local x,y,z = getElementPosition(source) local vehicle = createVehicle(601,-2770.91, -2299.95, 4.52309 + 3) warpPedIntoVehicle(source,vehicle) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("You have spawned with M4 Sherman tank!",source,0,200,0) end addEvent("spawn_sherman", true) addEventHandler("spawn_sherman",root,joinSherman) function joinPershing() setPedSkin ( source, 33 ) local x,y,z = getElementPosition(source) local vehicle = createVehicle(455,-1067, -1207, 128.5 + 1) warpPedIntoVehicle(source,vehicle) outputChatBox("You have spawned with M26 Pershing tank!",source,0,200,0) end addEvent("spawn_pershing", true) addEventHandler("spawn_pershing",root,joinPershing) function joinTiger2() setPedSkin ( source, 12 ) local x,y,z = getElementPosition(source) local vehicle = createVehicle(450,-1067, -1207, 128.5 + 1) warpPedIntoVehicle(source,vehicle) outputChatBox("You have spawned with King Tiger II tank!",source,0,200,0) end addEvent("spawn_tiger2", true) addEventHandler("spawn_tiger2",root,joinTiger2) function onWasted(totalAmmo, killer, killerWeapon, bodypart, stealth) triggerClientEvent(source, "showGUI", source) end addEventHandler ("onPlayerWasted", getRootElement(), onWasted) function setCameraOnPlayerJoin () fadeCamera(source, true, 5) setCameraMatrix(source, -1231.6711, -273.84088, 22.8733, -1345.63241, -477.8543588, 12.8733) end addEventHandler("onPlayerJoin", getRootElement(), setCameraOnPlayerJoin) function setCameraOnPlayerWasted () fadeCamera(source, true, 5) setCameraMatrix(source, -1244.6711, -287.84088, 15.8733, -1345.63241, -477.8543588, 12.8733) end addEventHandler("onPlayerWasted", getRootElement(), setCameraOnPlayerWasted) addEventHandler ( "onPlayerWasted", root, function () setPlayerHudComponentVisible ( source, "ammo", false ) -- Hide the ammo displays for the newly joined player setPlayerHudComponentVisible ( source, "weapon", false ) -- Hide the weapon displays for the newly joined player end )
Xwad Posted July 27, 2015 Author Posted July 27, 2015 One last question. I want to hide radar when the player die but its not working:/ function hideRadar () showPlayerHudComponent ( 'radar', false ); end addEventHandler("onPlayerWasted", getRootElement(), hideRadar) this a part of server.lua
#RooTs Posted July 27, 2015 Posted July 27, 2015 (edited) add function in Client.lua Example function startSound (killer, weapon, bodypart) showPlayerHudComponent ( 'radar', false ) sound = playSound("music/music.mp3", true) end addEventHandler("onClientPlayerWasted", getLocalPlayer(), startSound) function destroySound() showPlayerHudComponent ( 'radar', true ) if isElement(sound) then stopSound(sound) end end addEventHandler("onClientPlayerSpawn", getLocalPlayer(), destroySound) Edited July 27, 2015 by Guest
xeon17 Posted July 27, 2015 Posted July 27, 2015 One last question. I want to hide radar when the player die but its not working:/ function hideRadar () showPlayerHudComponent ( 'radar', false ); end addEventHandler("onPlayerWasted", getRootElement(), hideRadar) this a part of server.lua It doesn't work because you haven't definied the player argument. Use the code which RooTs gave you, it should work.
Xwad Posted July 28, 2015 Author Posted July 28, 2015 (edited) I have a problem again I made a new gui for spawn and its not working correctly. When a player die then a gui will open and there the player must click on a gui button to get back to the hangar (setcameramatrix) . The problem is that if a player die then the gui will open for other players too:/ i tryed to make it with TriggerClientEvent but it didnt worked:( here is the edited part of the spawn script server.lua function shopa(totalAmmo, killer, killerWeapon, bodypart, stealth) fadeCamera(source, true, 5) setCameraMatrix(source, -1244.6711, -287.84088, 15.8733, -1345.63241, -477.8543588, 12.8733) triggerClientEvent(source, "showGUI", source) end addEvent("shopa",true) addEventHandler("shopa",root,shopa) client.lua GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(177,177,296,234,"You are dead!",false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Button[3] = guiCreateButton(10,75,290,230,"Return to hangar",false,GUIEditor_Window[1]) function openguidmshop () guiSetInputEnabled(true) guiSetVisible ( GUIEditor_Window[1], true ) showCursor ( true ) end addEventHandler( "onClientPlayerWasted", localPlayer, openguidmshop ) function destroyguidmshop () guiSetInputEnabled(false) guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], destroyguidmshop ) function shopa () triggerServerEvent ( "shopa", getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], shopa ) Edited July 28, 2015 by Guest
Miika Posted July 28, 2015 Posted July 28, 2015 server.lua function destroyguidmshop () guiSetInputEnabled(false) guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], destroyguidmshop ) function shopa () triggerServerEvent ( "shopa", getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], shopa ) You cannot run client functions in serverside script.
Xwad Posted July 28, 2015 Author Posted July 28, 2015 shit i posted the wrong script sry client GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Window[1] = guiCreateWindow(177,177,296,234,"You are dead!",false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Button[3] = guiCreateButton(10,75,290,230,"Return to hangar",false,GUIEditor_Window[1]) function openguidmshop () guiSetInputEnabled(true) guiSetVisible ( GUIEditor_Window[1], true ) showCursor ( true ) end addEventHandler( "onClientPlayerWasted", localPlayer, openguidmshop ) function destroyguidmshop () guiSetInputEnabled(false) guiSetVisible ( GUIEditor_Window[1], false ) showCursor ( false ) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], destroyguidmshop ) function shopa () triggerServerEvent ( "shopa", getLocalPlayer()) end addEventHandler ( "onClientGUIClick", GUIEditor_Button[3], shopa ) server function shopa(totalAmmo, killer, killerWeapon, bodypart, stealth) fadeCamera(source, true, 5) setCameraMatrix(source, -1244.6711, -287.84088, 15.8733, -1345.63241, -477.8543588, 12.8733) triggerClientEvent(source, "showGUI", source) end addEvent("shopa",true) addEventHandler("shopa",root,shopa)
Miika Posted July 28, 2015 Posted July 28, 2015 triggerClientEvent(source, "showGUI", source) Do you have event added in client side?
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