Hello everyone, I’m in need of help as I’m out of options!
I’ve been working on a Grim Reaper job for DarkRP, this job should function in a similar fashion as the hitman, biggest difference being he will always have a random target set. I’ve tried setting a variable to mark a random player for death, I’ve decided to use MySQL after trying everything else, and I’ve still had no luck. It sets the random player, but is not setting the “SetReap” Variable for that player, which means I cannot check if that player is worthy of being reaped upon their death.
I no longer get any errors, it’s simply not working any way that I try it. I get this might be extremely simple, and I might look like a complete idiot for not figuring it out myself, but I’ve run out of options.
local reapvar = 0
targettable = {}
concommand.Add("grimhunt2", function(ply)
r = table.Random(player.GetAll())
local setreap = tonumber(sql.QueryValue("SELECT Reaped FROM Players WHERE SteamID=\""..r:SteamID().."\""))
usermessage.Hook( "MyUsermessage", RecvMyUmsg );
Frame2 = vgui.Create( "DFrame" )
Frame2:SetPos( ScrW() / 2.2, 0 )
Frame2:SetSize( ScrW() / 6, ScrH() / 8 )
Frame2:SetTitle( " " )
Frame2:SetVisible( true )
Frame2:SetDraggable( false )
Frame2:ShowCloseButton( false)
t = CurTime() + 10
Frame2.Paint = function()
draw.DrawText( "TARGET:"..r:Name(), "DermaLarge", ScrW() / 50, ScrH() / 100, Color( 255, 55, 55, 255 ), TEXT_ALIGN_LEFT )
end
ply:ChatPrint("Test:"..r:Name())
ply:ChatPrint("Test:"..r:SteamID())
if setreap == 0 then
sql.Query("Update Players SET Reaped = 0 WHERE SteamID=\""..r:SteamID().."\"", function(data) end);
ply:ChatPrint("Success")
else
ply:ChatPrint("Failure")
end
concommand.Add("closegrim2", function()
Frame2:Close()
end)
end)
local function ReapComplete(victim, weapon, killer)
victimid = victim:SteamID();
local reaping = tonumber(sql.QueryValue("SELECT Reaped FROM Players WHERE SteamID=\""..victimid.."\""))
if reaping == 1 then
sql.Query("Update Players SET Reaped = 0 WHERE SteamID=\""..victimid.."\"", function(data) end);
killer:ChatPrint("Success")
else
killer:ChatPrint("Failure")
end
end
hook.Add("PlayerDeath", "PlayerReap", ReapComplete)
local function ReapCreation( client )
local steamID = client:SteamID();
local name = client:Name();
if not sql.TableExists("Players") then
sql.Query( "CREATE TABLE Players ( SteamID, Name, Reaped )" )
end
sql.Query("SELECT * FROM Players WHERE SteamID=\""..steamID.."\"", function(data)
if (!data or table.Count(data) == 0) then
sql.Query("INSERT INTO Players (SteamID, Name, Reaped) VALUES (\""..steamID.."\", \""..name.."\", 0 )", function(data)
end);
end;
end);
end
hook.Add("PlayerInitialSpawn", "ReapCreation", CreateReap)
If anybody can help me figure out why it’s not working I’d greatly appreciate it, using MySQL was not my first option and I’m more than willing to go back to the basics for this script.