Login to ZARP
Username: Password: Remember me

TOPIC: LUA help pl0x

LUA help pl0x 5 years 6 months ago #1035165

Right so I'm working on a crude version of the health/armour chargers but I'm having a bit of bother with implementing an interval timer so the client isn't spammed with a notification every frame while using the charger.

I have a base entity that creates the network variables in the standard ENT:SetupDataTables function, here is the majority of my code from the shared.lua file for the base entity:
Warning: Spoiler! [ Click to expand ]


Here is my init.lua for my base entity, where I set the NotificationInterval value on initialise:
Warning: Spoiler! [ Click to expand ]


I have then created a health charger entity that inherits from the base entity briefly described above. In my ENT:Use function below, you can see me calling the base ENT:NotifyClient function I've written when the player's health is full:
function ENT:Use(activator, caller)

    if not IsValid(caller) or not caller:IsPlayer() then return end

    local plyCurrentHealth = caller:Health()

    if plyCurrentHealth >= 100 then BaseClass:NotifyClient(caller, "You are already at full health!", 4, "Error") end

end

So if you refer back to my shared.lua file for my base entity (first spoiler), and look within the NotifyClient function, I call another function by the name of CanSendNotification where I check to see if the interval has been passed. However, I get the following error when I press my use key on the entity in-game:
[ERROR] lua/entities/base_charger/init.lua:30: attempt to call method 'GetNotificationInterval' (a nil value)
  1. CanSendNotification - lua/entities/base_charger/init.lua:30
   2. NotifyClient - lua/entities/base_charger/shared.lua:18
    3. unknown - lua/entities/health_charger/init.lua:23

I feel like this is gonna be a really silly mistake considering it's taken me this long and I still haven't found what I've done wrong. Any help would be appreciated, and yes, I know my scripts are shite pls no hate.
  • .uzi
  • .uzi's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP Golden Blue Badge
  • Foos yer doos?
  • Posts: 6005
  • Thanks received: 2441
  • Karma: 123
Login or register to post a reply.

LUA help pl0x 5 years 6 months ago #1035230

if plyCurrentHealth >= 100 then BaseClass:NotifyClient(caller, "You are already at full health!", 4, "Error") end

I think you mean "self" not "BaseClass"
  • DEADMONSTOR
  • DEADMONSTOR's Avatar
  • Offline
  • Former Owner
  • ZARP VIP
  • Posts: 9276
  • Thanks received: 3799
  • Karma: 80
...
Login or register to post a reply.
The following user(s) said Thank You: .uzi

LUA help pl0x 5 years 6 months ago #1035231

DEADMONSTOR wrote:
if plyCurrentHealth >= 100 then BaseClass:NotifyClient(caller, "You are already at full health!", 4, "Error") end

I think you mean "self" not "BaseClass"

Yeah you're right, boy am I fuckin stupid

just updated the code and works properly now, ty dead
  • .uzi
  • .uzi's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP Golden Blue Badge
  • Foos yer doos?
  • Posts: 6005
  • Thanks received: 2441
  • Karma: 123
Login or register to post a reply.

LUA help pl0x 5 years 6 months ago #1035232

Sorry I couldn't get to this sooner men!
  • Nafe
  • Nafe's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP Golden Blue Badge
  • Posts: 18589
  • Thanks received: 8585
  • Karma: -377
Login or register to post a reply.
Time to create page: 0.082 seconds

274 PLAYERS ONLINE

Connect to server View Gametracker DarkRP 1
19/127
online
Connect to server View Gametracker Deathrun
0/40
online
Connect to server View Gametracker TTT
0/47
online
Connect to server View Gametracker Bhop
2/32
online
Connect to server View Gametracker Surf
7/32
online
Connect to server View Gametracker Prop Hunt
0/42
online
Connect to server View Gametracker Sandbox
0/42
online
Connect to server Discord
246/788
online
Top