xScatta Posted September 14, 2013 Posted September 14, 2013 Hey code here problem below: names = {"James","John","Johnny","Cesar"} subnames = {"Rodriguez","Johnshon","Thomson","Black"} function nick() players = getElementsByType("player") setPlayerNametagText(players,math.random(names).."_"..math.random(subnames)) end addCommandHandler("rpnick",nick) i want to script random the names and subnames for every player but idk how to use ipairs
nic062 Posted September 14, 2013 Posted September 14, 2013 local names = {"James","John","Johnny","Cesar"} local subnames = {"Rodriguez","Johnshon","Thomson","Black"} function nick() local players = getElementsByType("player") local nbrNames = table.getn(names) local nbrSubnames = table.getn(subnames) for i, player in pairs(players) do setPlayerNametagText(player, ""..names[math.random(nbrNames)].."_"..subnames[math.random(nbrSubnames)].."") end end addCommandHandler("rpnick",nick) Tested, if you want allow the command only for admin : local names = {"James","John","Johnny","Cesar"} local subnames = {"Rodriguez","Johnshon","Thomson","Black"} function nick(thePlayer) local accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user."..accountname, aclGetGroup("Admin")) then local players = getElementsByType("player") local nbrNames = table.getn(names) local nbrSubnames = table.getn(subnames) for i, player in pairs(players) do setPlayerNametagText(player, ""..names[math.random(nbrNames)].."_"..subnames[math.random(nbrSubnames)].."") end end end addCommandHandler("rpnick",nick) Enjoy
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now