• NPC Kill pay system revised
    9 replies, posted
Hey people of Facepunch. I betcha all know of the NPC pay pr. kill system in the DarkRP. But if you're asking me, it's a bit lame way to do it. So instead of granting the player magically the chosen amount of money, would there be a way to have the money drop on the ground instead? & Maybe make it happen randomly, like one drop between every 1 and 5 kills or something?
You could find the dropmoneyondeath hook and use it on OnNPCKilled, then use math.random 1, 5.
Your suggestion didn't work, and console isn't coming up with any errors, so I can't even tell if it's reading the code. Any suggestions?
[lua] function GM:OnNPCKilled(victim, ent, weapon) local kills = math.random(1, 5) if ValidEntity(ent) then if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end if kills <= 3 then CreateMoneyBag(victim:GetPos() + Vector(0,0,64), math.random(10,20)) end end for k,v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE,victim:GetClass() .. " was killed by " .. ent:GetName().. " with a " .. weapon:GetClass() .. ".\n" ) end end end [/lua] Not sure if this is what you're looking for.
[QUOTE=brandonj4;36172215][lua] function GM:OnNPCKilled(victim, ent, weapon) local kills = math.random(1, 5) if ValidEntity(ent) then if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end if kills <= 3 then CreateMoneyBag(victim:GetPos() + Vector(0,0,64), math.random(10,20)) end end for k,v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE,victim:GetClass() .. " was killed by " .. ent:GetName().. " with a " .. weapon:GetClass() .. ".\n" ) end end end [/lua] Not sure if this is what you're looking for.[/QUOTE] Either that didn't work, or I'm doing it wrong.. I just replaced the original code with your code, yet it still didn't work, am I doing something wrong?
[QUOTE=Baf;36172504]Either that didn't work, or I'm doing it wrong.. I just replaced the original code with your code, yet it still didn't work, am I doing something wrong?[/QUOTE] [lua] function GM:OnNPCKilled(victim, ent, weapon) local kills = math.random(1, 5) if ValidEntity(ent) then if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end if kills <= 3 then DarkRPCreateMoneyBag(victim:GetPos() + Vector(0,0,64), math.random(10,20))--woops end end for k,v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE,victim:GetClass() .. " was killed by " .. ent:GetName().. " with a " .. weapon:GetClass() .. ".\n" ) end end end [/lua] Wrong name.. use that instead.
[QUOTE=brandonj4;36173618][lua] function GM:OnNPCKilled(victim, ent, weapon) local kills = math.random(1, 5) if ValidEntity(ent) then if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end if kills <= 3 then DarkRPCreateMoneyBag(victim:GetPos() + Vector(0,0,64), math.random(10,20))--woops end end for k,v in pairs(player.GetAll()) do if v:IsAdmin() then v:PrintMessage(HUD_PRINTCONSOLE,victim:GetClass() .. " was killed by " .. ent:GetName().. " with a " .. weapon:GetClass() .. ".\n" ) end end end [/lua] Wrong name.. use that instead.[/QUOTE] Thanks but the math.random part doesn't work. It still drops on every kill Isn't it supposed to be "local kills = math.random(1,5)" Instead of "local kills = math.random(1, 5)"?
[QUOTE=Baf;36180466]Thanks but the math.random part doesn't work. It still drops on every kill Isn't it supposed to be "local kills = math.random(1,5)" Instead of "local kills = math.random(1, 5)"?[/QUOTE] It doesn't matter if there's a space after the comma. You can debug it if you want and put in: [lua] if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end print(kills)--Debug if kills <= 3 then [/lua] Since you say it keeps constantly dropping do: [lua] local kills = math.random(1, 2) if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end if kills == 2 then-- or 1 do w/e [/lua]
[QUOTE=brandonj4;36183329]It doesn't matter if there's a space after the comma. You can debug it if you want and put in: [lua] if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end print(kills)--Debug if kills <= 3 then [/lua] Since you say it keeps constantly dropping do: [lua] local kills = math.random(1, 2) if ent:IsVehicle() and ent:GetDriver():IsPlayer() then ent = ent:GetDriver() end if kills == 2 then-- or 1 do w/e [/lua][/QUOTE] Mkay, but removing the space after comma fixed my problem. Thanks for your help, it's all working now :)
[QUOTE=Baf;36183741]Mkay, but removing the space after comma fixed my problem. Thanks for your help, it's all working now :)[/QUOTE] No problem but the space really doesn't matter.
Sorry, you need to Log In to post a reply to this thread.