Jump to content

need help


COOKIE2

Recommended Posts

i need help at roll5-6 the rest is just for now

addCommandHandler("roll",

function(player,comd)

local roll = math.random(1,6)

if roll == 1 then outputChatBox("u won", 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", player)

elseif roll == 5 then givePlayerMoney(source,3500)

elseif roll == 6 then takePlayerMoney(source,4500)

end

end

)

Link to comment

Hmm, why not try this way?

addCommandHandler("roll",
function(player,comd)
local roll = math.random(1,6)
if roll == 1 then outputChatBox("u won", 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("You win!", player)
elseif roll == 5 then setPlayerMoney( source, +3500 ) --Add $3500 to the money you have.
elseif roll == 6 then setPlayerMoney( source, -4500 ) --Reduce $4500 from the money amount you have.
end
end
)

If this still doesn't work, try changing 5 and 6 to:

elseif roll == 5 then setPlayerMoney(player, +3500)
elseif roll== 6 then takePlayerMoney(player,  -4500)

The way to put codes is by:

[lua]inside it is code, then end it with "/" in front of "lua"

Link to comment

Use takePlayerMoney and givePlayerMoney. They are there for a reason.

setPlayerMoney will set player's money; it will not add the amount you pass in 2nd parameter.

If you'll takePlayerMoney with negative value, you may see weird money behaviour (either going way too high or down too low).

@COOKIE2, LEARN LEARN LEARN... You don't have source in your function anywhere... You have player in function parameter list, why don't you use it, master-helper?

Link to comment

why dont you stick with your previous topic?

why dont you put code in lua tags?

why dont you read comments in the code you're trying to edit?

i commented that code about "player" instead of "source", if you'd bother to pay any attention to that your code would work and save people here from another cookie topic.

addCommandHandler("roll",
function(player,comd)
local roll = math.random(1,6)
if roll == 1 then outputChatBox("u won", player)
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) 
elseif roll == 4 then outputChatBox("You win!", player)
elseif roll == 5 then 
givePlayerMoney(player, 3500) -- Add $3500 to the money you have.
outputChatBox("You won $3500!", player) -- it's a good practice to inform player what happend to his cash, you know
elseif roll == 6 then 
takePlayerMoney(player, 4500) -- Reduce $4500 from the money amount you have.
outputChatBox("You lost $4500!", 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...