diff --git a/README.md b/README.md index 0126cff..840a7de 100644 --- a/README.md +++ b/README.md @@ -85,10 +85,14 @@ de MTA-Paradise SERÁ IGNORADO! - Si al abrir el servidor se cierra solo, el problema será 99% relacionado con MySQL. Comprueba que has seguido todos los pasos, y que estás usando el módulo mta_mysql(.dll en Windows y .so en Linux). Comprueba que dicho módulo esté en la carpeta correcta (en la que indican en la Wiki de MTA del enlace anterior) y, por último, comprueba que las credenciales en resources/sql/mysql.lua sean las correctas. - Es muy interesante revisar el archivo mods\deathmatch\logs\server.log en caso de que haya errores. Lo mejor es borrar el fichero, abrir el servidor y cerrarlo (o esperar a que se cierre solo) y, después, revisar este archivo. + +- Si has descargado este GM con anterioridad y no podías ni crear interiores ni crear vehículos, decirte que esos fallos han sido **solucionados.** Descarga la última versión. ## Integración con foro SMF - Este GM es compatible con la integración de un foro SMF versión 2.1. Para ello, habrá que modificar la resource 'sqlforo' con las credenciales de la base de datos del foro y establecer la variable enabled en true (línea 22, fichero mysql.lua de la resource sqlforo y sqllogin). + +- También habrá que establecer la variable enabled en true (línea 18, fichero foro.lua de la resource foro). - A partir de aquí, la resource 'foro' se encargará de ofrecer al usuario vincular su usuario IG con su cuenta de foro. diff --git a/db/server.sql b/db/server.sql index a837a25..72cd733 100644 --- a/db/server.sql +++ b/db/server.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Servidor: 127.0.0.1 --- Tiempo de generación: 08-06-2020 a las 16:14:31 +-- Tiempo de generación: 19-12-2020 a las 19:22:00 -- Versión del servidor: 10.4.11-MariaDB -- Versión de PHP: 7.4.6 @@ -18,7 +18,7 @@ SET time_zone = "+00:00"; /*!40101 SET NAMES utf8mb4 */; -- --- Base de datos: `server` +-- Base de datos: `server2` -- -- -------------------------------------------------------- @@ -452,17 +452,17 @@ CREATE TABLE `interiors` ( `outsideX` float NOT NULL, `outsideY` float NOT NULL, `outsideZ` float NOT NULL, - `outsideVehRX` float NOT NULL, - `outsideVehRY` float NOT NULL, - `outsideVehRZ` float NOT NULL, + `outsideVehRX` float DEFAULT NULL, + `outsideVehRY` float DEFAULT NULL, + `outsideVehRZ` float DEFAULT NULL, `outsideInterior` tinyint(3) UNSIGNED NOT NULL, `outsideDimension` int(10) UNSIGNED NOT NULL, `insideX` float NOT NULL, `insideY` float NOT NULL, `insideZ` float NOT NULL, - `insideVehRX` float NOT NULL, - `insideVehRY` float NOT NULL, - `insideVehRZ` float NOT NULL, + `insideVehRX` float DEFAULT NULL, + `insideVehRY` float DEFAULT NULL, + `insideVehRZ` float DEFAULT NULL, `insideInterior` tinyint(3) UNSIGNED NOT NULL, `interiorName` varchar(255) CHARACTER SET latin1 NOT NULL, `interiorType` tinyint(3) UNSIGNED NOT NULL, @@ -470,13 +470,13 @@ CREATE TABLE `interiors` ( `interiorPriceCompra` int(11) NOT NULL DEFAULT 0, `characterID` int(10) UNSIGNED NOT NULL DEFAULT 0, `locked` tinyint(3) NOT NULL DEFAULT 0, - `dropoffX` float NOT NULL, - `dropoffY` float NOT NULL, - `dropoffZ` float NOT NULL, + `dropoffX` float DEFAULT NULL, + `dropoffY` float DEFAULT NULL, + `dropoffZ` float DEFAULT NULL, `precintado` int(10) UNSIGNED NOT NULL DEFAULT 0, `idasociado` int(10) UNSIGNED NOT NULL DEFAULT 0, `alarma` int(10) UNSIGNED NOT NULL DEFAULT 0, - `camaras` int(11) NOT NULL, + `camaras` int(11) NOT NULL DEFAULT 0, `recaudacion` int(10) UNSIGNED NOT NULL DEFAULT 0, `productos` int(10) UNSIGNED NOT NULL DEFAULT 0 ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -859,7 +859,7 @@ CREATE TABLE `vehicles` ( `fuel` float UNSIGNED NOT NULL DEFAULT 100, `pinturas` int(11) NOT NULL DEFAULT 3, `tunning` text CHARACTER SET latin1 DEFAULT NULL, - `neon` int(11) NOT NULL, + `neon` int(11) DEFAULT NULL, `seguro` int(11) NOT NULL DEFAULT 0, `km` int(11) NOT NULL DEFAULT 0, `fasemotor` int(11) NOT NULL DEFAULT 0, diff --git a/resources/3dtext/3dtext.lua b/resources/3dtext/3dtext.lua index 390b128..0645e0c 100644 --- a/resources/3dtext/3dtext.lua +++ b/resources/3dtext/3dtext.lua @@ -106,23 +106,21 @@ addCommandHandler( "nearbytexts", function createTableAndSend3DText() for k, v in ipairs(getElementsByType("player")) do - if exports.players:isLoggedIn(v) then - local x, y, z = getElementPosition( v ) - local dimension = getElementDimension( v ) - local interior = getElementInterior( v ) - local elementsToSend = {} - for key, element in pairs( getElementsByType( "3dtext", resourceRoot ) ) do - if getElementDimension( element ) == dimension and getElementInterior( element ) == interior then - local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( element ) ) - if distance <= 15 then - table.insert(elementsToSend, element) - end + local x, y, z = getElementPosition( v ) + local dimension = getElementDimension( v ) + local interior = getElementInterior( v ) + local elementsToSend = {} + for key, element in pairs( getElementsByType( "3dtext", resourceRoot ) ) do + if getElementDimension( element ) == dimension and getElementInterior( element ) == interior then + local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( element ) ) + if distance <= 15 then + table.insert(elementsToSend, element) end end - if #elementsToSend > 0 then - triggerClientEvent(v, "onSendTablePickup3DText", v, elementsToSend) - end + end + if #elementsToSend > 0 then + triggerClientEvent(v, "onSendTablePickup3DText", v, elementsToSend) end end end -setTimer(createTableAndSend3DText, 1500, 0) \ No newline at end of file +setTimer(createTableAndSend3DText, 2500, 0) \ No newline at end of file diff --git a/resources/foro/foro.lua b/resources/foro/foro.lua index 0954d3e..d864674 100644 --- a/resources/foro/foro.lua +++ b/resources/foro/foro.lua @@ -14,8 +14,11 @@ 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 enabled = false -- Poner en true si se utilizará el sistema de vinculación y sincronización con un foro SMF. function checkUsernameForum () + if enabled == false then return end local userID = exports.players:getUserID(source) local sql = exports.sqllogin:query_assoc_single("SELECT userIDForo FROM usuarios WHERE estado = 1 AND userIDIG = " .. tonumber(userID)) if sql then @@ -88,6 +91,7 @@ function tieneFaccionAsociada(groupID) end function actualizarPermisosEnForo(userID) + if enabled == false then return end if not userID then return false end local userIDForo = getUserIDForo(userID) if not userIDForo then return false end diff --git a/resources/interiors/interiors.lua b/resources/interiors/interiors.lua index e50ce7e..b0657ad 100644 --- a/resources/interiors/interiors.lua +++ b/resources/interiors/interiors.lua @@ -1350,26 +1350,24 @@ addCommandHandler("comprarint", ejecutarCompra) function createTableAndSendInts() for k, v in ipairs(getElementsByType("player")) do - if exports.players:isLoggedIn(v) then - local x, y, z = getElementPosition( v ) - local dimension = getElementDimension( v ) - local interior = getElementInterior( v ) - local elementsToSend = {} - for key, element in pairs( getElementsByType( "colshape", resourceRoot ) ) do - if getElementDimension( element ) == dimension and getElementInterior( element ) == interior then - local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( element ) ) - if distance <= 20 then - table.insert(elementsToSend, element) - end + local x, y, z = getElementPosition( v ) + local dimension = getElementDimension( v ) + local interior = getElementInterior( v ) + local elementsToSend = {} + for key, element in pairs( getElementsByType( "colshape", resourceRoot ) ) do + if getElementDimension( element ) == dimension and getElementInterior( element ) == interior then + local distance = getDistanceBetweenPoints3D( x, y, z, getElementPosition( element ) ) + if distance <= 20 then + table.insert(elementsToSend, element) end end - if #elementsToSend > 0 then - triggerClientEvent(v, "onSendTablePickupInts", v, elementsToSend) - end + end + if #elementsToSend > 0 then + triggerClientEvent(v, "onSendTablePickupInts", v, elementsToSend) end end end -setTimer(createTableAndSendInts, 1500, 0) +setTimer(createTableAndSendInts, 2500, 0) function isInteriorAlquiler(interiorID) local interior = interiors[ interiorID ] diff --git a/resources/players/main.lua b/resources/players/main.lua index b020421..8586621 100644 --- a/resources/players/main.lua +++ b/resources/players/main.lua @@ -509,10 +509,14 @@ local function savePlayer( player ) local gordura = tonumber(getElementData(player, "gordura")) local musculatura = tonumber(getElementData(player, "musculatura")) local tpd = tonumber(getElementData(player, "tpd")) + -- Evitar valores negativos que provocan errores al guardarse. + if sed < 0 then sed = 0 end + if cansancio < 0 then cansancio = 0 end + if hambre < 0 then hambre = 0 end + if gordura < 0 then gordura = 0 end + if musculatura < 0 then musculatura = 0 end + if tpd < 0 then tpd = 0 end local sql, error = exports.sql:query_free( "UPDATE characters SET musculatura = " ..musculatura.. ", gordura = " .. gordura .. ", cansancio = " .. cansancio .. ", sed = " .. sed .. ", hambre = " .. hambre .. ", tpd = " .. tpd .. ", x = " .. x .. ", y = " .. y .. ", z = " .. z .. ", dimension = " .. dimension .. ", interior = " .. interior .. ", rotation = " .. getPedRotation( player ) .. ", health = " .. math.floor( getElementHealth( player ) ) .. ", armor = " .. math.floor( getPedArmor( player ) ) .. ", weapons = " .. getWeaponString( player ) .. ", lastLogin = NOW() WHERE characterID = " .. tonumber( getCharacterID( player ) ) ) - if not sql or error then - savePlayer( player ) - end end end end diff --git a/resources/players/main_c.lua.old b/resources/players/main_c.lua.old deleted file mode 100644 index c1f70e6..0000000 --- a/resources/players/main_c.lua.old +++ /dev/null @@ -1,197 +0,0 @@ ---[[ -Copyright (c) 2010 MTA: Paradise -Copyright (c) 2020 DownTown RolePlay -Copyright (c) 2018 DownTown Roleplay - -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 localPlayer = getLocalPlayer( ) -local loggedIn = false -local screenX, screenY = guiGetScreenSize( ) -local characters = false -local languages = false -local localIP = nil -setFarClipDistance(6000) - -addEvent( getResourceName( resource ) .. ":spawnscreen", true ) -addEventHandler( getResourceName( resource ) .. ":spawnscreen", localPlayer, - function( ) - setTimer( - function( ) - if not characters then - setFarClipDistance(2500) - triggerServerEvent("onRequestLoginPanel",getLocalPlayer()) - end - end, 300, 1 - ) - - fadeCamera( true, 1 ) - showChat( false ) - showPlayerHudComponent( "radar", false ) - showPlayerHudComponent( "area_name", false ) - loggedIn = false - characters = false - end -) - -addEventHandler( "onClientResourceStart", getResourceRootElement( ), - function( ) - showPlayerHudComponent( "area_name", false ) - end -) --- - -addCommandHandler( "changechar", - function( ) - if loggedIn then - local window, forced = exports.gui:getShowing( ) - if not forced then - if window == 'characters' then - exports.gui:hide( ) - else - if getElementData(getLocalPlayer(), "muerto") == true or getElementData(getLocalPlayer(), "tazed") == true or getElementData(getLocalPlayer(), "accidente") == true then - outputChatBox("¡Te recordamos que NO puedes evadir rol!", 255, 0, 0) - triggerServerEvent("onMensajeStaff", getLocalPlayer(), "¡ALERTA URGENTE! POSIBLE EVASIÓN DE ROL DE ["..getElementData(getLocalPlayer(), "playerid").."] "..getPlayerName(getLocalPlayer()):gsub("_", " ").."!", 255, 0, 0) - else - exports.gui:show( 'characters', false, false, true ) - end - end - end - end - end -) -bindKey( "pause", "down", "changechar" ) - -function selectCharacter( id, name ) - if loggedIn and (getElementData(getLocalPlayer(), "muerto") == true or getElementData(getLocalPlayer(), "tazed") == true or getElementData(getLocalPlayer(), "accidente") == true) then - outputChatBox("¡Te recordamos que NO puedes evadir rol!", 255, 0, 0) - triggerServerEvent("onMensajeStaff", getLocalPlayer(), "¡ALERTA URGENTE! POSIBLE EVASIÓN DE ROL DE ["..getElementData(getLocalPlayer(), "playerid").."] "..getPlayerName(getLocalPlayer()):gsub("_", " ").."!", 255, 0, 0) - else - if id == -1 then - -- new character - exports.gui:show( 'create_character', true ) - elseif id == -2 then - -- logout - exports.gui:hide( ) - triggerServerEvent( getResourceName( resource ) .. ":logout", localPlayer ) - elseif id == -3 then - -- PJ Ckeado - showChat(true) - outputChatBox("Este PJ está bloqueado por un CK. Acude a foro para más información.", 255, 0, 0) - elseif loggedIn and name == getPlayerName( localPlayer ):gsub( "_", " " ) then - exports.gui:hide( ) - else - exports.gui:hide( ) - triggerServerEvent( getResourceName( resource ) .. ":spawn", localPlayer, id ) - end - end -end - -addEvent( getResourceName( resource ) .. ":characters", true ) -addEventHandler( getResourceName( resource ) .. ":characters", localPlayer, - function( chars, spawn, token, ip ) - triggerEvent("onDestroyLoginPanel", localPlayer) - characters = chars - exports.gui:updateCharacters( chars ) - isSpawnScreen = spawn - if isSpawnScreen then - exports.gui:show( 'characters', true, true, true ) - showChat( false ) - showPlayerHudComponent( "radar", false ) - showPlayerHudComponent( "area_name", false ) - loggedIn = false - end - end -) - -addEventHandler( "onClientResourceStart", root, - function( res ) - if getResourceName( res ) == "players" then - setTimer( - function( ) - if characters then - exports.gui:updateCharacters( characters ) - if not loggedIn then - exports.gui:show( 'characters', true, true, true ) - end - else - triggerServerEvent("onRequestLoginPanel",getLocalPlayer()) - end - - if languages then - exports.gui:updateLanguages( languages ) - end - end, - 150, - 1 - ) - end - end -) - -addEventHandler( "onClientResourceStop", root, - function( res ) - exports[ getResourceName( res ) ] = nil - end -) - -addEvent( getResourceName( resource ) .. ":onSpawn", true ) -addEventHandler( getResourceName( resource ) .. ":onSpawn", localPlayer, - function( langs ) - exports.gui:hide( ) - showChat( true ) - showPlayerHudComponent( "radar", true ) - loggedIn = true - setElementData(localPlayer, "hud", true) - exports.gui:updateCharacters( characters ) - languages = langs - exports.gui:updateLanguages( languages ) - - outputChatBox( "Ahora estás jugando como " .. getPlayerName( localPlayer ):gsub( "_", " " ) .. ".", 0, 255, 0 ) - setFarClipDistance(1500) - triggerEvent("onMostrarPuntosCardinales", localPlayer) - setElementAlpha(localPlayer, 127) - setTimer(setElementAlpha, 4000, 1, localPlayer, 255) - - end -) - -addEvent( getResourceName( resource ) .. ":languages", true ) -addEventHandler( getResourceName( resource ) .. ":languages", localPlayer, - function( langs ) - languages = langs - exports.gui:updateLanguages( languages ) - end -) - -function isLoggedIn( ) - return loggedIn -end - -addEvent( "updateCharacterName", true ) -addEventHandler( "updateCharacterName", localPlayer, - function( id, name ) - if characters then - for key, value in ipairs( characters ) do - if value.characterID == id then - characters[key].characterName = name - exports.gui:updateCharacters( characters ) - return - end - end - end - end -) - diff --git a/resources/vehicles/vehicles.lua b/resources/vehicles/vehicles.lua index 2badb44..4e3f139 100644 --- a/resources/vehicles/vehicles.lua +++ b/resources/vehicles/vehicles.lua @@ -349,7 +349,7 @@ addCommandHandler( { "createvehicle", "makevehicle" }, local c1 = RGB2HEX (r or 255, g or 255, b or 255) local c2 = RGB2HEX (r2 or 255, g2 or 255, b2 or 255) local c3 = RGB2HEX (luz1 or 255, luz2 or 255, luz3 or 255) - local vehicleID, error = exports.sql:query_insertid( "INSERT INTO vehicles (model, posX, posY, posZ, rotX, rotY, rotZ, color1, color2, color3, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, interior, dimension, respawnInterior, respawnDimension) VALUES (" .. table.concat( { model, x, y, z, 0, 0, rz,"'".. c1.."'", "'".. c2.."'", "'".. c3.."'", x, y, z, 0, 0, rz, getElementInterior( player ), getElementDimension( player ), getElementInterior( player ), getElementDimension( player ) }, ", " ) .. ")", getVehiclePlateText( vehicle ) ) + local vehicleID, error = exports.sql:query_insertid("INSERT INTO vehicles (model, posX, posY, posZ, rotX, rotY, rotZ, color1, color2, color3, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, interior, dimension, respawnInterior, respawnDimension, numberplate) VALUES (" .. table.concat( { model, x, y, z, 0, 0, rz,"'".. c1 .."'", "'".. c2 .."'", "'".. c3 .."'", x, y, z, 0, 0, rz, getElementInterior( player ), getElementDimension( player ), getElementInterior( player ), getElementDimension( player ), "'".. getVehiclePlateText( vehicle ) .."'" }, ", " ) .. ")" ) if vehicleID then -- tables for ID -> vehicle and vehicle -> data vehicleIDs[ vehicleID ] = vehicle @@ -397,7 +397,7 @@ function createVehicleFromConce( player, model2 ) local c1 = RGB2HEX (r or 255, g or 255, b or 255) local c2 = RGB2HEX (r2 or 255, g2 or 255, b2 or 255) local c3 = RGB2HEX (luz1 or 255, luz2 or 255, luz3 or 255) - local vehicleID, error = exports.sql:query_insertid( "INSERT INTO vehicles (model, posX, posY, posZ, rotX, rotY, rotZ, color1, color2, color3, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, interior, dimension, respawnInterior, respawnDimension, characterID) VALUES (" .. table.concat( { model, x, y, z, rx, ry, rz, "'" ..c1.."'", "'" ..c2.."'", "'" ..c3.."'", x, y, z, rx, ry, rz, interior, dimension, interior, dimension, characterID }, ", " ) .. ")", getVehiclePlateText( vehicle ) ) + local vehicleID, error = exports.sql:query_insertid("INSERT INTO vehicles (model, posX, posY, posZ, rotX, rotY, rotZ, color1, color2, color3, respawnPosX, respawnPosY, respawnPosZ, respawnRotX, respawnRotY, respawnRotZ, interior, dimension, respawnInterior, respawnDimension, numberplate, characterID) VALUES (" .. table.concat( { model, x, y, z, 0, 0, rz,"'".. c1 .."'", "'".. c2 .."'", "'".. c3 .."'", x, y, z, 0, 0, rz, getElementInterior( player ), getElementDimension( player ), getElementInterior( player ), getElementDimension( player ), "'".. getVehiclePlateText( vehicle ) .."'", characterID }, ", " ) .. ")" ) if vehicleID then local newVehicle = createVehicle( model, x, y, z, rx, ry, rz, getVehiclePlateText( vehicle ) ) setElementFrozen(newVehicle, true)