I'm trying to add a new feature on my server, but I'm getting an error and I don't know how to fix it. Anyone can help me?
Error:
[ERROR] lua/includes/extensions/player.lua:75: bad argument #1 to 'upper' (string expected, got nil)
1. upper - [C]:-1
2. GetBySteamID - lua/includes/extensions/player.lua:75
3. ShowSearch - gamemodes/terrortown/gamemode/corpse.lua:211
4. UseOverride - addons/ttt_decaying_corpses/lua/autorun/server/sv_ttt_decay.lua:34
5. unknown - gamemodes/terrortown/gamemode/player.lua:393
Code:
CreateConVar("ttt_decay_time",240,bit.bor(FCVAR_NOTIFY,FCVAR_ARCHIVE),"How many seconds a body must be unidentified before decaying.")
CreateConVar("ttt_decay_skeleton_time",200,bit.bor(FCVAR_NOTIFY,FCVAR_ARCHIVE),"How many additional seconds a decayed body must be unidentified before turning into a skeleton.")
timer.Create("TTT_Decay_Timer", 4, 0, function()
local st = GetConVar("ttt_decay_time"):GetInt();
local stt = st + GetConVar("ttt_decay_skeleton_time"):GetInt();
for k,v in pairs(ents.FindByClass("prop_ragdoll")) do
if (v.player_ragdoll) then
if (v.ttt_decay and v.ttt_decay >= st) and !CORPSE.GetFound(v) then
v:EmitSound("ambient/creatures/flies" .. math.random(1,5) .. ".wav",60,95);
if not v.ttt_decay_rotten or (not v.ttt_decay_skeleton and v.ttt_decay > stt and stt != st) then
local rag = ents.Create("prop_ragdoll")
rag:SetModel(v.ttt_decay_rotten and "models/player/skeleton.mdl" or "models/player/charple.mdl");
rag:SetPos(v:GetPos())
rag:SetAngles(v:GetAngles())
rag:Spawn()
rag:SetCollisionGroup(COLLISION_GROUP_WEAPON);
if (v.ttt_decay_rotten) then rag.ttt_decay_skeleton = true end
rag:SetSkin(2);
rag.was_role = v.was_role;
rag.bomb_wire = v.bomb_wire
rag.dtime = v.dtime;
rag.uqid = v.uqid;
rag.kills = {}
if IsValid(player.GetByUniqueID(rag.uqid)) then
CORPSE.SetPlayerNick(rag, player.GetByUniqueID(rag.uqid));
end
rag.CanUseKey = true;
function rag:UseOverride(ply)
if (ply:IsDetective()) then
CORPSE.ShowSearch(ply, self, (ply:KeyDown(IN_WALK) or ply:KeyDownLast(IN_WALK)))
else
ply:SendLua("local ply = LocalPlayer() ply:EmitSound('plats/platstop1.wav', 100, 90) chat.AddText( Color( 255,220, 0 ), 'This body has rotted so much that the victim can be identified only by a detective.' )");
end
end
rag.ttt_decay_rotten = true;
rag.ttt_decay = v.ttt_decay;
rag.player_ragdoll = true;
-- position the bones
local num = rag:GetPhysicsObjectCount()-1
local ve = v:GetVelocity()
for i=0, num do
local bone = rag:GetPhysicsObjectNum(i)
if IsValid(bone) then
local bp, ba = v:GetBonePosition(rag:TranslatePhysBoneToBone(i))
if bp and ba then
bone:SetPos(bp)
bone:SetAngles(ba)
end
end
end
rag:Fire("disablemotion");
rag:Fire("enablemotion","",1);
v:Remove();
end
end
v.ttt_decay = (v.ttt_decay or 0) + 4
end
end
end);
Thanks in advance for any answers
Nothing?
Replace self with rag on the ShowSearch call
It's not my code, it was abandoned on Workshop and I'm trying to fix it. I'll try this, dubb
Ah I miss overlooked that rag was something you're creating, it looks like it's missing a few parameters from corpse.lua, you could add rag.sid = v.sid somewhere before the useoverride, and then you can change it back to self in the ShowSearch call.
You probably shouldn't use the code as it seems to be outdated with the current TTT, it shouldn't be too hard to recreate the addon while using the proper hooks.
Hmm, recreate the code entirely?
Sorry, you need to Log In to post a reply to this thread.