upd | clearance

This commit is contained in:
Danya H 2024-09-30 19:40:58 +01:00
parent 34dd2172c7
commit 46e55f6667
5 changed files with 29 additions and 23 deletions

View File

@ -5,17 +5,17 @@ function App() {
const [data, setData] = useState('')
useEffect(() => {
fw.event.register('customCefEvent', ([test]) => {
setData(test)
return 'response from cef'
fw.event.register('customCefEvent', async ([test]) => {
setData(p => p + ' ' + test)
return 'from cef'
})
}, [])
return (
<>
<div style={{ width: '100%', color: 'white', textAlign: 'center' }}>
<h1>Hello World!</h1>
<h2>{data}</h2>
</>
</div>
)
}

View File

@ -1,12 +1,14 @@
import { fw } from 'rage-fw-client'
fw.browser.registerBrowser(mp.browsers.new('package://cef/index.html'))
fw.player.registerBrowser(mp.browsers.new('package://cef/index.html'))
fw.event.register('customClientEvent', async ([greetings]) => {
fw.system.log.info(greetings)
fw.event.register('cefReady', async () => {
fw.system.log.info('cefReady')
const data = await fw.player.triggerBrowser('customCefEvent', ['str'])
fw.system.log.info(`CEF RESPONSE: ${data}`)
const responseCef = await fw.player.triggerBrowser('customCefEvent', [
'from client',
])
fw.system.log.info(responseCef)
return 'Hola from client!'
await fw.player.triggerServer('customServerEvent', ['from client'])
})

View File

@ -2,12 +2,17 @@ import { fw } from 'rage-fw-server'
fw.event.register('playerJoin', async ([player]) => {
fw.system.log.info(`Connected: ${player.socialClub}`)
const response = await fw.player.triggerClient(
player,
'customClientEvent',
['Hi from server!'],
)
fw.system.log.info(`Response from client: ${response}`)
})
fw.event.register('customServerEvent', async ([player, msg]) => {
fw.system.log.info(player.socialClub + ' ' + msg)
const resFromCef = await fw.player.triggerBrowser(
player,
'customCefEvent',
['from server'],
)
fw.system.log.info(player.socialClub + ' ' + resFromCef)
return 'from server'
})

View File

@ -1,7 +1,5 @@
declare module 'rage-fw-shared-types' {
export interface RageFW_ICustomClientEvent {
customClientEvent(greetings: string): Promise<string>
}
export interface RageFW_ICustomClientEvent {}
export interface RageFW_ICustomServerEvent {
customServerEvent(greetings: string): string

View File

@ -1,9 +1,10 @@
{
"maxplayers" : 100,
"name" : "RAGE FW Server powered by Entity Seven Group",
"name" : "RageFW Example Server. Powered by Entity Seven Group",
"gamemode" : "freeroam",
"stream-distance" : 300.0,
"announce" : false,
"csharp" : "disabled",
"allow-cef-debugging": true,
"port": 22005
}