Author Topic: Simple Lotery  (Read 8849 times)

Offline Katzujari

Simple Lotery
« on: March 01, 2011, 02:16:07 am »
Ok, Primero en español:
Este Item es básicamente un sistema de "billete premiado" en que los usuarios ingresan un numero entre 1 y X, si resulta el mismo que arroja el PHP, resultan ganadores de Y creditos

X y Y Se configuran abiertamente desde Admin panel, pudiendo crear algo sencillo o algo complejo.
Ej: numero entre 1 y 3 o numero entre 1 y 100.

En caso de que el usuario coloque un numero mayor a X (en el primer ejemplo, 4) habrá desperdiciado su dinero.



Now in english :P
This Item is basically a system of "winning ticket"in which users enter a number between 1 and X, if it is cast by the PHP, are winners of Y credits

X and Y are configured openly from Admin panel and can create simple or complex.
Eg number between 1 and 3 or number between 1 and 100.

If the user to place a number greater than X (in the first instance, 4) have wasted their money.

(google translate LOL)

Code: [Select]
<?php
/**********************************************************************************
* SMFShop item                                                                    *
***********************************************************************************
* SMFShop: Shop MOD for Simple Machines Forum                                     *
* =============================================================================== *
* Software Version:           SMFShop 3.0 (Build 12)                              *
* $Date:: 2007-01-18 19:26:55 +1100 (Thu, 18 Jan 2007)                          $ *
* $Id:: loteria.php 79 2007-01-18 08:26:55Z daniel15                          $ *
* Software by:                DanSoft Australia (http://www.dansoftaustralia.net/)*
* Copyright 2005-2007 by:     DanSoft Australia (http://www.dansoftaustralia.net/)*
* Support, News, Updates at:  http://www.dansoftaustralia.net/                    *
*                                                                                 *
* Forum software by:          Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006-2007 by:     Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version of the license can always be found at                        *
* http://www.simplemachines.org.                                                  *
**********************************************************************************/

if (!defined('SMF'))
die('Hacking attempt...');

class 
item_Loteria extends itemTemplate
{
function getItemDetails() {
$this->authorName 'Katzujari';
$this->authorWeb 'http://www.foro.rphentai.co.cc/';
$this->authorEmail '';

$this->name "Loteria";
$this->desc "Gana xxx Creditos!";
$this->price 10;

$this->require_input true;
$this->can_use_item true;
$this->addInput_editable true;
}

function getAddInput()
{
global $item_info$db_prefix;
if ($item_info[1] == 0$item_info[1] = '3';
if ($item_info[2] == 0$item_info[2] = '30';
return 'Numero Maximo para sorteo: <input type="text" name="info1" value="' $item_info[1]  . '" /><br />
    Premio (cantidad si se gana): <input type="text" name="info2" value="' 
$item_info[2]  . '" /> ';
}

function getUseInput()
{
global $item_info$db_prefix;
$num "<input type='text' name='numuser' value='1'>";
return "Escribe un numero entre 1 y {$item_info[1]}: " .$num;
}

function onUse()
{
global $item_info$db_prefix$context;
if ($_POST['numuser'] > $item_info[1])
{
return 'El numero debia ser entre 1 y '.$item_info[1].'. Solo has desperdiciado tu dinero.';
}
else {
$sorteo mt_rand(1$item_info[1]);
if ($_POST['numuser'] == $sorteo)
{
$result db_query("
UPDATE 
{$db_prefix}members
SET money = money + "
.$item_info[2]."
WHERE ID_MEMBER = 
{$context[user][id]}"__FILE____LINE__);

return 'Felicidades! Ganaste ' .$item_info[2];
}
else
{
return 'Mala suerte, el numero correcto era ' .$sorteo;
}
}
}
}

?>


(Review the file to translate texts)

Offline hoxxing

Re: Simple Lotery
« Reply #1 on: January 18, 2013, 11:11:59 am »
Hola, me aparece éste error:

"ERROR: No se pudo crear instancia de 'lotery' item!"

Tengo la versión:
Numero de la version: 3.1 (SMF 2.0 branch) (Build 5)
Version: 3.0 (Build 15)

SMF: 2.0.2

Cómo lo puedo solucionar?
Gracias! :)

Offline hoxxing

Re: Simple Lotery
« Reply #2 on: January 19, 2013, 11:54:39 pm »
Hola :)
Ya he podido saber porque el error de arriba se daba, y es que yo había guardado el archivo como "lotery.php" cuando el id del ítem es "loteria.php", así es como debía guardarlo, pero bueno, ahora tengo otro problema:

Resulta que al añadir el ítem todo iba bien, añadirlo en el shop, comprarlo, usarlo, jugar y perder.....pero al momento de ganar, surge un problema:

"Fatal error: Call to undefined function db_query() in /home/stepmani/public_html/foro_3/Sources/shop/items/loteria.php on line 76"

He intentado solucionarlo, pero nada la verdad, no se cual es el problema, uso DreamWeaber Cs5 y cuando trato de cambiar algo muestra error syntax, pero cuando vuelve a su normalidad, nada, me dice que el código esta bien pero en realidad al usarlo, no. Que puede ser?

Muchas gracias.

Offline Coolgem

Re: Simple Lotery
« Reply #3 on: March 29, 2013, 09:07:17 am »
Hello, can you please make a version of this that is english? That would be nice. P.S. I'm using Google Translate to write this message in spanish because i am english, not spanish!
----------------------------------------------------------------------
Hola, ¿podría hacer una versión de este que es el Inglés? Eso estaría bien. PD Estoy usando Google Translate para escribir este mensaje en español porque no soy Inglés, no español!

Offline emankhan

Re: Simple Lotery
« Reply #4 on: January 27, 2015, 03:29:25 pm »
nice and good post
____________
http://www.chessrivals.net/

« Last Edit: December 29, 2015, 02:31:53 pm by emankhan »

Offline mali

Re: Simple Lotery
« Reply #5 on: June 15, 2016, 04:50:43 am »
long sought this information, thank you!