Agu# Posted March 23, 2013 Share Posted March 23, 2013 Hola, en script soy medio nuevo, pero quiero saber porque me da este error. Script: local host = "instance42134.db.xeround.com" local user = "Agu" local password = "NO LA MOSTRARE" local database = "usersystem" connect_mysql = mysql_connect(host, user, password, database ) if not connect_mysql then outputChatBox( no_connect_sql_message ) end Link to comment
Agu# Posted March 23, 2013 Author Share Posted March 23, 2013 Esa no es la pass, pero no la mostrare por las dudas Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 No dijiste que error te da... Link to comment
Agu# Posted March 23, 2013 Author Share Posted March 23, 2013 (edited) Perdon. Me dice 2 errores: 1.- ERROR: userPanel/cfg.lua:12: attempt to call global 'mysyql_connect' (a nil value) 2.- ERROR: userPanel/cfg/messages.lua:8: attempt to call global 'mysql_connect' (a nill value) Esos son los errores. cfg.lua: local host = "instance42134.db.xeround.com" local user = "Agu" local password = "NO LA MOSTRARE" local database = "usersystem" connect_mysql = mysql_connect(host, user, password, database ) if not connect_mysql then outputChatBox( no_connect_sql_message ) end messages.lua: no_connect_sql_message = "[sql] ERROR: Could not connect to MySQL server" error_in_query = "Error executing the query: (" .. mysql_errno(connect_mysql) .. ") " .. mysql_error(connect_mysql) --// 1: Makes onstart message visible // 0: Make sonstart message invisible setUpdateMessage = 1 updateMessage = "Nuevas actualizaciones en la userpanel! Asegúrese de presionar el botón Check Progreso en F4!" -- // Clan tag? setTag = "[NvX]" mysql_connect.lua: -- [[ Settings ]] -- local TAGS = {} local admins = "" local unReadMessage = 0 local messageTable = {} local itemTable = {} -- [[ Event's ]] -- addEvent( "changeSkin", true ) addEvent( "updateAdminsOnline", true ) addEvent( "saveSkinGUI", true ) addEvent( "changeNickGUI", true ) addEvent( "sendTheNewPM", true ) addEvent( "savePlayerPosition", true ) addEvent( "setSpawnSet", true ) addEvent( "getMessageFromSubject", true ) addEvent( "deleteMessage", true ) addEvent( "getInventoryItems", true ) addEvent( "openTheUserPanelForUsers", true ) local time = getRealTime() local year = time.year + 1900 local month = time.month + 1 local monthday = time.monthday local hours = time.hour local minutes = time.minute local seconds = time.second -------------------------------------- -- On join, set the class from the player -------------------------------------- function onJoin() if( not connect_mysql ) then outputChatBox( no_connect_sql_message ) else local colour = mysql_query( connect_mysql, "SELECT * FROM `players` WHERE serial='" .. getPlayerSerial( source ) .. "'" ) if( colour ) then while true do local row = mysql_fetch_assoc( colour ) if ( not row ) then if( not TAGS[source] ) then nameJoined = getPlayerName( source ) setPlayerNametagColor ( source, 255, 255, 0 ) createBlipAttachedTo( source, 0, 2, 255, 255, 0) end break end nameJoined = getPlayerName( source ) name = row['login'] money = row['money'] local class = row['class'] TAGS[source] = class bindKey(source, 'F4', 'down', openPanelForUsers) bindKey( source, 'm', 'down', secure ) -- [[ Admin ]] -- if( TAGS[source] == "4" ) then setPlayerNametagColor ( source, 255, 0, 0 ) createBlipAttachedTo( source, 0, 2, 255, 0, 0) setPlayerMoney( source, money ) if( setUpdateMessage == "1" ) then outputChatBox("#FF0000*USER: #FFFF00"..updateMessage.."", source, 0, 0, 0, true ) end -- [[ Moderator ]] -- elseif( TAGS[source] == "3" ) then setPlayerNametagColor ( source, 0, 0, 255 ) createBlipAttachedTo( source, 0, 2, 0, 0, 255) setPlayerMoney( source, money ) if( setUpdateMessage == "1" ) then outputChatBox("#FF0000*USER: #FFFF00"..updateMessage.."", source, 0, 0, 0, true ) end -- [[ Member ]] -- elseif( TAGS[source] == "2" ) then setPlayerNametagColor ( source, 0, 255, 0 ) createBlipAttachedTo( source, 0, 2, 0, 255, 0) setPlayerMoney( source, money ) if( setUpdateMessage == "1" ) then outputChatBox("#FF0000*USER: #FFFF00"..updateMessage.."", source, 0, 0, 0, true ) end end end end mysql_free_result( colour ) end end -------------------------------------- -- Opening the userpanel -------------------------------------- function openPanelForUsers( theUser ) messageTable = {} unReadMessage = 0 if( not connect_mysql ) then outputChatBox( no_connect_sql_message ) else local userQuery = mysql_query( connect_mysql, "SELECT * FROM `players` WHERE serial='" .. getPlayerSerial( theUser ) .. "'" ) if( userQuery ) then while true do local rowUsers = mysql_fetch_assoc( userQuery ) if( not rowUsers ) then break end local userName = rowUsers["login"] local getSiteInfoDatabase = mysql_query( connect_mysql, "SELECT * FROM `messages` WHERE `to`='" .. userName .. "' " ) if (getSiteInfoDatabase) then local numRows = mysql_num_rows(getSiteInfoDatabase) if (numRows >= 0) then while true do local row = mysql_fetch_assoc(getSiteInfoDatabase) countMessage = mysql_num_rows( getSiteInfoDatabase) if (not row) then break end subject = row['title'] from = row['from'] dateN = row['date'] message = row['content'] unread = row['read'] if( unread == "0") then unReadMessage = unReadMessage + 1 end table.insert( messageTable, subject ) table.insert( messageTable, from ) table.insert( messageTable, dateN ) end else return nil end end local loginName = rowUsers["login"] local class = rowUsers["class"] local serial = rowUsers["serial"] local skin = rowUsers["skin"] triggerClientEvent( theUser, "openTheUserPanel", getRootElement(), loginName, class, serial, skin, countMessage, unReadMessage, messageTable, pmMessage, useSpawn ) mysql_free_result( getSiteInfoDatabase ) end end end end addCommandHandler("upanel", openPanelForUsers ) addEventHandler("openTheUserPanelForUsers", getRootElement(), openPanelForUsers ) -------------------------------------- -- If the resource is restarted, re-set the tags. -------------------------------------- function restartingTags() if( not connect_mysql ) then outputChatBox( no_connect_sql_message ) else for i, player in ipairs (getElementsByType ("player")) do local colour = mysql_query( connect_mysql, "SELECT * FROM `players` WHERE serial='" .. getPlayerSerial( player ) .. "'" ) if( colour ) then while true do local row = mysql_fetch_assoc( colour ) if ( not row ) then if( not TAGS[player] ) then nameJoined = getPlayerName( player ) setPlayerNametagColor ( player, 255, 255, 0 ) createBlipAttachedTo( player, 0, 2, 255, 255, 0) end break end nameJoined = getPlayerName( player ) name = row['login'] local class = row['class'] TAGS[player] = class bindKey(player, 'F4', 'down', openPanelForUsers) bindKey( player, 'm', 'down', secure ) if( TAGS[player] == "4" ) then setPlayerNametagColor ( player, 255, 0, 0 ) createBlipAttachedTo( player, 0, 2, 255, 0, 0) elseif( TAGS[player] == "2" ) then setPlayerNametagColor ( player, 0, 255, 0 ) createBlipAttachedTo( player, 0, 2, 0, 255, 0) elseif( TAGS[player] == "3" ) then setPlayerNametagColor ( player, 0, 0, 255 ) createBlipAttachedTo( player, 0, 2, 0, 0, 255) end end end mysql_free_result( colour ) end end end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), restartingTags) -------------------------------------- -- Inventory ------------------------------------- function getInventoryItems( thePlayerUsing ) itemTable = {} local ownerName = getPlayerName( thePlayerUsing ) if( not connect_mysql ) then outputChatBox( no_connect_sql_message ) else local getItems = mysql_query( connect_mysql, "SELECT * FROM `inventory` WHERE `owner`='" .. ownerName .. "'" ) if( getItems ) then while true do local itemRow = mysql_fetch_assoc( getItems ) if( not itemRow ) then break end local numItemRows = mysql_num_rows( getItems ) if (numItemRows >= 0) then -- [[ Items ]] -- item = itemRow['item'] -- ID itemName = itemRow['itemname'] -- Name itemValue = itemRow['itemvalue'] -- Value itemType = itemRow['type'] table.insert( itemTable, item ) table.insert( itemTable, itemName ) table.insert( itemTable, itemValue ) table.insert( itemTable, itemType ) end end end triggerClientEvent( thePlayerUsing, "setItemListGrid", getRootElement(), itemTable ) mysql_free_result( getItems ) end end addEventHandler("getInventoryItems", getRootElement(), getInventoryItems ) -------------------------------------- -- Deleting message! ------------------------------------- function deleteMessage(delSubject, delFrom, thePlayerUsing) local delMessage = mysql_query( connect_mysql, "DELETE FROM `messages` WHERE `title`='".. delSubject .. "' AND `from`='".. delFrom .. "'" ) if( delMessage ) then triggerClientEvent( thePlayerUsing, "deleteSucces", getRootElement()) else outputChatBox("Error.", thePlayerUsing) end mysql_free_result( delMessage ) end addEventHandler("deleteMessage", getRootElement(), deleteMessage ) -------------------------------------- -- Get the message, shove the message to client again ------------------------------------- function getMessageFromSubject( selectedMessage, theSender, thePlayerUsing ) local getTheMessage = mysql_query( connect_mysql, "SELECT content FROM `messages` WHERE `title`='" .. selectedMessage .. "' AND `from`='" .. theSender .. "' " ) local setUnreaded = mysql_query( connect_mysql, "UPDATE `messages` SET `read`='1'" ) local messageRow = mysql_fetch_assoc( getTheMessage ) if( messageRow ) and ( setUnreaded ) then theMessage = messageRow['content'] if ( theMessage ) then triggerClientEvent( thePlayerUsing, "setMessageVisible", getRootElement(), theMessage ) else outputChatBox("No messages?") end else --outputChatBox("An SQL error has occured! Source [[ getMessageFromSubject ]]") end mysql_free_result( getTheMessage ) mysql_free_result( setUnreaded ) end Edited March 23, 2013 by Guest Link to comment
Alexs Posted March 23, 2013 Share Posted March 23, 2013 Eso significa que la función 'mysyql_connect' no existe. Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 Perdon.Me dice 2 errores: 1.- ERROR: userPanel/cfg.lua:12: attempt to call global 'mysyql_connect' (a nil value) 2.- ERROR: userPanel/cfg/messages.lua:8: attempt to call global 'mysql_connect' (a nill value) Esos son los errores. No tenes la module de mysql. P.D: Podrias usar las funciones de mysql integradas. dbConnect dbExec dbQuery dbPoll Link to comment
Agu# Posted March 23, 2013 Author Share Posted March 23, 2013 Emm, lo que pasa es que no entiendo nada de MySQL, solo vi el vídeo de pekio123 que instala el house_system_mysql y yo lo hice tal cual. Pero igual investigare algo. Link to comment
Agu# Posted March 23, 2013 Author Share Posted March 23, 2013 Esto esta bien? outputDebugString( "Initiating usersystem" ) initiateDatabase = dbConnect( "sqlite", "users.db" ) if( initiateDatabase ) then outputDebugString( "Connecting to database" ) end local createPlayerTable = dbQuery( initiateDatabase, "CREATE TABLE IF NOT EXISTS players ( id INTEGER PRIMARY KEY AUTOINCREMENT, login TEXT, type INTEGER, class INTEGER, serial TEXT, skin INTEGER, money INTEGER, ip TEXT)", 10 ) if( createPlayerTable ) then outputDebugString( "Checking player tables.." ) end local createMessageTable = dbQuery( initiateDatabase, "CREATE TABLE IF NOT EXISTS messages ( id INTEGER PRIMARY KEY AUTOINCREMENT, reciever TEXT, sender TEXT, subject TEXT, content TEXT, date INTEGER, read INTEGER)", 10 ) if( createMessageTable ) then outputDebugString( "Checking message tables..") end dbFree( createPlayerTable ) dbFree( createMessageTable ) outputDebugString( "Usersystem started!" ) Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 Para insertar/crear/cambiar usa dbExec, dbQuery se usa para obtener datos. Link to comment
Agu# Posted March 23, 2013 Author Share Posted March 23, 2013 Mira probare, pero por las dudas, este es el script. https://community.multitheftauto.com/in ... ils&id=744 Link to comment
Castillo Posted March 23, 2013 Share Posted March 23, 2013 Se ve que no entendiste como funciona ese recurso, el script ese tiene todo lo de mysql, lo unico que hay que hacer es configurar el servidor mysql. P.D: Usa este mejor, que no requiere mysql: https://community.multitheftauto.com/ind ... ls&id=6208 Link to comment
Agu# Posted March 23, 2013 Author Share Posted March 23, 2013 Si, muchas gracias, ese me lo descargue ayer, pero puse todo bien, presiono F4 y no me aparece el panel. Una cosa, yo cambie todo al español. Perdonen por las molestias, es que solo llevo 1 mes de scripter y no entiendo todo, tienen que darme tiempo para leer y pensar, discúlpenme por favor y gracias por su atención. Link to comment
Recommended Posts