So, I am trying to integrate PointMod([url]http://www.facepunch.com/showthread.php?933261-PointMod-Earn-points-and-buy-items-with-them[/url]!) to a DarkRP server, and am trying to make a money printer kind of entity which will periodically give you points if you have one, I know i can use the ply:GivePoints() function in PointMod to accomplish this, but it didn't work.. so far I got this:
[lua]
-- Respect Generator reworked for DarkRP by gomedunAddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_c17/consolebox01a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
self.sparking = false
self.damage = 100
self.IsRespectGenerator = true
timer.Simple(30, self.CreateMoneybag, self)
end
function ENT:OnTakeDamage(dmg)
if self.burningup then return end
self.damage = (self.damage or 100) - dmg:GetDamage()
if self.damage <= 0 then
local rnd = math.random(1, 10)
if rnd < 3 then
self:BurstIntoFlames()
else
self:Destruct()
self:Remove()
end
end
end
function ENT:Destruct()
local vPoint = self:GetPos()
local effectdata = EffectData()
effectdata:SetStart(vPoint)
effectdata:SetOrigin(vPoint)
effectdata:SetScale(1)
util.Effect("Explosion", effectdata)
Notify(self.dt.owning_ent, 1, 4, "Your respect generator has exploded!")
end
function ENT:BurstIntoFlames()
Notify(self.dt.owning_ent, 1, 4, "Your respect generator is overheating!")
self.burningup = true
local burntime = math.random(8, 18)
self:Ignite(burntime, 0)
timer.Simple(burntime, self.Fireball, self)
end
function ENT:Fireball()
if not self:IsOnFire() then return end
local dist = math.random(20, 280) -- Explosion radius
self:Destruct()
for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
if not v:IsPlayer() and not v.IsMoneyPrinter then v:Ignite(math.random(5, 22), 0) end
end
self:Remove()
end
local function PrintMore(ent)
if ValidEntity(ent) then
ent.sparking = true
timer.Simple(3, ent.CreateMoneybag, ent)
end
end
function ENT:GenRespect()
if not ValidEntity(self) then return end
if self:IsOnFire() then return end
local MoneyPos = self:GetPos()
if math.random(1, 22) == 3 then self:BurstIntoFlames() end
local PointsToGive = GetConVarNumber("rgenamount")
timer.Create( "GivePoints", 300, 0, function()
for k, v in ipairs( player.GetAll() ) do
v:GivePoints( PointsToGive )
end
end )
self.sparking = false
end
function ENT:Think()
if not self.sparking then return end
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(1)
effectdata:SetScale(1)
effectdata:SetRadius(2)
util.Effect("Sparks", effectdata)
end
[/lua] as my init, can somebody help me? (the rgenamount has been added)
what didnt work, any errors? (post errors if there are any)
well it doesn't give me points
-snip-
bump
go into your console, and post the errors
Fail you guys are blind lol
[lua]
-- Respect Generator reworked for DarkRP by gomedun
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
local PointsToGive = 20
function ENT:Initialize()
self:SetModel("models/props_c17/consolebox01a.mdl")
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
local phys = self:GetPhysicsObject()
if phys:IsValid() then phys:Wake() end
self.sparking = false
self.damage = 100
timer.Simple(30, self.GenRespect, self)
end
function ENT:OnTakeDamage(dmg)
if self.burningup then return end
self.damage = (self.damage or 100) - dmg:GetDamage()
if self.damage <= 0 then
local rnd = math.random(1, 10)
if rnd < 3 then
self:BurstIntoFlames()
else
self:Destruct()
self:Remove()
end
end
end
function ENT:Destruct()
local vPoint = self:GetPos()
local effectdata = EffectData()
effectdata:SetStart(vPoint)
effectdata:SetOrigin(vPoint)
effectdata:SetScale(1)
util.Effect("Explosion", effectdata)
Notify(self.dt.owning_ent, 1, 4, "Your respect generator has exploded!")
end
function ENT:BurstIntoFlames()
Notify(self.dt.owning_ent, 1, 4, "Your respect generator is overheating!")
self.burningup = true
local burntime = math.random(8, 18)
self:Ignite(burntime, 0)
timer.Simple(burntime, self.Fireball, self)
end
function ENT:Fireball()
if not self:IsOnFire() then return end
local dist = math.random(20, 280) -- Explosion radius
self:Destruct()
for k, v in pairs(ents.FindInSphere(self:GetPos(), dist)) do
if not v:IsPlayer() then v:Ignite(math.random(5, 22), 0) end
end
self:Remove()
end
local function PrintMore(ent)
if ValidEntity(ent) then
ent.sparking = true
timer.Simple(3, ent.GenRespect, ent)
end
end
function ENT:GenRespect()
if not ValidEntity(self) then return end
if self:IsOnFire() then return end
if math.random(1, 22) == 3 then self:BurstIntoFlames() end
ply:GivePoints( PointsToGive )
self.sparking = false
end
function ENT:Think()
if not self.sparking then return end
local effectdata = EffectData()
effectdata:SetOrigin(self:GetPos())
effectdata:SetMagnitude(1)
effectdata:SetScale(1)
effectdata:SetRadius(2)
util.Effect("Sparks", effectdata)
end
[/lua]
P.s
I can tell you i did something like that but it's not ply:GivePoints (You did v -_- [means give all players]) i did points bag and points printer something awesome ^_^
[QUOTE=gomedun;25491973]stuff[/QUOTE]
It doesn't have to go in to the entities, put this in gamemode/init.lua
[lua]
CreateClientConVar("rgenamount", 30, false, false)
local PointsToGive = GetConVarNumber("rgenamount")
timer.Create("GivePoints", 30, 0, function()
for _,ent in pairs(ents.GetAll()) do
for _,v in pairs(player.GetAll()) do
if ent:GetClass() == "ent_generator" then
v:GivePoints( PointsToGive )
end
end
end
end)
[/lua]
cubar, more help? this checks for the generator enitty right? what should the ent_generator code be?
It's needs to be the entity's name in entities/entities
ok.
[editline]22nd October 2010[/editline]
It works, but everyone gets points rather then just the owner..
[editline]22nd October 2010[/editline]
bump
Try with and [lua]if ent:GetClass() == "ent_generator" and v:GetOwner() then [/lua]
now it won't give no points at all
Scrap that then just do
[lua]timer.Create("GivePoints", 30, 0, function()
..code.. self.Owner:GivePoints( PointsToGive )
end
[/lua]
In the entity
Sorry, you need to Log In to post a reply to this thread.