jET Posted October 2, 2009 Share Posted October 2, 2009 How to do that - when you click the Button Groove join the team? Sorry For my bad english client : GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} function stgui_close() showCursor(false) guiSetVisible( GUIEditor_Window[1], false ) outputChatBox ( "Team Selected!", 255, 255, 36, true) end function stgui_show(key, keyState) outputChatBox ( "Select Team", 255, 255, 36, true) showCursor(true) guiSetVisible( GUIEditor_Window[1], true ) end function StartMode(startedResource) if getThisResource() == startedResource then showCursor(true) GUIEditor_Window[1] = guiCreateWindow(124,233,781,360,"Team Deathmatch 0.1",false) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Label[1] = guiCreateLabel(0.2151,0.1389,0.5826,0.1778,"Team Deathmatch 0.1",true,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255-255-34) guiLabelSetVerticalAlign(GUIEditor_Label[1],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false) guiSetFont(GUIEditor_Label[1],"sa-gothic") GUIEditor_Label[2] = guiCreateLabel(0.3841,0.3417,0.2535,0.1306,"Select Team",true,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[2],255-255-255) guiLabelSetVerticalAlign(GUIEditor_Label[2],"top") guiLabelSetHorizontalAlign(GUIEditor_Label[2],"left",false) guiSetFont(GUIEditor_Label[2],"sa-header") grove = guiCreateButton(0.274,0.5306,0.4443,0.0917,"Grove",true,GUIEditor_Window[1]) ballas = guiCreateButton(0.274,0.6806,0.4443,0.0917,"Ballas",true,GUIEditor_Window[1]) vagos = guiCreateButton(0.274,0.8333,0.4443,0.0917,"Vagos",true,GUIEditor_Window[1]) guiSetVisible( GUIEditor_Window[1], true ) addEventHandler ( "onClientGUIClick", grove, teamgrove, false ) addEventHandler ( "onClientGUIClick", ballas, teamballas, false ) addEventHandler ( "onClientGUIClick", vagos, teamvagos, false ) bindKey ( "m", "down", stgui_show ) end end addEventHandler("onClientResourceStart", getRootElement(), StartMode) function teamgrove(startedResource) if getThisResource() == startedResource then triggerServerEvent("teamgrove", getRootElement(), p) end end addEventHandler("onClientResourceStart", getRootElement(), teamgrove) server: function createTeamsOnStart () teamgrove = createTeam ( "Grove", 0,255,0 ) teamballas = createTeam ( "Ballas", 0,255,0 ) teamvagos = createTeam ( "Vagos", 0,255,0 ) end addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), createTeamsOnStart ) function joingrove ( source ) setPlayerTeam ( source, teamgrove ) triggerClientEvent("teamgrove", getRootElement(),source) end addEvent("teamgrove", true) addEventHandler("teamgrove", getRootElement(), joingrove) Link to comment
Gamesnert Posted October 2, 2009 Share Posted October 2, 2009 function teamgrove(startedResource) if getThisResource() == startedResource then triggerServerEvent("teamgrove", getRootElement(), p) end end addEventHandler("onClientResourceStart", getRootElement(), teamgrove) May I ask you, did you just copy this from the function above? As it doesn't work this way. Basically, you're telling the server you want to join "Grove" team on resource start. And also when you click the button. Then something else. What's the "p" in triggerServerEvent? It doesn't appear to be anything, so setPlayerTeam will return a warning. To fix both of these issues, let's fix stuff up a little: function teamgrove() -- We don't want it started on resource start. Basically all of importance that changed triggerServerEvent("teamgrove", getRootElement()) end function joingrove ( ) -- Changed the function a little to not even require the "source" or "p" argument. setPlayerTeam ( client, teamgrove ) triggerClientEvent("teamgrove", getRootElement(),client) -- Is this even required? I don't see any reference to this back in your code end addEvent("teamgrove", true) addEventHandler("teamgrove", getRootElement(), joingrove) I guess that should fix it up a little. 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