Ulysses
General => Developers Corner => Topic started by: fubar on June 07, 2018, 10:47:19 AM
-
local CATEGORY_NAME = "Hepful Commands"
function ulx.rights(ply)
ply:Say( "You have the right to remain silent, anything you say or do", teamOnly=false )
ply:Say( "Will be held against you in a court of law. Do you understant", teamOnly=false )
ply:Say( "these rights I have read to you? And do you wish to speak with me?", teamOnly=false )
end
local rights = ulx.command( "Police Commands", "ulx rights", ulx.rights, "!rights" )
rights:defaultAccess( ULib.ACCESS_ALL )
rights:help( "Gives rights" )
function ulx.raid(ply)
ply:Say( "/advert Prepare to be raided!", teamOnly=false )
end
local raid = ulx.command( CATEGORY_NAME, "ulx raid", ulx.raid, "!raid" )
raid:defaultAccess( ULib.ACCESS_ALL )
raid:help( "Gives raid" )
function ulx.carjack(ply)
ply:Say( "/advert Prepare to be carjacked!", teamOnly=false )
end
local carjack = ulx.command( CATEGORY_NAME, "ulx carjack", ulx.carjack, "!carjack" )
carjack:defaultAccess( ULib.ACCESS_ALL )
carjack:help( "Gives carjack" )
function ulx.kidnap(ply)
ply:Say( "/advert Prepare to be kidnaped!", teamOnly=false )
end
local kidnap = ulx.command( CATEGORY_NAME, "ulx kidnap", ulx.kidnap, "!kidnap" )
kidnap:defaultAccess( ULib.ACCESS_ALL )
kidnap:help( "Gives kidnap" )
None of them work
-
Are these running from server? "Say" is a server side command.
You should be getting lua errors at startup of server attempting to load the file, or when running the commands.
They will be helpful in telling you why they aren't working.
-
No lua errors :I
-
I see what you did
you have entity as "ply" you need it as "calling_ply"
-
No lua errors :I
Where did you place your Lua file? I ran your code and received the following error:
[ERROR] addons/ulx-test/lua/ulx/modules/sh/fubar.lua:3: ')' expected near '='
1. unknown - addons/ulx-test/lua/ulx/modules/sh/fubar.lua:0
I see what you did
you have entity as "ply" you need it as "calling_ply"
While it might be a good idea to stick to conventions, the parameter passing mechanism in Lua is positional. The first parameter in a ULX command callback will always be the player that called the command. The name of the parameter doesn’t influence this.
-
yes I am getting that same error
addons/custom/lua/ulx/modules/sh/u_custom.lua
-
The function signature for Player:Say:
Player:Say( string text, boolean teamOnly=false )
When a parameter is followed by an equal sign and a value (e.g. "teamOnly=false"), that value is regarded as the default value. As a result, the second parameter in Player:Say defaults to false.
If you don’t want to send the message in team chat, you can write:
ply:Say( "We were bested. So be it.", false )
or
ply:Say( "We were bested. So be it." )
If you do want to send the message in team chat, you must set the second parameter to true:
ply:Say( "We were bested. So be it.", true )
The following is invalid:
ply:Say( "We were bested. So be it.", teamOnly=false ) -- invalid