Betting system
#1

hi guys i wanted to make a gambling system like

Player is inside a casino infront of a object id lets say object id 3221

Then he goes infront of object id 3221 and use /lottery

it will ask him for money to bet with Dialog .

If he bets the money, then the player gets frozen for few seconds.

Then if he wins it'll give him the double money he betted if he loose he looses the money he bet on at.

I'd like this to be completely luck wise and very difficult to earn so.

I dont want player to bet more than 50k
Reply
#2

Use checkpoint or pickup in front of that object make if player step there he is able to use lottery command and make win / loose on random, add more loose messages than win messages + money, so there will be more chances for loose than win :P this should work in my logic hah :P
Reply
#3

pawn Код:
SetPlayerCheckpoint(playerid, 0, 0, 0, 5); // the cords where the object is or where you want that player will use cmd

CMD:lottery(playerid, params[])
{
   if(IsPlayerInRangeOfPoint(playerid, 7.0, 0,0,0)) //cords where the lottery is
   {
        ShowPlayerDialog(playerid, 3, DIALOG_STYLE_INPUT, "Lottery", "How much money you want to bet?", "Submit", "Cancel");
   }
    else
   {
    SendClientMessage(playerid, 0xFFFFFF, "You are not at any casino.");
   }
    return 1;
}
i dont have pawn and it is to hard for me to make it without it
the rest you got to do it by yourself...
Reply
#4

What I mean was like

I map an ATM and use that as a lottery ticket

So I place ATM from map editor if people step infront of ATM he can use /lottery

also can someone help me make lottery function like

people bet the money and if he won he get the double money he betted if he loose he looses the money.

Thelottery would work like this
1. Infront of ATM when he does /gamble There is dialog for the number he wants to pick
2.then Another dialog right after number picking called "Money you want to bet"
3.Then once he hit subit button he gets frozen for 4 secconds with textdraw on his skin "Spinning"
4.then a number function if the number get picked match he wins the double amount of money he bet
5.if he looses then he loose the money he bet.
Reply
#5

Help pls!
Reply
#6

pawn Код:
YCMD:gamble(playerid, params[], help)
{
   #pragma unused help
   #pragma unused params
   if(!IsPlayerInRangeOfPoint(playerid, X, Y, Z))
      return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] {FFFFFF} You are not close to atm!");
   ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Input number and cash you want to gamble!", "Submit", "Cancel");
   return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   if(dialogid == 12421)
   {
      if(response)
      {
      new cash, number;
      if(sscanf(inputtext,"dd",number,cash))
         return ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Use this form:\n[number] [cash] !", "Submit", "Cancel");
      else if(number < 1 || number > 10)
         return ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Use this form:\n[number] [cash]\nYour number can't go below 1 or above 10!", "Submit", "Cancel");
      else if(cash < 1 || cash > 1000) // change if you want
         return ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Use this form:\n[number] [cash]\nCash can't go below 1 or above 1000!", "Submit", "Cancel");
      new rand = random(10);
      new rannd = rand + 1; // cuz of '0'
      if(rannd == number)
      {
         GivePlayerMoney(playerid, cash * 2);
         SendClientMessage(playerid, 0xFFFF00AA, "[CONGRATULATIONS] You won!");
      }
      else
      {
         GivePlayerMoney(playerid, 0 - cash);
         SendClientMessage(playerid, 0xFF0000AA, "[FAILURE] You lost!");
      }
      }
   }
   return 1;
}
Reply
#7

Uhm Ermin answered your question.
Reply
#8

Please transform if/else to switch/case because it crhases my compiler
Reply
#9

If you have had optimized the code it won't crash, I gave you example, just to read it and try to understand :S

pawn Код:
YCMD:gamble(playerid, params[], help)
{
   #pragma unused help
   #pragma unused params
   if(!IsPlayerInRangeOfPoint(playerid, X, Y, Z))
      return SendClientMessage(playerid, 0xFF0000AA, "[ERROR] {FFFFFF} You are not close to atm!");
   ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Input number and cash you want to gamble!", "Submit", "Cancel");
   return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
   switch(dialogid)
   case 12421:
      if(response)
      {
      new cash, number;
      if(sscanf(inputtext,"dd",number,cash))
         return ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Use this form:\n[number] [cash] !", "Submit", "Cancel");
      else if(number < 1 || number > 10)
         return ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Use this form:\n[number] [cash]\nYour number can't go below 1 or above 10!", "Submit", "Cancel");
      else if(cash < 1 || cash > 1000) // change if you want
         return ShowPlayerDialog(playerid, 12421, DIALOG_STYLE_INPUT, "Use this form:\n[number] [cash]\nCash can't go below 1 or above 1000!", "Submit", "Cancel");
      new rand = random(10);
      new rannd = rand + 1; // cuz of '0'
      if(rannd == number)
      {
         GivePlayerMoney(playerid, cash * 2);
         SendClientMessage(playerid, 0xFFFF00AA, "[CONGRATULATIONS] You won!");
      }
      else
      {
         GivePlayerMoney(playerid, 0 - cash);
         SendClientMessage(playerid, 0xFF0000AA, "[FAILURE] You lost!");
      }
      }
   return 1;
}
Reply
#10

ty ermin
it worked but i wanted like

to show "Spinning" - When player sumbits the number/money spinning for 5 seconds then the result

also i made 20k - 100k the can only bet and if player has low money it shows them "Low amount money cannot gamble!"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)