boro Posted July 30, 2013 Share Posted July 30, 2013 Hi all i have problem with my bonus script but it don't work i want give player bonus weapon but only for one player not for all players i don't know what is bad. function gibvebonus ( player, command ) if getElementByType ( players ) == 'player' then local bonus = math.random ( player ) giveWeapon ( player, 38, 9999 ) outputChatBox("* ".. getPlayerName(player) .." have bonus weapon") end end addCommandHandler ( "playerbonus", givebonus ) Link to comment
csiguusz Posted July 30, 2013 Share Posted July 30, 2013 Use getRandomPlayer to get a random player. And your code doesn't make much sense. Link to comment
boro Posted July 30, 2013 Author Share Posted July 30, 2013 Is it good? function gibvebonus ( player, command ) local randomPlayer = getRandomPlayer ( ) giveWeapon ( randomPlayer, 38, 9999 ) outputChatBox("* ".. getPlayerName(randomPlayer) .." have bonus weapon") end addCommandHandler ( "bonus", givebonus ) i won't t test it because am on phone ty. Link to comment
Baseplate Posted July 30, 2013 Share Posted July 30, 2013 And you have a little mistake, as the event handler is attached to a function which doesn't exist. Change the givebonus with gibvebonus. Link to comment
Sasu Posted July 30, 2013 Share Posted July 30, 2013 If you want to use in client side you can use: local player = getElementsByType("player") local randomPlayer = player[math.random(1, #player)] Link to comment
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