#7 |
AMX_CREARCODES
[spoiler]
Código PHP:
/* Script generated by Pawn Studio */
#include <amxmodx>
#include <amxmisc>
#include <mysqlt>
#define PLUGIN "amx_crearCodes"
#define AUTHOR "Hypnotize"
#define VERSION "1.0"
new const HOST[] = "127.0.0.1";
new const USUARIO[] = "root";
new const PASSWORD[] = "";
new const DB[] = "test";
new const szTableP[] = "amx_codigos"; //misma tabla del plugin original
new Handle:g_isTuple, Handle:g_Connection;
const CREAR_CODE = 4;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
// Add your own code here
register_clcmd( "amx_crearCode", "amx_crear", ADMIN_RCON, "< Cantidad de codes > < Cantidad de APS >")
MySQL_Init( );
}
public amx_crear( id, nivel, cid )
{
if (!cmd_access(id, nivel, cid, 3))
return PLUGIN_HANDLED;
new Query[ 256 ], iData[ 2 ], code[ 100 ], len, valor[ 100 ];
iData[ 0 ] = id;
iData[ 1 ] = CREAR_CODE;
read_argv( 1, code, charsmax( code ) );
read_argv( 2, valor, charsmax( valor ) );
remove_quotes( code );
remove_quotes( valor );
new amount = str_to_num( code );
new amount2 = str_to_num( valor );
new rnd = random_num( 4, 9 );
for( new i = 0; i < amount; i++ )
{
len = format(code[len], sizeof code - len, "ZP_");
for( new i = 0; i < rnd; i++ )
{
switch( random_num(0, 2) )
{
case 0: len += format(code[len], sizeof code - len, "%s", random_num( 97, 122 ));
case 1: len += format(code[len], sizeof code - len, "%s", random_num( 65, 90 ));
case 2: len += format(code[len], sizeof code - len, "%s", random_num( 48, 57 ));
}
}
//client_print(id, print_console, "INSERT INTO %s (Code, premio) VALUES (^"%s^", %d)", szTableP, code, amount2);
formatex( Query , charsmax( Query ) , "INSERT INTO %s (Code, premio) VALUES (^"%s^", %d)", szTableP, code, amount2);
mysql_query(g_Connection, "Crearcodees", Query, iData, 2 );
}
return PLUGIN_HANDLED;
}
public MySQL_Init( )
{
g_isTuple = mysql_makehost(HOST, USUARIO, PASSWORD, DB);
new error[32], errnum;
g_Connection = mysql_connect(g_isTuple, errnum, error, 31);
if(errnum)
{
log_to_file("mysqlt.log", "ERROR1: [%d]- [%s]", errnum, error)
return pause( "a" );
}
return PLUGIN_CONTINUE;
}
public Crearcodees(failstate, error[], error2, data[], size, Float:queuetime)
{
static id;
id = data[ 0 ];
if( !is_user_connected( id ) )
return;
switch( failstate )
{
case TQUERY_CONNECT_FAILED:
{
log_to_file( "SQL_LOG_TQ.txt", "Error en la conexion al MySQL [%i]: %s", error2, error );
return;
}
case TQUERY_QUERY_FAILED: log_to_file( "SQL_LOG_TQ.txt", "Error en la consulta al MySQL [%i]: %s", error2, error );
}
if( data[ 1 ] == CREAR_CODE )
{
if( failstate < TQUERY_SUCCESS )
client_print(id, print_console, "ERROR AL CREAR EL CODE");
else
client_print(id, print_console, "CODE REGISTRADO CORRECTAMENTE");
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/
[/spoiler]
Un addon extra al plugin a pedido de w0w
IMAGENES
http://prntscr.com/lnbcbi
https://steamcommunity.com/sharedfiles/f...1575548060
https://steamcommunity.com/sharedfiles/f...1575552873
http://prntscr.com/lnbfhw
TEMA & SOPORTE EN: https://amxmodx-es.com/Thread-ZP-Addon-S...C3%B3digos
Mapas Frutas 100%
DeathRun Levels 100%
Atrapa al Traidor (Edición) 100%
Battle Royale 40%