Hero192 Posted August 16, 2015 Share Posted August 16, 2015 Hey again, i still have the same problem about the blip visiblity, i want it shows only for criminal team . I want when i go to ped to change the team if i changed the team to police i want this blip be invisible ,my code doesn't works like i want ,it just works if i restarted the script ,i want it be refreshed. Anyone can give me his hand on this please,i m stuck here.. Thanks in advance. setElementVisibleTo(criminalBlip, root, false) for i, player in ipairs ( getPlayersInTeam ( getTeamFromName ( "Criminal" ) ) ) do outputChatBox("Go pickup it",player,255,0,20) setElementVisibleTo(criminalBlip, player, true) end Link to comment
t3wz Posted August 16, 2015 Share Posted August 16, 2015 IIYAMA already answered you. This example should enable the event "onPlayerTeamChange". local lastPlayerTeam = {} setTimer(function () local players = getElementsByType("player") for i=1,#players do local player = players[i] local playerTeam = getPlayerTeam(player) or false -- make sure it always returns false, if it returns nil. if playerTeam then local lastTeam = lastPlayerTeam[player] or false -- make sure it always returns false, if it returns nil. if playerTeam ~= lastTeam then triggerEvent("onPlayerTeamChange",player,isElement(lastTeam) and lastTeam or false,playerTeam) lastPlayerTeam[player] = playerTeam end else local lastTeam = lastPlayerTeam[player] if lastTeam then triggerEvent("onPlayerTeamChange",player,isElement(lastTeam) and lastTeam or false,nil) lastPlayerTeam[player] = nil end end end end,1000,0) addEventHandler("onPlayerQuit",root, function () if lastPlayerTeam[source] then lastPlayerTeam[source] = nil end end) Which you can use here: addEventHandler ( "onPlayerTeamChange", root, function ( oldTeam,newTeam ) local team = getTeamFromName ( "Criminal" ) if oldTeam == team then setElementVisibleTo( criminalBlip, source, nil ) elseif newTeam == team then setElementVisibleTo( criminalBlip, source, true ) end end) And this is maybe handy too. addEventHandler("onPlayerJoin",root, function () setElementVisibleTo(criminalBlip, source, false) end) Nothing is tested, I will leave that to you. The first code will add a new event called "onPlayerTeamChange" and the second will make the blip visible/invisible, just add them to your current code ... 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