Jump to content

[Ayuda]


Arsilex

Recommended Posts

Hola tuve un problema al añadir un numero a la lista de contactos

es decir copio el script y tal y es que no llama a los que tiene que llamar miren

Si alguen puede ayudarme les estaria muy agradecido

el fallo es al llamar al numero 911

--[[ 
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 .
]]
 
addEventHandler( "onResourceStart", resourceRoot,
    function( )
        if not exports.sql:create_table( 'phones',
            {
                { name = 'phoneNumber', type = 'int(10) unsigned', primary_key = true, auto_increment = 100000 },
            } ) then cancelEvent( ) return end
    end
)
 
-- we need to export a function to generate a new (unused) phone number, really
function createPhone( number )
    if not number then
        number = exports.sql:query_insertid( "INSERT INTO phones VALUES ()" );
    else
        -- we create a row for the one that didn't exist yet but where we have the number for.
        local highestNumber = exports.sql:query_assoc_single( "SELECT MAX(phoneNumber) AS max FROM phones" )
        if highestNumber then
            if highestNumber.max == nil or number == highestNumber.max + 1 then
                -- no current phones OR the new phone number is the new max.
                return createPhone( )
            elseif number < highestNumber.max then
                -- we have a phone number that's below the maximum
                if not exports.sql:query_free( "INSERT INTO phones (phoneNumber) VALUES (" .. number .. ")" ) then
                     -- if this fails, the phone number does exist
                    return false
                end
            else
                -- number is too high, ignore
                return false
            end
        else
            return createPhone( )
        end
    end
    return number -- we don't want to return the MySQL error if that failed
end
 
--
 
local function findFromPhoneBook( number, name )
    if name:lower( ) == "cab" or name:lower( ) == "taxi" then
        return 222
    end
    if name:lower( ) == "police LS" or name:lower( ) == "police ranger" then
        return 911
    end
    -- TODO: this should once in near future return the number associated to a certain name in the phone book - implies we have a phone book
    return false
end
 
local function findInPhoneBook( number, otherNumber )
    if otherNumber == 222 then
        return "Cab"
    end
    if otherNumber == 911 then
        return "police"
    end
    -- TODO: this should once in near future return the name of the phonebook entry assigned to that number - implies we have a phone book
    return false
end
 
--
 
local p = { }
 
--[[
Quick Guide
-----------
    type        effect
   
    function    executes the function, uses the first return value to determinate whetever to continue the call (true) or not (false),
                all return values beyond that are messages shown to the player.
                parameters for this are the player who calls, his phone number and the past input of this call.
    bool(true)  waits for the player input (/p)
    text        Show that message to the player
 
]]
 
local function getTaxiDrivers( )
    if getResourceFromName( "job-taxi" ) and getResourceState( getResourceFromName( "job-taxi" ) ) then
        return exports["job-taxi"]:getDrivers( ) or { }
    end
    return { }
end
 
local function getPoliceDrivers( )
    if getResourceFromName( "factions" ) and getResourceState( getResourceFromName( "factions" ) ) then
        return exports.factions:isPlayerInFaction ( thePlayer, 1)
    end
    return { }
end
 
local services =
{
    [222] =
    {
        function( player, phoneNumber, input )
            local drivers = getTaxiDrivers( )
            if #drivers > 0 then
                return true, "Operadora de Dillimore: Hola por favor ponga su localizaciones para ir a recojerle."
            else
                return false, "Operadora de Dillimore: En este momento no hay taxi disponible llame luego!"
            end 
        end,
        true,
        function( player, phoneNumber, input )
            local drivers = getTaxiDrivers( )
            if #drivers > 0 then
                for key, value in ipairs( drivers ) do
                    exports.chat:me( value, "Recive un SMS." )
                    outputChatBox( "SMS de ((" .. getPlayerName( player ):gsub( "_", " " ) .. ")) DM Taxi: Numero - Teléfono #" .. phoneNumber .. " - Localizacion: " .. input[1], value, 130, 255, 130 )
                    triggerClientEvent( value, "gui:hint", value, "Su trabajo: Conductor de Taxi - nueva tarifa", "Aguen necesita un taxi:\nPhone: #" .. phoneNumber .. " (( " .. getPlayerName( player ):gsub( "_", " " ) .. " ))\nLocalizacion: " .. input[1] )
                end
                return false, "SF Cab Operator says: We've dispatched a cab to your location. It should arrive soon!"
            else
                return false, "SF Cab Operator says: There are currently no Taxis available. Call later!"
            end
        end
    }
}
local services =
{
    [911] =
    {
        function( player, phoneNumber, input )
            local drivers = getPoliceDrivers( )
            if #drivers > 0 then
                return true, "Policia de Dillimore: Un agende ya esta en camino quedese en el lugar de donde llama."
            else
                return false, "Policia de Dillimore: En este momento no hay agentes disponible llame luego!"
            end 
        end,
        true,
        function( player, phoneNumber, input )
            local drivers = getPoliceDrivers( )
            if #drivers > 0 then
                for key, value in ipairs( drivers ) do
                    exports.chat:me( value, "Recive un SMS." )
                    outputChatBox( "SMS de ((" .. getPlayerName( player ):gsub( "_", " " ) .. ")) DM Taxi: Numero - Teléfono #" .. phoneNumber .. " - Localizacion: " .. input[1], value, 130, 255, 130 )
                    triggerClientEvent( value, "gui:hint", value, "Su trabajo: Conductor de Taxi - nueva tarifa", "Aguen necesita un taxi:\nPhone: #" .. phoneNumber .. " (( " .. getPlayerName( player ):gsub( "_", " " ) .. " ))\nLocalizacion: " .. input[1] )
                end
                return false, "SF Cab Operator says: We've dispatched a cab to your location. It should arrive soon!"
            else
                return false, "SF Cab Operator says: There are currently no Taxis available. Call later!"
            end
        end
    }
}
 
