kalitonchik Posted March 11, 2009 Share Posted March 11, 2009 local guiTextLabel = nil local guiTextLabelTeamName = nil local guiTextLabelText = nil function showPlayerTheirTeam(player, text, r, g, b) if ( player == getLocalPlayer() ) then if ( guiTextLabel ) then guiSetText ( guiTextLabelTeamName, text ) guiSetColor ( guiTextLabelTeamName, r, g, b ) else guiTextLabel = guiCreateLabel( 0.01, 0.20, 0.8203, 0.5, "Current Team: ", true ) if ( guiTextLabel ) then local guiLength = guiLabelGetTextExtent ( guiTextLabel ) local screenX, screenY = guiGetScreenSize() guiLength = tonumber(guiLength) / screenX local guiTextLabelTeamName = guiCreateLabel( tonumber(guiLength) + 0.01, 0.20, 1, 0.5, text, true ) if ( guiTextLabelTeamName ) then guiLabelSetColor ( guiTextLabelTeamName, tonumber(r), tonumber(g), tonumber(b) ) end end end end end function onClientPlayerSpawn() --outputChatBox ( "Ive Loaded, contacting server!" ) triggerServerEvent ( "Event_clientScriptLoaded", getRootElement(), getLocalPlayer() ) end addEvent ( "Event_showPlayerTheirTeam", true ) addEventHandler ( "Event_showPlayerTheirTeam", getRootElement(), showPlayerTheirTeam ) addEventHandler ( "onClientPlayerSpawn", getLocalPlayer(), onClientPlayerSpawn ) Problem is, when player spawn then Label shows Current Team, but when map changes Label shows the old Team from previous map. You can make a reconnect, for update Label (but it is inconvenient). Need to finish script Update Label whit what functions? add/remove function? destroy element? Link to comment
darkdreamingdan Posted March 11, 2009 Share Posted March 11, 2009 guiSetText is what you can use to update a label. Link to comment
kalitonchik Posted March 11, 2009 Author Share Posted March 11, 2009 Whot you mean with guiSetText is what you can use to update a label. I need update current team when start new map with new teams. I think its licke that addEventHandler( "onGamemodeMapStop", removeguiTextLabel) Help Link to comment
50p Posted March 11, 2009 Share Posted March 11, 2009 You can set a timer to check what is his current team or make custom events which would update that label when something happens (eg. player spawned, selected team, etc.)... You've got the event already (Event_showPlayerTheirTeam), just trigger that even when it's required to update the team name. Link to comment
kalitonchik Posted March 11, 2009 Author Share Posted March 11, 2009 function onMapFinish ( name ) update guiTextLabel end addEventHandler( "update", root, onMapFinish) i dont know syntax i search everywhere (wiki, ore in other game mode resources) Link to comment
50p Posted March 11, 2009 Share Posted March 11, 2009 You must understand events. If you don't understand them then you can say good bye to scripting or learn it. http://development.mtasa.com/index.php? ... ent_system 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