Han ocurrido los siguientes errores:
Warning [2] Undefined variable $unreadreports - Line: 119 - File: global.php(961) : eval()'d code PHP 8.4.6 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/global.php(961) : eval()'d code 119 errorHandler->error_callback
/global.php 961 eval
/printthread.php 16 require_once



MxEMexico
[ SQL ] Crear Tablas - Versión para impresión

+- MxEMexico (https://www.mxemexico.com)
+-- Foro: Extras (https://www.mxemexico.com/forumdisplay.php?fid=162)
+--- Foro: Pawn/Scripting. (https://www.mxemexico.com/forumdisplay.php?fid=100)
+--- Tema: [ SQL ] Crear Tablas (/showthread.php?tid=9494)



[ SQL ] Crear Tablas - ChrstopH - 12-03-2018

kpx, es un plugin que hice hace unos minutos xdXdXDxddxDXXDxd

Consiste en que puedan su tabla desde un archivo .ini

Uso:
- Crear un archivo .ini en configs llamado "Tablas"
- dentro de el meten el script para crear su tabla
- En el .sma Ponen el nombre de su DB ( es decir el del archivo sq3 )
- Una ves ya teniendo lo anterior escriben "amx_tabla" en consola y debería crearse  :whatever:

PD; Ya se que es un plugin muy simple, tal ves a alguien le sirva :whatever:

 
Código PHP:
<?php 
/* Script generated by Pawn Studio */

#include <amxmodx>
#include <amxmisc>
#include <sqlx>

new const szArchivo[] = "Tablas.ini";

new const
szDB[] = "TEST"; // cambiar al nombre de tu DB ( osea el archivo sq3 )

new szRuta[ 300 ]; 
new szPath[ 256 ];

new
Handle:hTuple;

public
plugin_init()
{
register_plugin("Crear Tablas SQL", "0.1", "Hypnotize");
// Add your own code here

get_configsdir( szPath, charsmax( szPath ) );
formatex( szRuta, charsmax( szRuta ), "%s/%s", szPath, szArchivo );

register_clcmd("amx_tabla", "LeerIni");

MySQLx_Init();
}

public
LeerIni( id )
{
if( ~
get_user_flags( id ) & ADMIN_RCON )
{
client_print( id, print_chat, "[ AMXX ] No tienes acceso a este comando!" );
return;
}
if( !
file_exists( szRuta ) ) 
{
client_print( id, print_console, "[ AMXX ] El archivo '%s' NO Existe.", szRuta );
return;
}

new
szLine[ 700 ], szTable[ 1000 ], len = 0;
new
file; file = fopen( szRuta, "r" );

while(
file && !feof( file ) )
{
fgets( file, szLine, charsmax( szLine ) );

if(
szLine[ 0 ] == ';' || szLine[ 0 ] == '/' && szLine[ 1 ] == '/' || !szLine[ 0 ] )
continue;

len += format( szTable[len], charsmax( szTable ) - len, "%s", szLine );
}

fclose( file );

SQL_ThreadQuery( hTuple, "QueryCreateTable", szTable );
}
 
public MySQLx_Init()
{
    new get_type[ 12 ]; SQL_SetAffinity( "sqlite" );
    SQL_GetAffinity( get_type, sizeof get_type );

    if( !equali( get_type, "sqlite" ) )
    {
        log_to_file( "SQLITE_ERROR.txt", "[ AMXX ] Error de conexion" );
        return pause( "a" );
    }
    
    hTuple
= SQL_MakeDbTuple( "", "", "", szDB );
    
   
return PLUGIN_CONTINUE
}

public
plugin_end( )
SQL_FreeHandle( hTuple ); 

public QueryCreateTable(failstate, error[], error2, data[], size, Float:queuetime)
{
    switch ( failstate )
    {
        case TQUERY_CONNECT_FAILED: log_to_file("SQL_LOG_TQ.txt", "Failed to connect to database [%i]: %s", error2, error)
        case TQUERY_QUERY_FAILED: log_to_file("SQL_LOG_TQ.txt", "Error on query for creating table [%i]: %s", error2, error)
    }
    
   
return PLUGIN_HANDLED;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
*/

IMAGENES:
Tabla a crear en .ini
[ http://prntscr.com/lp8x48 ]

Tabla creada y revisada:

[ http://prntscr.com/lp8wzi ]


RE: [ SQL ] Crear Tablas - GabsHp - 12-03-2018

No entendí cuál es la función Xd Crear una tabla con un string ya definido en un .ini, activado mediante un comando de amx? Eso entendí, no sé si eso era o estoy pacheco Xd


RE: [ SQL ] Crear Tablas - ChrstopH - 12-03-2018

Por si eres wey y no tenes el SQLManager y ocupas crear una tabla para algún plugin, metes el script para crear la tabla en el .ini y pones amx_tabla y te ejecuta el script creandote la tabla en la DB :whatever: