• Need some help coding a new ulx command
    9 replies, posted
So I'm trying to code a button/command for my ulx menu that will turn a player/force a player to be traitor. I'm not a coder at all. My knowledge is next to nothing and this is probably completely wrong. But I based it off other code from ulx but when I added it, I got "too many lua errors" if anyone tried to join. Here's what I've come up with (don't make too much fun): function ulx.traitor( calling_ply, target_plys ) for _,v in pairs( target_plys ) do v:SetRole(ROLE_TRAITOR) end local strip = ulx.command( "TTT", "ulx traitor", ulx.traitor, "!traitor" ) strip:addParam{ type=ULib.cmds.PlayersArg } strip:defaultAccess( ULib.ACCESS_ADMIN ) strip:help( "Change traitor target(s)." ) Anyway, any help is appreciated and if you give me an entire new code that's perfectly fine too haha.
just copy and paste one of the other commands and change it around.
You left out a closing "end" for the for loop. Also you've copied parts of the strip command and didn't change the variable, so one is going to override the other...
You're constant use of "strip" might be causing a problem.. Here is a script a friend of mine , (Juze), made quite a while ago. [CODE]function ulx.traitor( calling_ply, target_plys ) for _,v in pairs(target_plys) do v:SetRole(ROLE_TRAITOR) SendFullStateUpdate() end ulx.fancyLogAdmin( calling_ply, "#A made #T a traitor", target_plys ) end[/CODE]
Ive been looking for something like this, but i dont know where to put it.
[QUOTE=gaz492;38408371]Ive been looking for something like this, but i dont know where to put it.[/QUOTE] Don't know where to put what exactly? Be more specific.
[QUOTE=StpdKlown;38414429]Don't know where to put what exactly? Be more specific.[/QUOTE] where do i put the code, what file.
[QUOTE=gaz492;38415316]where do i put the code, what file.[/QUOTE] I'm pretty sure in your server's addon folder where ULX exists.. look in the files to see which one has all the commands and just stick it in there. If that doesn't work tell me and I'll look into it.
dir/addons/ulx/lua/ulx/modules/sh/[anynameuwant].lua [lua] local CATEGORY_NAME = "TTT" function ulx.cc_traitor( ply, targs ) for _, v in ipairs( targs ) do v:SetRole(ROLE_TRAITOR) end SendFullStateUpdate() ulx.fancyLogAdmin( ply, true, "#A turned #T into a traitor", targs ) end local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.cc_traitor, "!traitor", true ) traitor:addParam{type=ULib.cmds.PlayersArg, hint = "<user(s)>"} traitor:defaultAccess( ULib.ACCESS_SUPERADMIN ) traitor:help( "Turns target(s) into a traitor." ) [/lua] first time on face punch i acctually helped ssomeone instead of asked for help, (woot) also my birthday :3
[QUOTE=Declivity;38420669]dir/addons/ulx/lua/ulx/modules/sh/[anynameuwant].lua [lua] local CATEGORY_NAME = "TTT" function ulx.cc_traitor( ply, targs ) for _, v in ipairs( targs ) do v:SetRole(ROLE_TRAITOR) end SendFullStateUpdate() ulx.fancyLogAdmin( ply, true, "#A turned #T into a traitor", targs ) end local traitor = ulx.command( CATEGORY_NAME, "ulx traitor", ulx.cc_traitor, "!traitor", true ) traitor:addParam{type=ULib.cmds.PlayersArg, hint = "<user(s)>"} traitor:defaultAccess( ULib.ACCESS_SUPERADMIN ) traitor:help( "Turns target(s) into a traitor." ) [/lua] first time on face punch i acctually helped ssomeone instead of asked for help, (woot) also my birthday :3[/QUOTE] Thanks and happy brithday
Sorry, you need to Log In to post a reply to this thread.