Creating Tables by API

For discussion of the Poker Mavens server module and other administration topics

Re: Creating Tables by API

Postby Kent Briggs » Tue Aug 25, 2009 3:17 pm

MonTheHoops wrote:Cheers Kent, got that to work now. Just waiting for the code to put the created games online as I'm completely clueless on the coding side of things, I just cant get my head around it at all..I've tried :D


Here's a modifcation of George's code that puts the game online right after creating it:

Code: Select all
<html>
<body bgcolor="#F3FFC2">
     
  <?php

    include "API.php";

    if (isset($_REQUEST["Submit"]))
    {
      $Player = $_REQUEST["Player"];
      $Name = $_REQUEST["Name"];
      $Game = $_REQUEST["Game"];
      $Password = $_REQUEST["Password"];
      $ObserverChat = $_REQUEST["ObserverChat"];
      $Seats = $_REQUEST["Seats"];
      $BuyInMin = $_REQUEST["BuyInMin"];
      $BuyInMax = $_REQUEST["BuyInMax"];
      $BuyInDef = $_REQUEST["BuyInDef"];
      $SmallBlind = $_REQUEST["SmallBlind"];
      $BigBlind = $_REQUEST["BigBlind"];
      $params = "Password=$pw&Command=RingGamesAdd" .
                "&Name=" .   urlencode($Name) .
                "&Game=" .   urlencode(stripslashes($Game)) .
                "&PW=" .       urlencode($Password) .
               "&Private=" . "No" .
               "&ObserverChat=" .    urlencode($ObserverChat) .
                "&Seats=" . urlencode($Seats) .
                "&BuyInMin=" . urlencode($BuyInMin) .
      "&BuyInMax=" . urlencode($BuyInMax) .
      "&BuyInDef=" .    urlencode($BuyInDef) .
      "&Rake=" . 3 .
      "&RakeEvery=" . 100 .
      "&RakeMax=" . 1000 .
      "&TurnClock=" . 30 .
      "&TimeBank=" . 60 .
                "&SmallBlind=" .   urlencode($SmallBlind) .
                "&BigBlind=" .    urlencode($BigBlind) .
      "&Auto=" . "Yes" .
                "&Log=" .     urlencode("Ring game $Name created by $Player");
      $api = Poker_API($url,$params,true);
      if ($api["Result"] == "Ok")
      {
        $params = "Password=$pw&Command=RingGamesOnline&Name=" . urlencode($Name) ;
        $api = Poker_API($url,$params,true);
        if ($api["Result"] == "Ok") echo "A new Ring Game, $Name , has been successfully created and put online.";
        else echo "Error putting new game online: " . $api["Error"];
      }
      else echo "Error creating game: " . $api["Error"] . "<br/>Click Back Button to correct";
      exit;
    }
  ?>

  <h2>Add Your Own Ring Game Table</h2>
<h3>to Our Players Club gameserver</h3>
  <form method="post">
    <table>
    <tr><td>Your PlayerName:</td><td><input type="text" name="Player" /></td></tr>
    <tr><td>Name the table:</td><td><input type="text" name="Name" /></td></tr>
<tr><td>Game:</td><td><select size="1" name="Game">
       <option>Select an option</option>
   <option value="Limit Hold'em">Limit Hold'em</option>
       <option value="Pot Limit Hold'em">Pot Limit Hold'em</option>
        <option value="No Limit Hold'em">No Limit Hold'em</option>
   </select></td></tr>
    <tr><td>Table Password:</td><td><input type="text" name="Password" />(optional)</td></tr>
    <tr><td>Allow Observer Chat:</td><td>
   <input type="radio" name="ObserverChat" Value="Yes" checked>Yes</input>
   <input type="radio" name="ObserverChat" Value="No">No</input></td></tr>
    <tr><td><select size="1" name="Seats">
       <option>Seats:</option>
   <option value="2">2</option>
       <option value="3">3</option>
        <option value="4">4</option>
   <option value="5">5</option>
       <option value="6">6</option>
        <option value="7">7</option>
   <option value="8">8</option>
       <option value="9">9</option>
        <option value="10">10</option>
   </select></td></tr>
   <tr><td> <select size="1" name="BuyInMin">
       <option>Minimum Buyin:</option>
   <option value="10">10</option>
       <option value="50">50</option>
        <option value="100">100</option>
   <option value="200">200</option>
       <option value="500">500</option>
        <option value="1000">1000</option>
   <option value="2000">2000</option>
       <option value="5000">5000</option>
