Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dev01-cls
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zero
dev01-cls
Commits
bd603481
Commit
bd603481
authored
Aug 08, 2025
by
zero
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
91d59403
Pipeline
#41
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
0 deletions
+82
-0
sh_net.lua
sh_net.lua
+82
-0
No files found.
sh_net.lua
0 → 100644
View file @
bd603481
-- Net messages para el plugin HogwartsRP Clases
-- Maneja la comunicación cliente-servidor para crear y responder tests.
if
SERVER
then
util
.
AddNetworkString
(
"HogwartsRP_CrearTestUI"
)
util
.
AddNetworkString
(
"HogwartsRP_GuardarTest"
)
util
.
AddNetworkString
(
"HogwartsRP_IniciarTest"
)
util
.
AddNetworkString
(
"HogwartsRP_EnviarRespuestas"
)
net
.
Receive
(
"HogwartsRP_GuardarTest"
,
function
(
len
,
client
)
local
CONFIG
=
ix
.
clases
.
CONFIG
local
hechizo
=
net
.
ReadString
()
local
experiencia
=
net
.
ReadUInt
(
16
)
local
clase
=
net
.
ReadString
()
local
preguntas
=
net
.
ReadTable
()
local
char
=
client
:
GetCharacter
()
if
char
:
GetFaction
()
!
=
ix
.
faction
.
Get
(
CONFIG
.
FACTION_PROFESOR
).
uniqueID
then
client
:
Notify
(
"¡No tienes permiso para crear tests!"
)
return
end
local
testID
=
os.time
()
ix
.
tests
[
testID
]
=
{
hechizo
=
hechizo
,
experiencia
=
experiencia
,
clase
=
clase
,
creador
=
client
,
preguntas
=
preguntas
,
estudiantes
=
{}
}
if
ix
.
config
.
Get
(
"HogwartsRP_TestDuration"
)
>
0
then
timer
.
Simple
(
ix
.
config
.
Get
(
"HogwartsRP_TestDuration"
),
function
()
ix
.
tests
[
testID
]
=
nil
end
)
end
client
:
Notify
(
"Test guardado con ID: "
..
testID
)
end
)
net
.
Receive
(
"HogwartsRP_EnviarRespuestas"
,
function
(
len
,
client
)
local
CONFIG
=
ix
.
clases
.
CONFIG
local
testID
=
net
.
ReadUInt
(
32
)
local
respuestas
=
net
.
ReadTable
()
local
test
=
ix
.
tests
[
testID
]
if
not
test
or
not
test
.
estudiantes
[
client
]
then
client
:
Notify
(
"¡Error: Test no válido!"
)
return
end
local
requiredScore
=
ix
.
config
.
Get
(
"HogwartsRP_RequiredScore"
)
local
puntaje
=
0
for
i
,
respuesta
in
ipairs
(
respuestas
)
do
if
respuesta
==
test
.
preguntas
[
i
].
respuestaCorrecta
then
puntaje
=
puntaje
+
10
end
end
test
.
estudiantes
[
client
].
puntaje
=
puntaje
local
char
=
client
:
GetCharacter
()
local
clasesCompletadas
=
char
:
GetData
(
"clasesCompletadas"
,
{})
clasesCompletadas
[
testID
]
=
true
char
:
SetData
(
"clasesCompletadas"
,
clasesCompletadas
)
if
puntaje
>=
requiredScore
then
char
:
GiveExperience
(
test
.
experiencia
)
client
:
Notify
(
"¡Aprobaste el test! Ganaste "
..
test
.
experiencia
..
" EXP."
)
RegisterHechizoItem
(
test
)
-- Registrar y añadir el ítem del hechizo
char
:
GetInventory
():
Add
(
CONFIG
.
ITEM_PREFIX
..
string.lower
(
test
.
hechizo
))
local
hechizosAprendidos
=
char
:
GetData
(
"hechizosAprendidos"
,
{})
hechizosAprendidos
[
test
.
hechizo
]
=
true
char
:
SetData
(
"hechizosAprendidos"
,
hechizosAprendidos
)
else
client
:
Notify
(
"No aprobaste el test. ¡Estudia más, joven mago!"
)
end
test
.
estudiantes
[
client
]
=
nil
end
)
end
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment