Jump to content

[Help]using diffirent commands to accept .


Recommended Posts

Hello .

I making a casino script that let you bet with other players on money . So , the player "A" use /roll name amount then the player"B" get a message that he can accept or refuse to bet on that money .

My problem is that when i send the bet to other player , what i have to do to make him check if he got an invitation from other player ? and how he can accept ?

Here is my code .

he can use the command /roll to invite someone and the other one can recive it then i didn't know how to make him accept or refuse the bet ?

function dice (player,command,giveplayername,ammount) 
if isElementWithinMarker (player,isincasino) then 
 local moneytogive = tonumber(ammount)   
   local givenplayer = getPlayerFromName ( giveplayername ) 
        local playername = getPlayerName ( player ) 
        local playername2 = getPlayerName ( givenplayer ) 
if  moneytogive >= 2000 then 
if getPlayerMoney (player) >= moneytogive then 
outputChatBox("use /accept to accept the bet",givenplayer,255,0,0) 
outputChatBox("sent",player,255,0,0) 
setElementData (player,playername2,"sent") 
setElementData (givenplayer,playername,"accept") 
  
else 
outputChatBox("You don't have enough money",player,255,0,0) 
end 
else 
outputChatBox("You need more than 2000$ ",player,255,0,0) 
end 
end 
end 
addCommandHandler("roll",dice) 
  
  
function accepto (player,command,giveplayername) 
if (player and getElementType(player) == "player" ) then 
   local givenplayer = getPlayerFromName ( giveplayername ) 
        local playername = getPlayerName ( player ) 
        local playername2 = getPlayerName ( giveplayername ) 
if getElementData (givenplayer,playername,"accept") then 
onaccept() 
  
end 
end 
end 
addCommandHandler ("accept",accepto) 
  
function onaccept (player,givenplayer) 
 takePlayerMoney(player,moneytogive) 
 takePlayerMoney(givenplayer,moneytogive) 
 x = math.random(1,12) 
 y = math.random(1,12) 
  
if x > y then  
outputChatBox("You Won ".. moneytogive*2 .."$ you rolled "..x.." and the computer rolled "..y,player,1,172,45) 
setTimer (givePlayerMoney,2000,1,player,moneytogive*2) 
end 
if x == y then 
outputChatBox("Its Draw!!! , You got your Money back , you rolled "..x.." and the computer rolled "..y,player,255,0,0) 
givePlayerMoney(player,moneytogive) 
end 
if xthen 
outputChatBox("You lost , you rolled "..x.." and the computer rolled "..y,player,255,0,0) 
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...