PoliceSA Posted December 27, 2014 Share Posted December 27, 2014 There is a way to get the name of all players on my team called for example : MTA, and write they're name with dxdrawtext ? Link to comment
PoliceSA Posted December 27, 2014 Author Share Posted December 27, 2014 How? can you explain me please? Link to comment
xeon17 Posted December 27, 2014 Share Posted December 27, 2014 getPlayerTeam getTeamName dxDrawText Link to comment
Dealman Posted December 27, 2014 Share Posted December 27, 2014 Yes, first of all you need to get all player elements and then check their team. After that, add them to a table. For example; -- Define the table. local mtaTeamPlayers = {}; -- First of all, fetch all current player elements local allPlayers = getElementsByType("player"); -- Then loop through all players and check their team name for k, v in ipairs(allPlayers) do if(getTeamName(getPlayerTeam(v)) == "MTA") then -- If their team name matches the one you want, get their player name and store it in a local variable local playerName = getPlayerName(v); -- Insert their name into our previously defined table table.insert(mtaTeamPlayers, #mtaTeamPlayers, playerName); end end Of course that's just an example. You'll have to make code which updates the table whenever a player join and quits. You'll also have to loop through the table to draw their names using dxDrawText. Edit: Or use the function manawydan suggested Link to comment
PoliceSA Posted December 27, 2014 Author Share Posted December 27, 2014 Aahah thx but what should I put in the client? Cuz i'm not good to script i should use on server like that? for k, v in ipairs(allPlayers) do if(getTeamName(getPlayerTeam(v)) == "team[1]") then local playerName = getPlayerName(v) table.insert(mtaTeamPlayers, #mtaTeamPlayers, playerName); triggerClientEvent (source, "TriggerToClient", g_Root, mtaTeamPlayers) end end Link to comment
manawydan Posted December 27, 2014 Share Posted December 27, 2014 one example, addEventHandler("onClientRender",root, function() local team = getPlayerTeam(localPlayer) if not(team)then return end local players = getPlayersInTeam(team) for k,v in ipairs(players)do -- you dxdraw here end end) Link to comment
PoliceSA Posted December 27, 2014 Author Share Posted December 27, 2014 .... local team = getPlayerTeam(localPlayer) if not(team)then return end local players = getPlayersInTeam(team) for k,v in ipairs(players)do dxDrawText (whatishouldputhere?, x + 60, 420, x, y, tocolor( 255, 255, 255 ), 1, "default-bold" ) end Link to comment
xeon17 Posted December 27, 2014 Share Posted December 27, 2014 (edited) addEventHandler("onClientRender",root, function () local team = getPlayerTeam(localPlayer) if not(team)then return end local players = getPlayersInTeam(team) for _,v in ipairs(players)do dxDrawText (getPlayerName(v), x + 60, 420, x, y, tocolor( 255, 255, 255 ), 1, "default-bold" ) end Edited December 27, 2014 by Guest Link to comment
PoliceSA Posted December 27, 2014 Author Share Posted December 27, 2014 Okay but this is for just 1 player and others? Link to comment
xeon17 Posted December 27, 2014 Share Posted December 27, 2014 I think it's already draw the name's of all players in team, idk Link to comment
MTA Team botder Posted December 27, 2014 MTA Team Share Posted December 27, 2014 You don't move the names. Every name will be rendered on the same spot. You should use the index value (that one you called _) Link to comment
PoliceSA Posted December 27, 2014 Author Share Posted December 27, 2014 Like That? .... for id,v in ipairs(players)do dxDrawText(getPlayerName(v), x + 60,420*id, x, screenHeight, tocolor(255, 255, 255, 255), 1, "default-bold", "left", "top", false, false, true, true, false) Link to comment
MTA Team botder Posted December 27, 2014 MTA Team Share Posted December 27, 2014 Yeah, almost. With your code your first name will be rendered at height 420, the next one at 840 and so on. (id starts at 1) Solution: dxDrawText(..., x + 60, 420 + 30 * (id - 1), ...) Link to comment
PoliceSA Posted December 28, 2014 Author Share Posted December 28, 2014 It Work just for the local player but the other no ..i should trigger it via server but i don't know how Link to comment
MTA Team botder Posted January 2, 2015 MTA Team Share Posted January 2, 2015 Show us the code in the current state. 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