Ulysses
General => Developers Corner => Topic started by: kulcris on September 29, 2014, 03:06:40 PM
-
I'm currently coding some RTD results and I'm trying to call a command (that i added to ulx) from this other file. how would i go about calling .... For example the ulx.slap function without running a console command. and if that is not possible then how would i call the console command and use it on a player?
(sorry nub at coding)
RESULT.Name = "run"
run2b = math.random(.5,2)
runtime = math.random(15,60)
function RESULT:Trigger(ply)
ulx.sprintspeed(ply,run2b*240)
ulx.walkspeed(ply,run2b*220)
timer.Simple(runtime, function()
if (ply and ply:IsValid()) then
ulx.sprintspeed(ply,240)
ulx.walkspeed(ply,220)
ply:ChatPrint("Returned to normal speed.")
RTD:SendColoredChatMessage(ply, "Has returned to their normal speed.")
end
end)
end
function RESULT:ShowMessage(ply)
RTD:BroadcastMessageAboutPlayer(ply, "has been sped up / slowed down by", Color(0, 255, 0), run2b, color_white, " for ", Color(0, 255, 0), runtime, color_white," Seconds ", Color(0, 255, 0))
end
-
RESULT.Name = "run"
run2b = math.random(2,10)
runtime = math.random(15,60)
function RESULT:Trigger(ply)
local plyname = ply:GetName( )
RunConsoleCommand("ulx", "sprintspeed", plyname, run2b*240)
RunConsoleCommand("ulx", "walkspeed", plyname, run2b*220)
timer.Simple(runtime, function()
if (ply and ply:IsValid()) then
RunConsoleCommand("ulx", "sprintspeed", plyname, 240)
RunConsoleCommand("ulx", "walkspeed", plyname, 220)
ply:ChatPrint("Returned to normal speed.")
RTD:SendColoredChatMessage(ply, "Has returned to their normal speed.")
end
end)
end
function RESULT:ShowMessage(ply)
RTD:BroadcastMessageAboutPlayer(ply, "has been sped up / slowed down by", Color(0, 255, 0), run2b, color_white, " for ", Color(0, 255, 0), runtime, color_white," Seconds ", Color(0, 255, 0))
end
This seems to have worked the way i would like it to.
-
run2b = math.random(2,10)
runtime = math.random(15,60)
I moved this into the trigger function so that it runs everytime it is triggered instead of just once the entire up time of the server
-
Not sure if this really answers what your asking but you could just use ulib functions instead of running ulx commands.
Heres the ulib Doc (http://ulyssesmod.net/docs/files/lua/ulib/server/player-lua.html#slap) on slap seen as that is the example you used
and here (http://ulyssesmod.net/docs/files/ULib_readme-txt.html) is the full docs
edit: just read your code and i dont think this will really help you at all, sorry.
-
You might be able to access a reference to the function by checking the ULib.cmds.translatedCmds["ulx slap"] table- I'm pretty sure you can find one there.
-
Sorry for the super late responses sometimes i get something in my head and then forget about it before i can get home and fully tinker with it XD Thank you for responding guys.
As for getting this to work i just needed to run the commands. it may be a bit messy but it seems to have worked