gokalpfirat Posted June 17, 2011 Share Posted June 17, 2011 function taskagitmakas ( player, command, tkm ) local rand = math.random(0,2) local playing = nil if tkm == rock then local playing = rock elseif tkm == paper then local playing = paper elseif tkm == scissors then local playing = scissors end if rand == 0 and tkm == rock then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." has played#00cc00"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock !" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == scissors then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player) ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == paper then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == rock then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == scissors then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 1 and tkm == paper then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == rock then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 2 and tkm == scissors then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == paper then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..oynanan.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end end addCommandHandler ( "tkm", taskagitmakas ) I have got a lot of errors when i debug it. Like line 14 and line 33. Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 where is 'oynanan' defined and post the errors Link to comment
gokalpfirat Posted June 17, 2011 Author Share Posted June 17, 2011 line 14 local oynanan (nil value) line 33 local oynanan (nil value) Link to comment
JR10 Posted June 17, 2011 Share Posted June 17, 2011 Exactly, oynanan is not defined. Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 # function taskagitmakas ( player, command, tkm ) local rand = math.random(0,2) local playing = nil if tkm == rock then local playing = rock elseif tkm == paper then local playing = paper elseif tkm == scissors then local playing = scissors end if rand == 0 and tkm == rock then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." has played#00cc00"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock !" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == scissors then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player) ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == paper then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == rock then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == scissors then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 1 and tkm == paper then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == rock then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 2 and tkm == scissors then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == paper then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end end addCommandHandler ( "tkm", taskagitmakas ) Look at now gives error at line 14 and 33 Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 Line 14 local playing (nil value) and when i say /tkm tas it doesnt works Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 here u defined playing as nil local playing = nil and it wont change because your if is wrong if tkm == rock then local playing = rock elseif tkm == paper then local playing = paper elseif tkm == scissors then local playing = scissors end when a player types something its a string so it should be if tkm == 'rock' then local playing = 'rock' elseif tkm == 'paper' then local playing = 'paper' elseif tkm == 'scissors' then local playing = 'scissors' end Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 Now no errors but when im saying /tkm rock it doesnt works why? Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 (edited) Now no errors but when im saying "/tkm rock" it doesnt works why? Sorry for flooding im press quate not modify sorry. Edited June 18, 2011 by Guest Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 Dude why did you double post and the same message function taskagitmakas ( player, command, tkm ) local rand = math.random(0,2) local playing = nil if tkm == 'rock' then local playing = 'rock' elseif tkm == 'paper' then local playing = 'paper' elseif tkm == 'scissors' then local playing = 'scissors' end if rand == 0 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." has played#00cc00"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock !" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player) ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end end addCommandHandler ( "tkm", taskagitmakas ) Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 Now only says outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 local rand = math.random(0,2) local playing = nil if tkm == 'rock' then playing = 'rock' elseif tkm == 'paper' then playing = 'paper' elseif tkm == 'scissors' then playing = 'scissors' end Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 It is working thnx bro. How can i use tkm command only once in a minute. Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 There are more than one way to do it maybe this function taskagitmakas ( player, command, tkm ) local rand = math.random(0,2) local playing = nil if tkm == 'rock' then local playing = 'rock' elseif tkm == 'paper' then local playing = 'paper' elseif tkm == 'scissors' then local playing = 'scissors' end if rand == 0 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." has played#00cc00"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock !" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player) ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played"..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end removeCommandHandler( "tkm", taskagitmakas ) setTimer(addCommandHandler, 60000, 1, taskagitmakas ) end addCommandHandler ( "tkm", taskagitmakas ) Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 İt works but i want like when you use tkm command then timer starts when you want to use command in timer it says "You can play only once time in a minute" Edit: Give error Bad argument@ "addCommandHandler" Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 Ok so you want the player to use it once then a 60 seconds timer start ok do this use setElementData --at the start of your command do this if getElementData(player, 'canPlay') then --the command code --at the end of the command setElementData(player, 'canPlay', false) setTimer(setElementData, 60000, 1, player, 'canPlay', true) Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 function taskagitmakas ( player, command, tkm ) local rand = math.random(0,2) local playing = nil if tkm == 'rock' then playing = 'rock' elseif tkm == 'paper' then playing = 'paper' elseif tkm == 'scissors' then playing = 'scissors' end if getElementData(player, 'canPlay') then if rand == 0 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock !" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player) ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end end setElementData(player, 'canPlay', false) setTimer(setElementData, 60000, 1, player, 'canPlay', true) end addCommandHandler ( "tkm", taskagitmakas ) function onChat (message, messageType) if not (getElementData(player, 'canPlay')) and message = string.find "/tkm" then outputChatBox("#00cc00Winner CPU!" ,source,0,255,0,true) end addEventHandler ( "onPlayerChat", getRootElement(), onChat ) I get error at line 79 and it doesnt works. Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 What the hell is this here: function taskagitmakas ( player, command, tkm ) if getElementData(player, 'canPlay') then local rand = math.random(0,2) local playing = nil if tkm == 'rock' then playing = 'rock' elseif tkm == 'paper' then playing = 'paper' elseif tkm == 'scissors' then playing = 'scissors' end if rand == 0 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock !" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player) ,getRootElement(),0,255,0,true) end if rand == 0 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played rock!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 1 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played paper!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw!" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'rock' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner"..getPlayerName(player), getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'scissors' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Draw" ,getRootElement(),0,255,0,true) end if rand == 2 and tkm == 'paper' then outputChatBox("Rock,Paper,Scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#cc0000"..getPlayerName(player).." #00cc00has played "..playing.."!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00CPU played scissors!" ,getRootElement(),0,255,0,true) outputChatBox("#00cc00Winner CPU!" ,getRootElement(),0,255,0,true) end end setElementData(player, 'canPlay', false) setTimer(setElementData, 60000, 1, player, 'canPlay', true) else outputChatBox('You have to wait 1 minute before you play again', player) end addCommandHandler ( "tkm", taskagitmakas ) Why is the onPlayerChat thing? Link to comment
gokalpfirat Posted June 18, 2011 Author Share Posted June 18, 2011 Not working. There arent any text at chatbox when i say /tkm rock Link to comment
JR10 Posted June 18, 2011 Share Posted June 18, 2011 Oh i forgot addEventHandler('onResourceStart', resourceRoot, function() for i,v in ipairs(getElementsByType('player')) do setElementData(v, 'canPlay', true) end end ) addEventHandler('onPlayerJoin', root, function() setElementData(source, 'canPlay', true) end ) 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