Jump to content

roll script.help me pls


raulrobi

Recommended Posts

I have makd a roll script

function roll(player.comd) local roll =

math random(1.6) if roll = 1 then u won blablabla

if roll = 2 u lost blablabla

if roll = 3 u r muted

if roll = 4 u win blablabla

addCommandHandler(("roll",roll)

it doesent work.CAN ANYONE REPAIR IT PLS.

Link to comment
function roll(player,command) -- a comma between parameters not a decimal point
local rand = math.random(1,6) -- math.random (with a decimal point and also a comma to separate the parameters of math.random)
if rand == 1 then -- == instead of = when comparing
-- do something
elseif rand == 2 then
-- do something else
elseif rand == 3 then
-- do something else
elseif rand == 4 then
-- do something else
elseif rand == 5 then
-- do something else
else
-- do something else
end -- end for the if in line 4
end -- end of the function
addCommandHandler("roll",roll) -- add the command handler

Link to comment
function rolldice(player,comd)
local roll = math.random(1,4)
if roll == 1 then outputChatBox("u won blablabla")
elseif roll == 2 then outputChatBox("u lost blablabla")
elseif roll == 3 then setPlayerMuted(source,true); setTimer(setPlayerMuted,1,30000,player,false) 
elseif roll == 4 then outputChatBox("u win blablabla")
end
end
addCommandHandler("roll",rolldice)

Edited by Guest
Link to comment
function roll(player,comd)
local roll = math.random(1,4)
if roll == 1 then outputChatBox("u won blablabla")
elseif roll == 2 then outputChatBox("u lost blablabla")
elseif roll == 3 then setPlayerMuted(source,true); setTimer(function() setPlayerMuted(source,false) end,1,30000) 
elseif roll == 4 then outputChatBox("u win blablabla")
end
end
addCommandHandler("roll",roll)

I do not recommend calling variables the same names as functions.

Link to comment
you.. posted.. 400 bytes script.. on.. RAPIDSHARE?

I'm sure, that nobody will care..

post your code on forums..

or use pastebin.com

or something, but not RAPIDSHARE!

this is his code,

addCommandHandler("roll",rolldice)
function rolldice(player,comd)
local roll = math.random(1,4)
if roll == 1 then outputChatBox("u won")
elseif roll == 2 then outputChatBox("u lost")
elseif roll == 3 then setPlayerMuted(source,true); setTimer(function() setPlayerMuted(source,false) end,1,30000) 
elseif roll == 4 then outputChatBox("u win")
end
end

Link to comment

this doesnt work (i open notepad and paste in it then i do save as then i type roll.lua)

function roll(player,comd)

local roll = math.random(1,4)

if roll == 1 then outputChatBox("u won blablabla")

elseif roll == 2 then outputChatBox("u lost blablabla")

elseif roll == 3 then setPlayerMuted(source,true); setTimer(function() setPlayerMuted(source,false) end,1,30000)

elseif roll == 4 then outputChatBox("u win blablabla")

addCommandHandler("roll",roll)

end

end

Link to comment

it would be much easier for you if you'd have any idea about programming at all.

this code is already a bit messy, you're just messing it up even more:

addCommandHandler("roll",
function(player,comd)
local roll = math.random(1,4)
if roll == 1 then outputChatBox("u won blablabla", player) -- no player was specified, message'd be shown to all
elseif roll == 2 then outputChatBox("u lost blablabla", player)
elseif roll == 3 then 
setPlayerMuted(player, true) -- as i recall, "source" is not passed by command handler, use "player", but i may be wrong
setTimer(setPlayerMuted, 30000, 1, player, false) -- what's more, setTimer parameters were messed up, 30000 executions with 1ms interval.
elseif roll == 4 then outputChatBox("u win blablabla", player)
end
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...