• DarkRP Editing
    5 replies, posted
Hiya all, Recently I've been making various modifications to DarkRP. I'm trying to create a 'Wanted' style effect, but with 'Marked' and only viewable by one class. I added this to various files: cl_init.lua: [lua]local function DrawDisplay() for k, v in pairs(player.GetAll()) do if v:GetNWBool("zombieToggle") == true then DrawZombieInfo(v) end if v:GetNWBool("wanted") == true then DrawWantedInfo(v) end end[/lua] to [lua]local function DrawDisplay() for k, v in pairs(player.GetAll()) do if v:GetNWBool("zombieToggle") == true then DrawZombieInfo(v) end if v:GetNWBool("wanted") == true then DrawWantedInfo(v) end if v:GetNWBool("assassin") == true then DrawAssassinInfo(v) end end[/lua] and [lua]function DrawAssassinInfo(ply) if not ply:Alive() then return end local pos = ply:EyePos() if not pos:RPIsInSight({LocalPlayer(), ply}) then return end pos.z = pos.z + 14 pos = pos:ToScreen() if GetGlobalInt("nametag") == 1 then draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1) draw.DrawText(ply:Nick(), "TargetID", pos.x, pos.y, team.GetColor(ply:Team()), 1) end draw.DrawText(LANGUAGE.assassin, "TargetID", pos.x, pos.y - 20, Color(255, 255, 255, 200), 1) draw.DrawText(LANGUAGE.assassin, "TargetID", pos.x + 1, pos.y - 21, Color(255, 0, 0, 255), 1) end[/lua] in between the DrawWantedInfo and DrawZombieInfo functions. I then added this to main.lua: [lua]function PlayerAssassin(ply, args) local t = ply:Team() if not (t == TEAM_ASSA) then Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "assassin", "/target")) else local p = FindPlayer(args) if p and p:Alive() then p:SetNWBool("assassin", true) for a, b in pairs(player.GetAll()) do b:PrintMessage(HUD_PRINTCENTER, string.format("RAWRGH", p:Nick())) timer.Create(p:Nick() .. " assassintimer", 10000, 1, TimerUnassassin, ply, args) end CfgVars["assassintarget"] = p:Nick() else Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "player: "..tostring(args))) end end return "" end AddChatCommand("/target", PlayerAssassin) function PlayerUnAssassin(ply, args) local t = ply:Team() if not (t == TEAM_ASSA) then Notify(ply, 1, 6, string.format(LANGUAGE.must_be_x, "assassin", "/untarget")) else local p = FindPlayer(args) if p and p:Alive() and p:GetNWBool("assassin") then p:SetNWBool("assassin", false) for a, b in pairs(player.GetAll()) do timer.Destroy(p:Nick() .. " assassintimer") end CfgVars["assassintarget"] = "" else Notify(ply, 1, 4, string.format(LANGUAGE.could_not_find, "Player: "..tostring(args))) end end return "" end AddChatCommand("/untarget", PlayedUnAssassin) function TimerUnassassin(ply, args) local p = FindPlayer(args) if p and p:Alive() and p:GetNWBool("assassin") then p:SetNWBool("assassin", false) for a, b in pairs(player.GetAll()) do b:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.assassin_expired, p:Nick())) timer.Destroy(p:Nick() .. " assassintimer") end else return "" end end[/lua] Yes, I did add all the right terms in the language_sh.lua file, but I constantly get spammed with this error: ERROR: GAMEMODE:'HUDPaint' Failed: includes/modules/draw.lua:144: bad argument #1 to 'len' (string expected, got nil) This happens as soon as you choose the class, though when using /target the message does print to the center of the HUD (I've not tested to see if a sign comes up above the target's head yet, however). Any ideas?
Yes, don't use DarkRp.
LANGUAGE.assassin is either not a string or nil.
[QUOTE=Gbps;18494671]LANGUAGE.assassin is either not a string or nil.[/QUOTE] [lua]assassin = "Marked",[/lua] That's set in language_sh.lua, so it's a string and isn't nil. Thanks for your suggestion, however. Any other ideas?
ERROR: GAMEMODE:'HUDPaint' Failed: includes/modules/draw.lua:144: bad argument #1 to 'len' (string expected, got nil) Means that that function in draw.lua wanted a string and was given a nil value. The only two places you use a function from the draw library is, [lua] draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1) [/lua]and [lua] draw.DrawText(LANGUAGE.assassin, "TargetID", pos.x + 1, pos.y - 21, Color(255, 0, 0, 255), 1) [/lua] And since I can assume ply:Nick() is not nil, the only other possible thing could be LANGUAGE.assassin.
[QUOTE=Gbps;18494801]ERROR: GAMEMODE:'HUDPaint' Failed: includes/modules/draw.lua:144: bad argument #1 to 'len' (string expected, got nil) Means that that function in draw.lua wanted a string and was given a nil value. The only two places you use a function from the draw library is, [lua] draw.DrawText(ply:Nick(), "TargetID", pos.x + 1, pos.y + 1, Color(0, 0, 0, 255), 1) [/lua]and [lua] draw.DrawText(LANGUAGE.assassin, "TargetID", pos.x + 1, pos.y - 21, Color(255, 0, 0, 255), 1) [/lua] And since I can assume ply:Nick() is not nil, the only other possible thing could be LANGUAGE.assassin.[/QUOTE] In response to this, I changed the two lines to: [lua]draw.DrawText("Marked", "TargetID", pos.x, pos.y - 20, Color(255, 255, 255, 200), 1) draw.DrawText("Marked", "TargetID", pos.x + 1, pos.y - 21, Color(255, 0, 0, 255), 1)[/lua] But the error still floods the screen... Maybe there is another file which includes these which could set off a draw function... Edit: Ah, hang on. I think I've found the error is coming from: [lua] if LocalPlayer():GetNWBool("helpAssassin") then draw.RoundedBox(10, 10, 10, 560, 130, Color(0, 0, 0, 255)) draw.RoundedBox(10, 12, 12, 556, 126, Color(51, 58, 51, 200)) draw.RoundedBox(10, 12, 12, 556, 20, Color(0, 0, 70, 200)) draw.DrawText("Assassin Help", "ScoreboardText", 30, 12, Color(255,0,0,255),0) draw.DrawText(LANGUAGE.assassinhelp, "ScoreboardText", 30, 35, Color(255,255,255,255),0)[/lua] Let me see if these draws exist. Edit2: In fact, could it be this here: [lua]if LocalPlayer():Team() == TEAM_ASSA and not LocalPlayer():GetNWBool("helpAssasin") then draw.RoundedBox(10, 10, 10, 460, 110, Color(0, 0, 0, 155)) draw.RoundedBox(10, 12, 12, 456, 106, Color(51, 58, 51,100)) draw.RoundedBox(10, 12, 12, 456, 20, Color(0, 0, 70, 100)) draw.DrawText(LANGUAGE.assasin_target, "ScoreboardText", 30, 12, Color(255,0,0,255),0) draw.DrawText(LocalPlayer():GetNWString("target"), "ScoreboardText", 30, 35, Color(255,255,255,255),0) end[/lua] Edit3: Yes, it was that last bit of coding I pasted, I only had one s in assassin, instead of two. Thank you for your help!
Sorry, you need to Log In to post a reply to this thread.