Jump to content

Rock, Paper, Scissors


Recommended Posts

  
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
# 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

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

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
     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

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

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
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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...