J'ai modifier un hud mais j'ai un problème avec la distance d'affichage

  • Initiateur de la discussion Deadman69330
  • Date de début
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
Bonjour,

J'ai fait un petit code (modifier d'un HUD sur gmodstore) pour que quand on regarde un joueur seulement les joueurs de sa faction voit son nom, sa vie et son job.

Par exemple que la Recrue Hanza voit les Officier de la Hanza, les Soldats... mais pas ceux de la faction ennemie.
Cependant j'ai un problème, c'est à dire que j'ai fait en sorte que la distance d'affichage soit inférieure à 140 unitées.
Avec la faction "Red Line" j'ai aucun problème mais avec la faction "Hanza" les noms s'affichent sur toute la map :/

Pourtant c'est exactement le même code, je comprend pas et je suis rester bloquer bien 2 heures dessus :(

Voilà mon code:
Code:
surface.CreateFont( "hudmainthickmed", { font = "BF4 Numbers", size = 22, weight = 500,} )
local function infoposjoueur() local ply = LocalPlayer() if ply:Team() == TEAM_RECRUEREDLINE or ply:Team() == TEAM_SOLDATREDLINE or ply:Team() == TEAM_OFFICIERREDLINE or ply:Team() == TEAM_LEADERREDLINE or ply:Team() == TEAM_SNIPERREDLINE or ply:Team() == TEAM_FUMIGATEURREDLINE then for _, v in pairs(player.GetAll()) do if ply != v then local pos = v:GetShootPos() pos.z = pos.z+5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and v:Team() == TEAM_RECRUEREDLINE or v:Team() == TEAM_SOLDATREDLINE or v:Team() == TEAM_OFFICIERREDLINE or v:Team() == TEAM_LEADERREDLINE or v:Team() == TEAM_SNIPERREDLINE or v:Team() == TEAM_FUMIGATEURREDLINE then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick),"hudmainthickmed",pos.x + 80, pos.y - 30,white,TEXT_ALIGN_LEFT ,TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255,255,255,0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200,200,200, 0), 1) draw.SimpleText(teamname,"hudmainthickmed",pos.x + 80, pos.y - 10, jobcol,TEXT_ALIGN_LEFT ,TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end if ply:Team() == TEAM_RECRUEHANZA or ply:Team() == TEAM_SOLDATHANZA or ply:Team() == TEAM_OFFICIERHANZA or ply:Team() == TEAM_LEADERHANZA or ply:Team() == TEAM_SNIPERHANZA or ply:Team() == TEAM_ARTIFICIERHANZA then for _, v in pairs(player.GetAll()) do if ply != v then local pos = v:GetShootPos() pos.z = pos.z+5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (ply:GetPos():Distance(v:GetPos()) < 140) and v:Team() == TEAM_RECRUEHANZA or v:Team() == TEAM_SOLDATHANZA or v:Team() == TEAM_OFFICIERHANZA or v:Team() == TEAM_LEADERHANZA or v:Team() == TEAM_SNIPERHANZA or v:Team() == TEAM_ARTIFICIERHANZA then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick),"hudmainthickmed",pos.x + 80, pos.y - 30,white,TEXT_ALIGN_LEFT ,TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255,255,255,0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200,200,200, 0), 1) draw.SimpleText(teamname,"hudmainthickmed",pos.x + 80, pos.y - 10, jobcol,TEXT_ALIGN_LEFT ,TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end if ply:Team() == TEAM_APPRENTIESTALKER or ply:Team() == TEAM_STALKER or ply:Team() == TEAM_VIEUXSTALKER then for _, v in pairs(player.GetAll()) do if ply != v then local pos = v:GetShootPos() pos.z = pos.z+5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and v:Team() == TEAM_APPRENTIESTALKER or v:Team() == TEAM_STALKER or v:Team() == TEAM_VIEUXSTALKER then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick),"hudmainthickmed",pos.x + 80, pos.y - 30,white,TEXT_ALIGN_LEFT ,TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255,255,255,0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200,200,200, 0), 1) draw.SimpleText(teamname,"hudmainthickmed",pos.x + 80, pos.y - 10, jobcol,TEXT_ALIGN_LEFT ,TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end
end
hook.Add("HUDPaint", "DrawNameOfPlayerTeams", infoposjoueur)
Merci de votre aide
 
Caesarovich

Caesarovich

Geek
Messages
182
Score réaction
31
Points
85
Mets des parenthèses à toutes les différententes conditions. Ça pourrait marcher
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
Caesarovich à dit:
Mets des parenthèses à toutes les différententes conditions. Ça pourrait marcher
Je vais essayer
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
UP
ça ne marche toujours pas, on voit toujours les joueurs à l'autre bout de la map

Code:
surface.CreateFont("hudmainthickmed", { font = "BF4 Numbers", size = 22, weight = 500
})
local function infoposjoueur() local ply = LocalPlayer() if (ply:Team() == TEAM_RECRUEREDLINE) or (ply:Team() == TEAM_SOLDATREDLINE) or (ply:Team() == TEAM_LIEUTENANTREDLINE) or (ply:Team() == TEAM_LEADERREDLINE) or (ply:Team() == TEAM_ESPIONREDLINE) or (ply:Team() == TEAM_FUMIGATEURREDLINE) or (ply:Team() == TEAM_MAJORREDLINE) or (ply:Team() == TEAM_CAPORALREDLINE) or (ply:Team() == TEAM_CAPITAINEREDLINE) then for _, v in pairs(player.GetAll()) do if ply ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and (v:Team() == TEAM_RECRUEREDLINE) or (v:Team() == TEAM_SOLDATREDLINE) or (v:Team() == TEAM_LIEUTENANTREDLINE) or (v:Team() == TEAM_LEADERREDLINE) or (v:Team() == TEAM_ESPIONREDLINE) or (v:Team() == TEAM_FUMIGATEURREDLINE) or (v:Team() == TEAM_MAJORREDLINE) or (v:Team() == TEAM_CAPORALREDLINE) or (v:Team() == TEAM_CAPITAINEREDLINE) then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end if (ply:Team() == TEAM_RECRUEHANZA) or (ply:Team() == TEAM_SOLDATHANZA) or (ply:Team() == TEAM_LIEUTENANTHANZA) or (ply:Team() == TEAM_LEADERHANZA) or (ply:Team() == TEAM_SNIPERHANZA) or (ply:Team() == TEAM_ARTIFICIERHANZA) or (ply:Team() == TEAM_MAJORHANZA) or (ply:Team() == TEAM_CAPORALHANZA) or (ply:Team() == TEAM_CAPITAINEHANZA) then for _, v in pairs(player.GetAll()) do if ply ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (ply:GetPos():Distance(v:GetPos()) < 140) and (v:Team() == TEAM_RECRUEHANZA) or (v:Team() == TEAM_SOLDATHANZA) or (v:Team() == TEAM_OFFICIERHANZA) or (v:Team() == TEAM_LEADERHANZA) or (v:Team() == TEAM_SNIPERHANZA) or (v:Team() == TEAM_ARTIFICIERHANZA) or (v:Team() == TEAM_MAJORHANZA) or (v:Team() == TEAM_CAPORALHANZA) or (v:Team() == TEAM_CAPITAINEHANZA) then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end if (ply:Team() == TEAM_APPRENTIESTALKER) or (ply:Team() == TEAM_STALKER) or (ply:Team() == TEAM_VIEUXSTALKER) then for _, v in pairs(player.GetAll()) do if ply ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and (v:Team() == TEAM_APPRENTIESTALKER) or (v:Team() == TEAM_STALKER) or (v:Team() == TEAM_VIEUXSTALKER) then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end if (ply:Team() == TEAM_RECRUEREICH) or (ply:Team() == TEAM_SOLDATREICH) or (ply:Team() == TEAM_LIEUTENANTREICH) or (ply:Team() == TEAM_LEADERREICH) or (ply:Team() == TEAM_PYROREICH) or (ply:Team() == TEAM_LOURDREICH) or (ply:Team() == TEAM_MAJORREICH) or (ply:Team() == TEAM_CAPORALREICH) or (ply:Team() == CAPITAINEREICH) then for _, v in pairs(player.GetAll()) do if ply ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and (v:Team() == TEAM_RECRUEREICH) or (v:Team() == TEAM_SOLDATREICH) or (v:Team() == TEAM_LIEUTENANTREICH) or (v:Team() == TEAM_LEADERREICH) or (v:Team() == TEAM_PYROREICH) or (v:Team() == TEAM_LOURDREICH) or (v:Team() == TEAM_MAJORREICH) or (v:Team() == TEAM_CAPORALREICH) or (v:Team() == CAPITAINEREICH) then local nick, plyTeam = v:Nick(), v:Team() draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end
end
hook.Add("HUDPaint", "DrawNameOfPlayerTeams", infoposjoueur)
 
thepsyca

thepsyca

Psychopathe
Messages
2 164
Score réaction
648
Points
365
Déjà tu devrais commencer par rendre ton code plus clair.

Évites de faire des répétitions de or TEAM == XXX

Personnellement je te conseillerais de faire :
Code:
local RedLine = { [TEAM_RECRUEREDLINE] = true, [TEAM_SOLDATREDLINE] = true, [TEAM_LIEUTENANTREDLINE] = true, [TEAM_LEADERREDLINE] = true, [TEAM_ESPIONREDLINE] = true, [TEAM_FUMIGATEURREDLINE] = true, [TEAM_MAJORREDLINE] = true, [TEAM_CAPORALREDLINE] = true, [TEAM_CAPITAINEREDLINE] = true,
}
local Hanza = {
}
local function IsHanza( ply ) if !IsValid( ply ) || !ply:IsPlayer() then return false end return Hanza[ply:Team()]
end
local function IsRedLine( ply ) if !IsValid( ply ) || !ply:IsPlayer() then return false end return RedLine[ply:Team()]
end
Tu n'es pas obligé de créer les fonctions mais tu devrais utiliser la même logique.

Généralement quand dans un code on déclare une variable utilisant une fonction c'est qu'elle est utilisé à plusieurs reprise dans le code donc faire local nick, plyTeam = v:Nick(), v:Team() dans ton code pour au final ne même pas utiliser la variable nick mais réutiliser la function v:Nick c'est pas fou.

Ton code est aussi très redondant.

Pas sur que ça fonctionne mais il est mieux que tu t'inspires de ça
Java:
timer.Simple(5, function() local faction = { ["RedLine"] = { [TEAM_RECRUEREDLINE] = true, [TEAM_SOLDATREDLINE] = true, [TEAM_LIEUTENANTREDLINE] = true, [TEAM_LEADERREDLINE] = true, [TEAM_ESPIONREDLINE] = true, [TEAM_FUMIGATEURREDLINE] = true, [TEAM_MAJORREDLINE] = true, [TEAM_CAPORALREDLINE] = true, [TEAM_CAPITAINEREDLINE] = true, }, ["Hanza"] = { [TEAM_RECRUEHANZA] = true, [TEAM_SOLDATHANZA] = true, [TEAM_LIEUTENANTHANZA] = true, [TEAM_LEADERHANZA] = true, [TEAM_SNIPERHANZA] = true, [TEAM_ARTIFICIERHANZA] = true, [TEAM_MAJORHANZA] = true, [TEAM_CAPORALHANZA] = true, [TEAM_CAPITAINEHANZA] = true, }, ["Stalker"] = { [TEAM_APPRENTIESTALKER] = true, [TEAM_STALKER] = true, [TEAM_VIEUXSTALKER] = true, }, ["Reich"] = { [TEAM_RECRUEREICH] = true, [TEAM_SOLDATREICH] = true, [TEAM_LIEUTENANTREICH] = true, [TEAM_LEADERREICH] = true, [TEAM_PYROREICH] = true, [TEAM_LOURDREICH] = true, [TEAM_MAJORREICH] = true, [TEAM_CAPORALREICH] = true, [CAPITAINEREICH] = true, } }
end )
surface.CreateFont("hudmainthickmed", { font = "BF4 Numbers", size = 22, weight = 500
})
local Team = ""
hook.Add("HUDPaint", "DrawNameOfPlayerTeam", function() local ply = LocalPlayer() if Team != "" then for _, v in ipairs(player.GetAll()) do if ply ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and faction[Team][v:Team()] then draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end
end )
hook.Add("OnPlayerChangedTeam", "HUDOnChangeTeam", function( ply, before, after ) for name, content in pairs( faction ) do if ( content[after] ) then Team = name break end end if ( faction[Team] && !faction[Team][after] ) then Team = "" end
end )
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
thepsyca à dit:
Déjà tu devrais commencer par rendre ton code plus clair.

Évites de faire des répétitions de or TEAM == XXX

Personnellement je te conseillerais de faire :
Code:
local RedLine = { [TEAM_RECRUEREDLINE] = true, [TEAM_SOLDATREDLINE] = true, [TEAM_LIEUTENANTREDLINE] = true, [TEAM_LEADERREDLINE] = true, [TEAM_ESPIONREDLINE] = true, [TEAM_FUMIGATEURREDLINE] = true, [TEAM_MAJORREDLINE] = true, [TEAM_CAPORALREDLINE] = true, [TEAM_CAPITAINEREDLINE] = true,
}
local Hanza = {
}
local function IsHanza( ply ) if !IsValid( ply ) || !ply:IsPlayer() then return false end return Hanza[ply:Team()]
end
local function IsRedLine( ply ) if !IsValid( ply ) || !ply:IsPlayer() then return false end return RedLine[ply:Team()]
end
Tu n'es pas obligé de créer les fonctions mais tu devrais utiliser la même logique.

Généralement quand dans un code on déclare une variable utilisant une fonction c'est qu'elle est utilisé à plusieurs reprise dans le code donc faire local nick, plyTeam = v:Nick(), v:Team() dans ton code pour au final ne même pas utiliser la variable nick mais réutiliser la function v:Nick c'est pas fou.

Ton code est aussi très redondant.

Pas sur que ça fonctionne mais il est mieux que tu t'inspires de ça
Java:
timer.Simple(5, function() local faction = { ["RedLine"] = { [TEAM_RECRUEREDLINE] = true, [TEAM_SOLDATREDLINE] = true, [TEAM_LIEUTENANTREDLINE] = true, [TEAM_LEADERREDLINE] = true, [TEAM_ESPIONREDLINE] = true, [TEAM_FUMIGATEURREDLINE] = true, [TEAM_MAJORREDLINE] = true, [TEAM_CAPORALREDLINE] = true, [TEAM_CAPITAINEREDLINE] = true, }, ["Hanza"] = { [TEAM_RECRUEHANZA] = true, [TEAM_SOLDATHANZA] = true, [TEAM_LIEUTENANTHANZA] = true, [TEAM_LEADERHANZA] = true, [TEAM_SNIPERHANZA] = true, [TEAM_ARTIFICIERHANZA] = true, [TEAM_MAJORHANZA] = true, [TEAM_CAPORALHANZA] = true, [TEAM_CAPITAINEHANZA] = true, }, ["Stalker"] = { [TEAM_APPRENTIESTALKER] = true, [TEAM_STALKER] = true, [TEAM_VIEUXSTALKER] = true, }, ["Reich"] = { [TEAM_RECRUEREICH] = true, [TEAM_SOLDATREICH] = true, [TEAM_LIEUTENANTREICH] = true, [TEAM_LEADERREICH] = true, [TEAM_PYROREICH] = true, [TEAM_LOURDREICH] = true, [TEAM_MAJORREICH] = true, [TEAM_CAPORALREICH] = true, [CAPITAINEREICH] = true, } }
end )
surface.CreateFont("hudmainthickmed", { font = "BF4 Numbers", size = 22, weight = 500
})
local Team = ""
hook.Add("HUDPaint", "DrawNameOfPlayerTeam", function() local ply = LocalPlayer() if Team != "" then for _, v in ipairs(player.GetAll()) do if ply ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end local x, y = pos.x, pos.y if (v:GetPos():Distance(ply:GetPos()) < 140) and faction[Team][v:Team()] then draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end
end )
hook.Add("OnPlayerChangedTeam", "HUDOnChangeTeam", function( ply, before, after ) for name, content in pairs( faction ) do if ( content[after] ) then Team = name break end end if ( faction[Team] && !faction[Team][after] ) then Team = "" end
end )
Merci d'avoir pris le temps de refaire mon code, je test tout ça :)
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
UP:

Code:
Error in hook OnPlayerChangedTeam: addons/custom_codes/lua/autorun/client/names_only_teams.lua:193: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback: [C]: in function 'pairs' addons/custom_codes/lua/autorun/client/names_only_teams.lua:193: in function 'fn' addons/ulib/lua/ulib/shared/hook.lua:109: in function <addons/ulib/lua/ulib/shared/hook.lua:92> [C]: in function '‌‎‬‪‭' lua/.dragondildos/rc1/../nul/40af6b227fe436a8bd0462370f353891963a0d80b7ff2b93ca428aa0975f31d0.lua:59: in function 'Call' gamemodes/darkrp/gamemode/modules/base/cl_gamemode_functions.lua:78: in function 'Function' lua/includes/modules/usermessage.lua:87: in function <lua/includes/modules/usermessage.lua:83>
[DarkRP] gamemodes/darkrp/gamemode/modules/base/cl_gamemode_functions.lua:78: 1. Call - [C]:-1 2. Function - gamemodes/darkrp/gamemode/modules/base/cl_gamemode_functions.lua:78 3. unknown - lua/includes/modules/usermessage.lua:87
 
thepsyca

thepsyca

Psychopathe
Messages
2 164
Score réaction
648
Points
365
Java:
timer.Simple(5, function() local faction = { ["RedLine"] = { [TEAM_RECRUEREDLINE] = true, [TEAM_SOLDATREDLINE] = true, [TEAM_LIEUTENANTREDLINE] = true, [TEAM_LEADERREDLINE] = true, [TEAM_ESPIONREDLINE] = true, [TEAM_FUMIGATEURREDLINE] = true, [TEAM_MAJORREDLINE] = true, [TEAM_CAPORALREDLINE] = true, [TEAM_CAPITAINEREDLINE] = true }, ["Hanza"] = { [TEAM_RECRUEHANZA] = true, [TEAM_SOLDATHANZA] = true, [TEAM_LIEUTENANTHANZA] = true, [TEAM_LEADERHANZA] = true, [TEAM_SNIPERHANZA] = true, [TEAM_ARTIFICIERHANZA] = true, [TEAM_MAJORHANZA] = true, [TEAM_CAPORALHANZA] = true, [TEAM_CAPITAINEHANZA] = true }, ["Stalker"] = { [TEAM_APPRENTIESTALKER] = true, [TEAM_STALKER] = true, [TEAM_VIEUXSTALKER] = true }, ["Reich"] = { [TEAM_RECRUEREICH] = true, [TEAM_SOLDATREICH] = true, [TEAM_LIEUTENANTREICH] = true, [TEAM_LEADERREICH] = true, [TEAM_PYROREICH] = true, [TEAM_LOURDREICH] = true, [TEAM_MAJORREICH] = true, [TEAM_CAPORALREICH] = true, [CAPITAINEREICH] = true } } surface.CreateFont("hudmainthickmed", { font = "BF4 Numbers", size = 22, weight = 500 }) local Team = "" local LPlayer = LocalPlayer() hook.Add("HUDPaint", "DrawNameOfPlayerTeam", function() if Team ~= "" then for _, v in ipairs(player.GetAll()) do if LPlayer ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end if (v:GetPos():Distance(LPlayer:GetPos()) < 140) and faction[Team][v:Team()] then draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end end) hook.Add("OnPlayerChangedTeam", "HUDOnChangeTeam", function(ply, before, after) if ( !faction ) then print("Error : Table doesn't exist !") return end for name, content in pairs(faction) do if (content[after]) then Team = name break end end if (faction[Team] && !faction[Team][after]) then Team = "" end end)
end)
 
  • J'aime
Réactions: Wasied
Wasied

Wasied

Psychopathe
Messages
911
Score réaction
398
Points
210
Caesarovich à dit:
Mets des parenthèses à toutes les différententes conditions. Ça pourrait marcher
Totalement inutile en Lua

Sinon le problème provient peux-être que les jobs prennent du temps à charger, donc faut mettre un timer comme thepscya t'a montré :)
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
thepsyca à dit:
Java:
timer.Simple(5, function() local faction = { ["RedLine"] = { [TEAM_RECRUEREDLINE] = true, [TEAM_SOLDATREDLINE] = true, [TEAM_LIEUTENANTREDLINE] = true, [TEAM_LEADERREDLINE] = true, [TEAM_ESPIONREDLINE] = true, [TEAM_FUMIGATEURREDLINE] = true, [TEAM_MAJORREDLINE] = true, [TEAM_CAPORALREDLINE] = true, [TEAM_CAPITAINEREDLINE] = true }, ["Hanza"] = { [TEAM_RECRUEHANZA] = true, [TEAM_SOLDATHANZA] = true, [TEAM_LIEUTENANTHANZA] = true, [TEAM_LEADERHANZA] = true, [TEAM_SNIPERHANZA] = true, [TEAM_ARTIFICIERHANZA] = true, [TEAM_MAJORHANZA] = true, [TEAM_CAPORALHANZA] = true, [TEAM_CAPITAINEHANZA] = true }, ["Stalker"] = { [TEAM_APPRENTIESTALKER] = true, [TEAM_STALKER] = true, [TEAM_VIEUXSTALKER] = true }, ["Reich"] = { [TEAM_RECRUEREICH] = true, [TEAM_SOLDATREICH] = true, [TEAM_LIEUTENANTREICH] = true, [TEAM_LEADERREICH] = true, [TEAM_PYROREICH] = true, [TEAM_LOURDREICH] = true, [TEAM_MAJORREICH] = true, [TEAM_CAPORALREICH] = true, [CAPITAINEREICH] = true } } surface.CreateFont("hudmainthickmed", { font = "BF4 Numbers", size = 22, weight = 500 }) local Team = "" local LPlayer = LocalPlayer() hook.Add("HUDPaint", "DrawNameOfPlayerTeam", function() if Team ~= "" then for _, v in ipairs(player.GetAll()) do if LPlayer ~= v then local pos = v:GetShootPos() pos.z = pos.z + 5 pos = pos:ToScreen() if not pos.visible then continue end if (v:GetPos():Distance(LPlayer:GetPos()) < 140) and faction[Team][v:Team()] then draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local teamname = v:getDarkRPVar("job") or team.GetName(v:Team()) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 1, pos.y + 41, Color(255, 255, 255, 0), 1) draw.DrawNonParsedText(teamname, "hudmainthickmed", pos.x + 80, pos.y + 4, Color(200, 200, 200, 0), 1) draw.SimpleText(teamname, "hudmainthickmed", pos.x + 80, pos.y - 10, jobcol, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) local health = DarkRP.getPhrase("health", v:Health()) draw.SimpleText(health, "hudmainthickmed", pos.x + 80, pos.y + 10, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER) end end end end end) hook.Add("OnPlayerChangedTeam", "HUDOnChangeTeam", function(ply, before, after) if ( !faction ) then print("Error : Table doesn't exist !") return end for name, content in pairs(faction) do if (content[after]) then Team = name break end end if (faction[Team] && !faction[Team][after]) then Team = "" end end)
end)
Marche pas,
Aucune erreur (enfin y en avait une mais je l'ai régler)

Code:
draw.SimpleText(string.upper(v:Nick()), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
à la place de

Code:
draw.SimpleText(string.upper(nick), "hudmainthickmed", pos.x + 80, pos.y - 30, white, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
La seule chose qui s'affiche c'est le nom du joueur au dessus de sa tête par défaut dans le Darkrp
 
  • Initiateur de la discussion
Deadman69330

Deadman69330

Psychopathe
Messages
2 289
Score réaction
309
Points
290
Wasied à dit:
Totalement inutile en Lua

Sinon le problème provient peux-être que les jobs prennent du temps à charger, donc faut mettre un timer comme thepscya t'a montré :)
La distance d'affichage est à cause d'un temps de latence de chargement des jobs trop long ?
 
Wasied

Wasied

Psychopathe
Messages
911
Score réaction
398
Points
210
Deadman69330 à dit:
La distance d'affichage est à cause d'un temps de latence de chargement des jobs trop long ?
Non rien à voir je parlais juste des jobs dans le code
 
Discord d'entraide
Rejoignz-nous sur Discord