</select></td></tr>
   <tr><td> <select size="1" name="BuyInMax">
       <option>Maximum Buyin:</option>
   <option value="10">10</option>
       <option value="50">50</option>
        <option value="100">100</option>
   <option value="200">200</option>
       <option value="500">500</option>
        <option value="1000">1000</option>
   <option value="2000">2000</option>
       <option value="5000">5000</option>
   <option value="10000">10000</option>
</select></td></tr>
<tr><td> <select size="1" name="BuyInDef">
       <option>Default Buyin:</option>
   <option value="10">10</option>
       <option value="50">50</option>
        <option value="100">100</option>
   <option value="200">200</option>
       <option value="500">500</option>
        <option value="1000">1000</option>
   <option value="2000">2000</option>
       <option value="5000">5000</option>
   <option value="10000">10000</option>
</select></td></tr>
<tr><td> <select size="1" name="SmallBlind">
       <option>Small Blind:</option>
   <option value="1">1</option>
       <option value="2">2</option>
   <option value="5">5</option>
   <option value="10">10</option>
       <option value="50">50</option>
        <option value="100">100</option>
   <option value="250">250</option>
       <option value="500">500</option>
</select></td></tr>
<tr><td> <select size="1" name="BigBlind">
      <option>Big Blind:</option>
    <option value="1">1</option>
       <option value="2">2</option>
       <option value="4">4</option>
   <option value="5">5</option>
   <option value="10">10</option>
   <option value="20">20</option>
       <option value="50">50</option>
        <option value="100">100</option>
   <option value="200">200</option>
       <option value="500">500</opti0on>
   <option value="1000">1000</option>
</select></td></tr>
    </table>
    <input type="submit" name="Submit" value="Create This Table!" />
  </form>

</body>
</html>
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3830
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby CanadaWest » Tue Aug 25, 2009 8:34 pm

OK Kent, you had me believing.

If you can do a string of commands, then this should work to take a tourney offline, change the date and put it back online. But it takes the game offline and then returns the error: "Error setting StartTime: Tournament is online Click Back Button to correct"

<?php

include "API.php";

if (isset($_REQUEST["Submit"]))
{
$Name = $_REQUEST["Name"];
$StartTime = $_REQUEST["time"];

$params = "Password=$pw&Command=TournamentsOffline" .
"&Name=" . urlencode($Name) .
"&Now=" . "Yes" ;
$api = Poker_API($url,$params,true);
if ($api["Result"] == "Ok")
{
$params = "Password=$pw&Command=TournamentsEdit" .
"&Name=" . urlencode($Name) .
"&StartTime=" . urlencode($StartTime);
$api = Poker_API($url,$params,true);
if ($api["Result"] == "Ok")
{
$params = "Password=$pw&Command=TournamentsOnline" .
"&Name=" . urlencode($Name) ;
$api = Poker_API($url,$params,true);
if ($api["Result"] == "Ok")
echo "<p><font face=\"Arial\" size=\"2\">Date and time for $Name changed to $StartTime<br><a href=\"http://playersclub.ca/PMservice/TourneyDate.php\">BACK</a>,</font></p>" ;
else echo "Error putting game online: " . $api["Error"] . "<br>Click Back Button to correct.<br><a
href=\"http://playersclub.ca/PMservice/TourneyDate.php\">BACK</a>,</font>";

}
else echo "Error setting StartTime: " . $api["Error"] . "<br/>Click Back Button to correct";
}
else echo "Error taking game offline: " . $api["Error"] . "<br/>Click Back Button to correct";
exit;
}
?>
George
(CanadaWest)
www.playersclub.ca
CanadaWest
 
Posts: 107
Joined: Wed May 06, 2009 12:59 pm

Re: Creating Tables by API

Postby Kent Briggs » Tue Aug 25, 2009 9:10 pm

CanadaWest wrote:If you can do a string of commands, then this should work to take a tourney offline, change the date and put it back online. But it takes the game offline and then returns the error: "Error setting StartTime: Tournament is online Click Back Button to correct"


The tournament thread needs a few seconds to shut down so either stick a sleep() command in between the API calls or better yet, make a loop that repeatedly calls TournamentsGet until you get Status=Offline.

shut down tournament
repeat
sleep(1)
until tournament status is offline
Kent Briggs - [email protected]
Briggs Softworks - http://www.briggsoft.com
Kent Briggs
Site Admin
 
Posts: 3830
Joined: Wed Mar 19, 2008 8:47 pm

Re: Creating Tables by API

Postby CanadaWest » Thu Aug 27, 2009 5:04 pm

Sorry, I should have figured that out.

Your help with stuff like this is WAY more than we should expect.
George
(CanadaWest)
www.playersclub.ca
CanadaWest
 
Posts: 107
Joined: Wed May 06, 2009 12:59 pm

Previous

Return to Site Administration

Who is online

Users browsing this forum: No registered users and 5 guests

cron