Castillo Posted June 7, 2012 Share Posted June 7, 2012 You're trying to use MySQL in a client side script, that'll never work because MySQL is server side only. Link to comment
Cyandie Posted June 7, 2012 Share Posted June 7, 2012 Just make a triggerServerEvent with your server side ( inserting to SQL or any SQL Script ). Link to comment
iFoReX Posted June 7, 2012 Author Share Posted June 7, 2012 what is bad ? :c problem in debugg addEventHandler("onResourceStart", resourceRoot, function() exports.sql:create_table('doingJob', { { name = 'Player', type = 'TEXT' }, { name = 'State', type = 'TEXT', default = 'false' }, } ) end ) addEvent("ChangeStateMYSQL",true) addEventHandler("ChangeStateMYSQL", getRootElement(), function() local theName = getPlayerName(source) local state = 'true' exports.sql:query_insertid( "INSERT INTO doingJob (Player, State,) VALUES (" .. table.concat( { theName, state } ) .. ")" ) end ) cl-side MedicB = {} MedicB[1] = guiCreateButton(551,189,199,42,"Si deseo hacerlo",false) guiSetVisible(MedicB[1],false) guiSetAlpha(MedicB[1],0) MedicB[2] = guiCreateButton(551,242,199,42,"No gracias",false) guiSetVisible(MedicB[2],false) guiSetAlpha(MedicB[2],0) function ambulanceDX() dxDrawText("No , Gracias !",558.0,250.0,743.0,277.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawRectangle(552.0,244.0,196.0,40.0,tocolor(0,0,0,200),false) dxDrawText("Si, deseo hacerlo !",558.0,194.0,742.0,226.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawRectangle(551.0,189.0,199.0,43.0,tocolor(0,0,0,220),false) dxDrawText("ambulancia ?",438.0,109.0,598.0,139.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawText("Hola amigo, quieres trabajar conduciendo la",437.0,91.0,816.0,108.0,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,true) dxDrawRectangle(429.0,86.0,419.0,329.0,tocolor(0,0,0,200),false) end medicPed = createPed( 70, -2655.1479492188, 640.16479492188, 14.454549789429) setElementRotation(medicPed, 0, 0, 180) medicMarker = createMarker( -2655.0856933594, 639.46484375, 13.5, "cylinder", 1, 255,255,255, 100 ) function markerHit (hitPlayer) if ( hitPlayer == localPlayer ) then addEventHandler("onClientRender",root, ambulanceDX) guiSetVisible(MedicB[1],true) guiSetVisible(MedicB[2],true) showCursor (true) end end addEventHandler ("onClientMarkerHit", medicMarker, markerHit) addEventHandler("onClientResourceStart", getResourceRootElement(), function() exports.sql:create_table('doingJob', { { name = 'Player', type = 'TEXT' }, { name = 'State', type = 'TEXT', default = 'false' }, } ) end ) addEventHandler("onClientGUIClick", root, function() if source == MedicB[2] then removeEventHandler("onClientRender",root, ambulanceDX) guiSetVisible(MedicB[1],false) guiSetVisible(MedicB[2],false) showCursor(false) elseif source == MedicB[1] then triggerServerEvent("ChangeStateMYSQL", getLocalPlayer()) end end ) Link to comment
Karevan Posted June 12, 2012 Share Posted June 12, 2012 You cant access externally to databases from 000webhost, you may consider looking for a paid host which allows you to do so Link to comment
myonlake Posted June 12, 2012 Share Posted June 12, 2012 Just get Xampp, that's probably one of the easiest things of managing a server. No need to pay anything. Link to comment
iFoReX Posted September 4, 2012 Author Share Posted September 4, 2012 why it doesnt work ? local server = get( "server" ) or "localhost" -- server local user = get( "user" ) or "root" -- username local password = get( "password" ) or "" -- password local db = get( "database" ) or "rpserver" -- database local port = get( "port" ) or 3306 local socket = get( "socket" ) or nil ================================================================== = Multi Theft Auto: San Andreas v1.3 ================================================================== = Server name : TDF|paradise ~ Roleplay = Server IP address: = Server port : 4590 = = Log file : ..p/RP Server/mods/deathmatch/logs/server.log = Maximum players : 32 = HTTP port : 23002 = Voice Chat : Disabled = Bandwidth saving : Medium ================================================================== [2012-09-05 01:39:06] Resources: 30 loaded, 0 failed [2012-09-05 01:39:06] Querying game-monitor.com master server... unavailable! [2012-09-05 01:39:06] Querying backup master server... success! [2012-09-05 01:39:06] MODULE: Unable to find modules/mta_mysql.dll! [2012-09-05 01:39:06] MODULE: Loaded "SHA Module" (1.02) by "mabako" [2012-09-05 01:39:06] Starting resources..... [2012-09-05 01:39:06] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:06] Start up of resource sql cancelled by script [2012-09-05 01:39:06] ERROR: Unable to start resource sql; Start up of resource cancelled by script [2012-09-05 01:39:06] Start up of resource irc cancelled by script [2012-09-05 01:39:06] ERROR: Unable to start resource irc; Start up of resource cancelled by script [2012-09-05 01:39:06] WARNING: players/main.lua(Line 379) [server] setPedFrozen is deprecated and may not work in future versions. Please replace with setElementFrozen. [2012-09-05 01:39:06] Some files in 'players' use deprecated functions. [2012-09-05 01:39:06] Use the 'upgrade' command to perform a basic upgrade of resources. [2012-09-05 01:39:06] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:06] Start up of resource sql cancelled by script [2012-09-05 01:39:06] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:06] Start up of resource players cancelled by script [2012-09-05 01:39:06] ERROR: Unable to start resource players; Start up of resource cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource vehicles cancelled by script [2012-09-05 01:39:07] ERROR: Unable to start resource vehicles; Start up of resource cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource interiors cancelled by script [2012-09-05 01:39:07] ERROR: Unable to start resource interiors; Start up of resource cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource items cancelled by script [2012-09-05 01:39:07] ERROR: Unable to start resource items; Start up of resource cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource vehicles cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource items cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] WARNING: admin/player.lua(Line 225) [server] isPedFrozen is deprecated and may not work in future versions. Please replace with isElementFrozen. [2012-09-05 01:39:07] WARNING: admin/player.lua(Line 238) [server] setPedFrozen is deprecated and may not work in future versions. Please replace with setElementFrozen. [2012-09-05 01:39:07] WARNING: admin/player.lua(Line 241) [server] setVehicleFrozen is deprecated and may not work in future versions. Please replace with setElementFrozen. [2012-09-05 01:39:07] Some files in 'admin' use deprecated functions. [2012-09-05 01:39:07] Use the 'upgrade' command to perform a basic upgrade of resources. [2012-09-05 01:39:07] WARNING: shops/shop.lua(Line 57) [server] setPedFrozen is deprecated and may not work in future versions. Please replace with setElementFrozen. [2012-09-05 01:39:07] Some files in 'shops' use deprecated functions. [2012-09-05 01:39:07] Use the 'upgrade' command to perform a basic upgrade of resources. [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource items cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource shops cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource items cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] ERROR: Unable to start resource shops; Start up of resource cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource vehicles cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource players cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:07] Start up of resource items cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:07] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:07] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource shops cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource items cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource interiors cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource vehicles cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource vehicles cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource maps cancelled by script [2012-09-05 01:39:08] ERROR: Unable to start resource maps; Start up of resource cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource teleports cancelled by script [2012-09-05 01:39:08] ERROR: Unable to start resource teleports; Start up of resource cancelled by script [2012-09-05 01:39:08] WARNING: bank/bank.lua(Line 59) [server] setPedFrozen is deprecated and may not work in future versions. Please replace with setElementFrozen. [2012-09-05 01:39:08] Some files in 'bank' use deprecated functions. [2012-09-05 01:39:08] Use the 'upgrade' command to perform a basic upgrade of resources. [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource items cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource bank cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource items cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) [2012-09-05 01:39:08] Start up of resource sql cancelled by script [2012-09-05 01:39:08] ERROR: exports: Call to non-running server resource (sql) [string "?"] [2012-09-05 01:39:08] Start up of resource players cancelled by script [2012-09-05 01:39:08] ERROR: Unable to start resource bank; Start up of resource cancelled by script [2012-09-05 01:39:08] Server shutdown as requested by resource sql (MySQL module missing.) Link to comment
TwiX! Posted September 5, 2012 Share Posted September 5, 2012 Call to non-running server resource (sql) [string "?"] /start sql Link to comment
TwiX! Posted September 5, 2012 Share Posted September 5, 2012 again this error? show your code where you export sql resource If everything is well then /start sql /restart YOUR RESOURCE Link to comment
iFoReX Posted September 5, 2012 Author Share Posted September 5, 2012 mm I cant do /start sql, because my console close in a seconds sql script : --[[ Copyright (c) 2010 MTA: Paradise This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ]] local connection = nil local connection = nil local null = nil local results = { } local max_results = 128 -- connection functions local function connect( ) -- retrieve the settings local server = get( "server" ) or "localhost" -- server local user = get( "user" ) or "root" -- username local password = get( "password" ) or "" -- password local db = get( "database" ) or "rpserver" -- database local port = get( "port" ) or 3306 local socket = get( "socket" ) or nil -- connect connection = mysql_connect ( server, user, password, db, port, socket ) if connection then if user == "root" then setTimer( outputDebugString, 100, 1, "Connecting to your MySQL as 'root' is strongly discouraged.", 2 ) end return true else outputDebugString ( "Connection to MySQL Failed.", 1 ) return false end end local function disconnect( ) if connection and mysql_ping( connection ) then mysql_close( connection ) end end local function checkConnection( ) if not connection or not mysql_ping( connection ) then return connect( ) end return true end addEventHandler( "onResourceStart", resourceRoot, function( ) if not mysql_connect then if hasObjectPermissionTo( resource, "function.shutdown" ) then shutdown( "MySQL module missing." ) end cancelEvent( true, "MySQL module missing." ) elseif not hasObjectPermissionTo( resource, "function.mysql_connect" ) then if hasObjectPermissionTo( resource, "function.shutdown" ) then shutdown( "Insufficient ACL rights for mysql resource." ) end cancelEvent( true, "Insufficient ACL rights for mysql resource." ) elseif not connect( ) then if connection then outputDebugString( mysql_error( connection ), 1 ) end if hasObjectPermissionTo( resource, "function.shutdown" ) then shutdown( "MySQL failed to connect." ) end cancelEvent( true, "MySQL failed to connect." ) else null = mysql_null( ) end end ) addEventHandler( "onResourceStop", resourceRoot, function( ) for key, value in pairs( results ) do mysql_free_result( value.r ) outputDebugString( "Query not free()'d: " .. value.q, 2 ) end disconnect( ) end ) -- function escape_string( str ) if type( str ) == "string" then return mysql_escape_string( connection, str ) elseif type( str ) == "number" then return tostring( str ) end end local function query( str, ... ) checkConnection( ) if ( ... ) then local t = { ... } for k, v in ipairs( t ) do t[ k ] = escape_string( tostring( v ) ) or "" end str = str:format( unpack( t ) ) end local result = mysql_query( connection, str ) if result then for num = 1, max_results do if not results[ num ] then results[ num ] = { r = result, q = str } return num end end mysql_free_result( result ) return false, "Unable to allocate result in pool" end return false, mysql_error( connection ) end function query_free( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end checkConnection( ) if ( ... ) then local t = { ... } for k, v in ipairs( t ) do t[ k ] = escape_string( tostring( v ) ) or "" end str = str:format( unpack( t ) ) end local result = mysql_query( connection, str ) if result then mysql_free_result( result ) return true end return false, mysql_error( connection ) end function free_result( result ) if results[ result ] then mysql_free_result( results[ result ].r ) results[ result ] = nil end end function query_assoc( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local t = { } local result, error = query( str, ... ) if result then for result, row in mysql_rows_assoc( results[ result ].r ) do local num = #t + 1 t[ num ] = { } for key, value in pairs( row ) do if value ~= null then t[ num ][ key ] = tonumber( value ) or value end end end free_result( result ) return t end return false, error end function query_assoc_single( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local t = { } local result, error = query( str, ... ) if result then local row = mysql_fetch_assoc( results[ result ].r ) if row then for key, value in pairs( row ) do if value ~= null then t[ key ] = tonumber( value ) or value end end free_result( result ) return t end free_result( result ) return false end return false, error end function query_insertid( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local result, error = query( str, ... ) if result then local id = mysql_insert_id( connection ) free_result( result ) return id end return false, error end function query_affected_rows( str, ... ) if sourceResource == getResourceFromName( "runcode" ) then return false end local result, error = query( str, ... ) if result then local rows = mysql_affected_rows( connection ) free_result( result ) return rows end return false, error end Link to comment
TwiX! Posted September 6, 2012 Share Posted September 6, 2012 1)you need only start sql if user == "root" then local user = get( "user" ) or "root" -- username Check it maybe your user isn't root. 2)Put you resource in mtaserver.conf <resource src="sql" startup="1" protected="0" /> Link to comment
iFoReX Posted September 6, 2012 Author Share Posted September 6, 2012 Doesnt work :// Link to comment
TwiX! Posted September 7, 2012 Share Posted September 7, 2012 any errors in debugsctring 3? you need start sql resource you need activate the console Link to comment
myonlake Posted September 7, 2012 Share Posted September 7, 2012 Dude, you don't have the MySQL module. Get it from the wiki. Place in your modules folder and deathmatch folder and make sure your mtaserver.conf includes the file. http://multitheftauto-modules.googlecod ... _mysql.dll Link to comment
TwiX! Posted September 7, 2012 Share Posted September 7, 2012 Dude, you don't have the MySQL module. Get it from the wiki.Place in your modules folder and deathmatch folder and make sure your mtaserver.conf includes the file. http://multitheftauto-modules.googlecod ... _mysql.dll I just forgot about it, and thought that he has it Link to comment
iFoReX Posted September 8, 2012 Author Share Posted September 8, 2012 I already have this modules, and I will see the mtaserver.conf Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now