Pivity

How to fix a lil error

Last read Never
#1

trying to make a simple script... But it is breaking /advert TheTerrorist = { TEAM_DJ }

hook.Add( "PlayerSay", "TerrorStart", function( ply, text, public ) text = string.lower( text ) if ( text == "!terror" ) and ply:IsPlayer() and table.HasValue( TheTerrorist, ply:Team() ) then ply:Say( "/advert test", teamOnly==false ) else return false end

end )

error ----- [DarkRP] gamemodes/darkrp/entities/entities/darkrp_billboard/init.lua:50: attempt to compare nil with number

  1. callback - gamemodes/darkrp/entities/entities/darkrp_billboard/init.lua:50
  2. callback - addons/darkrp/gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:17 3. RP_PlayerChat - addons/darkrp/gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:78 4. unknown - addons/darkrp/gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:142 5. Say - [C]:-1 6. v - addons/terror mod/lua/autorun/server/shared.lua:6 7. unknown - addons/darkrp/gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:138
#2

You're refering to a empty variable ofc? You can't refer to a variable you're creating

#3

Replace ply:Say( "/advert test", teamOnly==false ) with ply:Say( "/advert test", false )

I think that should work.

EDIT:

And remove that 'else return false'

#4
ByBenn20002at 4th of July 2016 15:13:20
Replaceply:Say( "/advert test", teamOnly==false )withply:Say( "/advert test", false )I think that should work.

no it wont

#5

TheTerrorist = { 1 }

hook.Add( "PlayerSay", "TerrorStart", function( ply, text, public ) text = string.lower( text ) if ( text == "!terror" ) and ply:IsPlayer() and table.HasValue( TheTerrorist, ply:Team() ) then ply:Say( "/advert test", false ) end end )

Thats working for me..

#6

TheTerrorist = { TEAM_DJ }

hook.Add( "PlayerSay", "TerrorStart", function( ply, text )

if string.lower( text ) == "!terror" and table.HasValue( TheTerrorist, ply:Team() ) then

ply:Say( "/advert test", false )

end

end )

-- Same error. What variable am i not refering too?

#7

You're creating 'text' while you refering to 'text' making it a nil as your variable is nil and when you try and reference to that it simply will stay nil.

Disagree x 1
#8

why does this work then?

hook.Add("PlayerSay" , "OpenTextCommand" , function(ply , text)

if string.lower(text) == "!unbox" or string.lower(text) == "/unbox" then

ply:ub_update_client()

net.Start("ub_openui")
net.Send(ply)

end

if string.lower(text) == "!unboxadmin" or string.lower(text) == "/unbox" then
net.Start("unboxadmin")
net.Send(ply)

end

end)

#9

You're on the update that's trying to create the billboard, which might have different arguments. The error that is occurring is happening in the actual billboard file itself.

#10
ByHandsome Patrickat 4th of July 2016 16:37:25
why does this work then?hook.Add("PlayerSay" , "OpenTextCommand" , function(ply , text)if string.lower(text) == "!unbox" or string.lower(text) == "/unbox" thenply:ub_update_client()net.Start("ub_openui")net.Send(ply)endif string.lower(text) == "!unboxadmin" or string.lower(text) == "/unbox" thennet.Start("unboxadmin")net.Send(ply)endend)

Because he's never overwriting the actual text argument, he's just using it?

#11
ByPatat 4th of July 2016 17:38:02
Because he's never overwriting the actual text argument, he's just using it?

The hook already gives him the "text" argument.

Edited It might be a bit of an odd suggestion, but you could change ply:Say( "/advert test", teamOnly==false ) to ply:ConCommand("Say","/advert","test"). Why? Because ply:Say() also seems to work on bots, this gives me the feeling it bypasses some of the other functions. Ply:CoCommand("Say","test") runs like if you would type something in your client console. It's just a suggestion, I don't know if it fixes the problem, but you might wanna give it a go.

Users viewing this thread
Nobody