Pivity

Adding a ulx csay in a gamemode

Last read Never
#1

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

#2

Is 'calling_ply' defined anywhere?

#3

this is the csay function from ulx code

function ulx.csay( calling_ply, message )
ULib.csay( _, message )

if ULib.toBool( GetConVarNumber( "ulx_logChat" ) ) then
ulx.logString( string.format( "(csay from %s) %s", calling_ply:IsValid() and calling_ply:Nick() or "Console", message ) )
end
end
local csay = ulx.command( CATEGORY_NAME, "ulx csay", ulx.csay, "@@@", true, true )
csay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
csay:defaultAccess( ULib.ACCESS_ADMIN )
csay:help( "Send a message to everyone in the middle of their screen." )

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.")

#4

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

#5

Moved to Lua Help

Users viewing this thread
Nobody