boro Posted July 30, 2013 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 )
csiguusz Posted July 30, 2013 Posted July 30, 2013 Use getRandomPlayer to get a random player. And your code doesn't make much sense.
boro Posted July 30, 2013 Author 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.
Baseplate Posted July 30, 2013 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.
Sasu Posted July 30, 2013 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)]
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