Adding a ulx csay in a gamemode
We currently use PrintMessage in our script but we wish to switch it over to ulx csay and was wondering if anyone had some advice on how to we would be able to do that.
This is the current function we have and we've tried putting "ulx.csay(calling_ply, "Zombie event has ended!")" while having the function StartingTimer( calling_ply )
which we saw in another addon that has ulx csay in it but we get an error of
"[ULX] lua/ulx/modules/sh/chat.lua:61: attempt to index local 'calling_ply' (a nil value)
1. csay - lua/ulx/modules/sh/chat.lua:61
2. unknown - gamemodes/fattishkid/gamemode/init.lua:91"
This is our script we are trying to add ulx csay in
function StartingTimer()
timer.Create( "TryingStart", 15, 1,
function() print( "Starting fatkid game" )
PrintMessage( HUD_PRINTTALK,("Starting fattish Kid game."))
if player.GetCount() >= 2 then
StartFatKid()
else
--ulx.csay(calling_ply, "2 players required before game can start.")
print( "2 players required before game can start." )
PrintMessage( HUD_PRINTTALK,("2 players required before game can start."))
StartingTimer()--end event must start createsometimers -- changed from CreateSomeTimers to StartingTimer
end
end )
end
Is 'calling_ply' defined anywhere?
this is the csay function from ulx code
as Bronson said, calling_ply is a required field for the function
However, looking at the function, it's only to check if it's a player for putting the player name into the logging, so you should be able to get away with changing calling_ply for "Console" in your code like so:
ulx.csay("Console", "2 players required before game can start.")
technically you could put any string you like in, as it will check to see if it's a valid player (which it wont be) and subbing "Console" in anyway
Moved to Lua Help