Teléfono
Números de teléfono, correos, mensajes de texto y notificaciones del teléfono a través del script de teléfono que tenga el servidor.
Las llamadas de teléfono pasan por ai-core, nunca por los exports propios de un script de teléfono. ai-core reenvía cada llamada al primer script de teléfono en marcha (tgiann-phone, lb-phone, gksphone y los demás de la lista de compatibilidad). Mientras no hay ningún teléfono en marcha, cada llamada responde null o false.
GetPhoneNumber
El número de teléfono de un jugador.
Lado: Servidor · Espera: no · Lib: phone.number
GetPhoneNumber(source: number): string | nulllocal number = exports['ai-core']:GetPhoneNumber(source) -- string o nilParámetros
Prop
Type
Devuelve
string | null: el número tal como lo escribe el script de teléfono. null cuando el jugador no tiene, no hay ningún teléfono en marcha o source no es un número.
Ejemplo
import { onClientCallback, resourceExport } from "@aicore-fivem/lib/server";
import { fail } from "@aicore-fivem/lib/shared";
const core = resourceExport("ai-core");
// Un objeto de tarjeta de visita muestra el número del dueño.
onClientCallback("myscript:myNumber", (source) => {
const number = core.GetPhoneNumber(source);
return number ? { ok: true, number } : fail("NO_PHONE_NUMBER");
});GetSourceByPhone
El jugador conectado que tiene un número de teléfono.
Lado: Servidor · Espera: no · Lib: phone.sourceOf
GetSourceByPhone(number: string): number | nulllocal src = exports['ai-core']:GetSourceByPhone('5551234') -- number o nilParámetros
Prop
Type
Devuelve
number | null: el id de servidor. null cuando el dueño de ese número no está conectado, el número es desconocido, no hay ningún teléfono en marcha o number no es un texto.
Ejemplo
import { notify, resourceExport } from "@aicore-fivem/lib/server";
import { Locale } from "common";
const core = resourceExport("ai-core");
/** A taxi job tells the caller their cab is on the way, if they are online. */
export function cabOnTheWay(callerNumber: string): void {
const caller = core.GetSourceByPhone(callerNumber);
if (caller !== null) notify(caller, Locale("NOTIFY_CAB_COMING"), "info");
}HasPhone
Si un jugador tiene un teléfono (en los scripts de teléfono que necesitan un objeto de teléfono, si lleva uno).
Lado: Servidor · Espera: no · Lib: phone.hasPhone
HasPhone(source: number): booleanlocal has = exports['ai-core']:HasPhone(source)Parámetros
Prop
Type
Devuelve
boolean: true cuando el script de teléfono dice que el jugador tiene teléfono. false cuando no, cuando no hay ningún teléfono en marcha o source no es un número.
Ejemplo
import { onClientCallback, resourceExport } from "@aicore-fivem/lib/server";
import { fail } from "@aicore-fivem/lib/shared";
const core = resourceExport("ai-core");
// Un trabajo que reparte tareas por mensaje de texto necesita un teléfono.
onClientCallback("myscript:startDeliveries", (source) =>
core.HasPhone(source) ? { ok: true } : fail("NEED_PHONE"),
);SendPhoneMail
Envía un correo al teléfono de un jugador.
Lado: Servidor · Espera: no · Lib: phone.mail
SendPhoneMail(to: number | string, mail: PhoneMail): booleanlocal sent = exports['ai-core']:SendPhoneMail(source, { sender = 'LS Customs', subject = 'Invoice', message = '...' })Parámetros
Prop
Type
PhoneMail
Prop
Type
Los textos se muestran tal cual: pasa textos traducidos. Consulta PhoneMail.
Devuelve
boolean: true cuando el script de teléfono aceptó el correo. false cuando el jugador no tiene número, falta subject o message, no hay ningún teléfono en marcha o lo rechazó.
Ejemplo
import { resourceExport } from "@aicore-fivem/lib/server";
import { Locale } from "common";
const core = resourceExport("ai-core");
/** The heist contact mails the location after the job was accepted. */
export function mailHeistLocation(source: number, street: string): void {
core.SendPhoneMail(source, {
sender: Locale("MAIL_CONTACT"),
subject: Locale("MAIL_HEIST_SUBJECT"),
message: Locale("MAIL_HEIST_BODY", street),
});
}SendPhoneMessage
Envía un mensaje de texto desde un número a un jugador o a un número.
Lado: Servidor · Espera: no · Lib: phone.message
SendPhoneMessage(from: string, to: number | string, text: string): booleanlocal sent = exports['ai-core']:SendPhoneMessage('Dispatch', source, 'Your cab is here.')Parámetros
Prop
Type
Devuelve
boolean: true cuando el script de teléfono aceptó el mensaje. false cuando el destinatario no tiene número, from o text no es un texto, no hay ningún teléfono en marcha o lo rechazó.
Ejemplo
import { resourceExport } from "@aicore-fivem/lib/server";
import { Locale } from "common";
const core = resourceExport("ai-core");
/** The next delivery address arrives by text. */
export function textNextStop(source: number, street: string): void {
if (!core.SendPhoneMessage(Locale("SENDER_DISPATCH"), source, Locale("TEXT_NEXT_STOP", street)))
console.log(`player ${source} could not get the text`);
}PhoneNotify
Muestra una notificación en el teléfono de un jugador.
Lado: Servidor · Espera: no · Lib: phone.notify
PhoneNotify(source: number, notification: PhoneNotification): booleanlocal shown = exports['ai-core']:PhoneNotify(source, { title = 'Bank', message = 'Salary paid', app = 'bank' })Parámetros
Prop
Type
PhoneNotification
Prop
Type
Consulta PhoneNotification.
Devuelve
boolean: true cuando el script de teléfono la mostró. false cuando falta title, no hay ningún teléfono en marcha, source no es un número o lo rechazó.
Ejemplo
import { resourceExport } from "@aicore-fivem/lib/server";
import { Locale } from "common";
const core = resourceExport("ai-core");
/** Tells the owner their car was towed. */
export function towedNotice(source: number, plate: string): void {
core.PhoneNotify(source, { title: Locale("PHONE_TOW_TITLE"), message: Locale("PHONE_TOW_TEXT", plate) });
}