local function advanceService( player, text )
    local call = p[ player ]
    if call.service then
        local state = services[ call.service ][ call.serviceState ]
        if state then
            if text then
                if type( state ) == "boolean" then
                    table.insert( call.input, text )
                    call.serviceState = call.serviceState + 1
                    advanceService( player )
                end
            else
                if type( state ) == "function" then
                    local ret = { state( player, call.number, call.input ) }
                    if #ret >= 2 then
                        for i = 2, #ret do
                            outputChatBox( ret[ i ], player, 180, 255, 180 )
                        end
                    end
                    if ( #ret >= 1 and ret[1] == false ) or #ret == 0 then
                        outputChatBox( "Ellos colgaron.", player, 180, 255, 180 )
                        p[ player ] = nil
                        return
                    end
                elseif type( state ) == "string" then
                    outputChatBox( state, player, 180, 255, 180 )
                elseif type( state ) == "boolean" then
                    return -- we need to stop here to prevent us from getting too far.
                end
                call.serviceState = call.serviceState + 1
                advanceService( player )
            end
        else
            outputChatBox( "Ellos colgaron.", player, 180, 255, 180 )
            p[ player ] = nil
            return
        end
    end
end
 
--
 
addCommandHandler( "call",
    function( player, commandName, ownNumber, otherNumber )
        if exports.players:isLoggedIn( player ) then
            if tonumber( ownNumber ) and otherNumber and exports.items:has( player, 7, tonumber( ownNumber ) ) then
                ownNumber = tonumber( ownNumber )
            else
                local has, key, item = exports.items:has( player, 7 )
                if has then
                    otherNumber = ownNumber
                    ownNumber = item.value
                else
                    outputChatBox( "(( No tienes telefono. ))", player, 255, 0, 0 )
                end
            end
           
            local otherNumber = tonumber( otherNumber ) or findFromPhoneBook( ownNumber, otherNumber )
            if ownNumber and otherNumber then
                if ownNumber == otherNumber then
                    outputChatBox( "No puedes llamarte a ti mismo.", player, 255, 0, 0 )
                else
                    local ownPhone = { exports.items:has( player, 7, ownNumber ) }
                    exports.chat:me( player, "Saca su " .. ( ownPhone[3].name or "telfono" ) .. " y aprieta un par de botones en él." )
                   
                    if services[ otherNumber ] then
                        p[ player ] = { other = false, service = otherNumber, number = ownNumber, state = 2, input = { }, serviceState = 1 }
                        advanceService( player )
                        return
                    else
                        for key, value in ipairs( getElementsByType( "player" ) ) do
                            if value ~= player then
                                local otherPhone = { has( value, 7, otherNumber ) }
                                if otherPhone and otherPhone[1] then
                                    p[ player ] = { other = value, number = ownNumber, state = 0 }
                                    p[ value ] = { other = player, number = otherNumber, state = 0 }
                               
                                    exports.chat:me( value, "'s " .. ( otherPhone[3].name or "phone" ) .. " esta sonando." )
                                    outputChatBox( "El teléfono muestra el numero " .. ( findInPhoneBook( otherNumber, ownNumber ) or ( "#" .. ownNumber ) ) .. ". (( /responder para coger. ))", value, 180, 255, 180 )
                                    return
                                end
                            end
                        end
                    end
                    -- TODO: if the phone is a dropped item, a menu for picking up/hanging up would be nice. and an actual check if it is
                   
Link to comment

pos mira por alli pone

local function findFromPhoneBook( number, name )

if name:lower( ) == "cab" or name:lower( ) == "taxi" then

return 222

end

if name:lower( ) == "police LS" or name:lower( ) == "police ranger" then

return 911

end

y despues sigue lo demas lo que pasa es que es para llamadas yo por ejemplo llamo a el 222 y el mensaje le llega al taxista pero si llamo al policia 911 no le llega :S

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...