Jump to content

Problema al empezar a scriptear


KaNaRi0

Recommended Posts

Posted

Hola, empezé a aprender un poco de LUA, estoy aprendiendo desde la Wiki, no entiendo que pasa, pero en la Wiki, cuando me pide que ponga en script.lua el código:

function manejadorDeInicio() 
    local x = 1959.55 
    local y = -1714.46 
    local z = 10 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    outputChatBox("Bienvenido a Mi Servidor", source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) 

me aparece un error al uniciar el Gamemode, aquí mi LOG:

===========================================================

= Multi Theft Auto: San Andreas v1.3

===========================================================

= Server name : Default MTA Server

= Server IP address:

= Server port : 22003

=

= Log file : .. 1.3/server/mods/deathmatch/logs/server.log

= Maximum players : 32

= HTTP port : 22005

= Voice Chat : Disabled

===========================================================

[2012-02-20 23:32:19] Resources: 186 loaded, 0 failed

[2012-02-20 23:32:19] Querying game-monitor.com master server... success!

[2012-02-20 23:32:20] Querying backup master server... success!

[2012-02-20 23:32:20] Starting resources..................

[2012-02-20 23:32:21] Server started and is ready to accept connections!

[2012-02-20 23:32:21] Type 'help' for a list of commands.

[2012-02-20 23:32:35] Stopping play

[2012-02-20 23:32:36] Stopping freeroam

[2012-02-20 23:32:36] Starting myserver

[2012-02-20 23:32:36] WARNING: myserver\script.lua:10: Bad argument @ 'addEventHandler' [Expected function at argument 3, got nil]

[2012-02-20 23:32:36] Gamemode 'Mi Servidor' started by Console.

[2012-02-20 23:32:36] start: Resource 'myserver' started

Saludos,

Posted

Eso es porque cambiaste el nombre de la funcion pero no en el event handler.

function manejadorDeInicio() 
    local x = 1959.55 
    local y = -1714.46 
    local z = 10 
    spawnPlayer(source, x, y, z) 
    fadeCamera(source, true) 
    setCameraTarget(source, source) 
    outputChatBox("Bienvenido a Mi Servidor", source) 
end 
addEventHandler("onPlayerJoin", getRootElement(), manejadorDeInicio) -- Aca. 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Nuevo problema:

Código (es supuestamente un comando jaja):

function crearVehículoParaJugador(elJugador, nombreDelComando, modeloDeVehículo) 
    local x,y,z = getElementPosition(elJugador) 
    x = x + 5 
    local vehículoCreado = createVehicle(tonumber(modeloDeVehículo),x,y,z) 
    if (vehículoCreado == false) then 
    outputChatBox("Error al crear vehículo.",elJugador) 
    end 
end 
  
  
addCommandHandler("crearvehiculo", crearVehículoParaJugador) 

El error no se como explicarlo claramente pero aquí les dejo como me aparece en el LOG:

SCRIPT ERROR: myserver\script.lua:21: '(' expected near 'Ã' 
WARNING: Loading script failed: myserver\script.lua:21: '(' expected near 'Ã' 

Gracias!

Posted

Perdona, el post este es mio.

PD. Arriba tengo un código con él:

Prueba:

function manejadorDeInicio()

local x = 1959.55

local y = -1714.46

local z = 10

spawnPlayer(source, x, y, z)

fadeCamera(source, true)

setCameraTarget(source, source)

outputChatBox("Bienvenido a Mi Servidor", source)

end

addEventHandler("onPlayerJoin", getRootElement(), manejadorDeInicio) -- Aca.

Posted

El problema son los acentos, Lua no los soporta.

function crearVehiculoParaJugador(elJugador, nombreDelComando, modeloDeVehiculo) 
    local x,y,z = getElementPosition(elJugador) 
    x = x + 5 
    local vehiculoCreado = createVehicle(tonumber(modeloDeVehiculo),x,y,z) 
    if (vehiculoCreado == false) then 
        outputChatBox("Error al crear vehículo.",elJugador) 
    end 
end  
addCommandHandler("crearvehiculo", crearVehiculoParaJugador) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Era cierto, muchas gracias eran las tildes.

Para ponerle un color al texto éste que debo hacer:

outputChatBox("Error al crear vehículo.",elJugador)

Posted
function crearVehiculoParaJugador(elJugador, nombreDelComando, modeloDeVehiculo) 
    local x,y,z = getElementPosition(elJugador) 
    x = x + 5 
    local vehiculoCreado = createVehicle(tonumber(modeloDeVehiculo),x,y,z) 
    if (vehiculoCreado == false) then 
        outputChatBox("Error al crear vehículo.",elJugador,255,0,0) -- Color rojo = 255, 0, 0. 
    end 
end 
addCommandHandler("crearvehiculo", crearVehiculoParaJugador) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Solo usa:

getElementPosition 

para obtener la posicion del jugador.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Aprovecho para solucionar mis dos últimas dudas para rematar el server:

Me refiero a las coordenadas para cuando empieze a jugar osea al iniciar el servidor, para empezar en las coordenadas que yo quiera.

La otra duda es poner varios mapas de DD, DM... y que se pongan al azar con todos los mapas que ponga, (o en orden da igual). Gracias!

Posted
Aprovecho para solucionar mis dos últimas dudas para rematar el server:

Me refiero a las coordenadas para cuando empieze a jugar osea al iniciar el servidor, para empezar en las coordenadas que yo quiera.

La otra duda es poner varios mapas de DD, DM... y que se pongan al azar con todos los mapas que ponga, (o en orden da igual). Gracias!

setElementPosition(elJugador,x,y,z) 

Y del otro lado, no entendi bien lo que preguntastes, capaz castillo lo sabe xD.

WRS( World Racing Server) [server] = 8%

Posted

Ah, creo que ya te entendi.

Usa este script para obtener las coordenadas del jugador:

addCommandHandler("getpos", 
    function (thePlayer) 
        local x, y, z = getElementPosition(thePlayer) 
        outputChatBox(x ..", ".. y ..", ".. z) 
    end 
) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
Pero como cogo la x y z...

Es facilisimo.... vas con tu personaje al lugar donde queres que spawnee, y luego entras al admin Panel..Ahi va a aparecer el X,Y,Z.

Saludos.

WRS( World Racing Server) [server] = 8%

Posted
mmm.. probe eso del chatbox XYZ pero 1 problem necesito q sea client pero solo me funciona serverside D: quiero que solo el player que puso /getpos obtenga sus posisiones

Bueno si sabes "scriptear" , deberias saber hacer eso no?

function coordenadas(cmd) 
  
local x,y,z = getElementPosition(localPlayer) 
  
outputChatBox("Te encuentras en : "..x..","..y..","..z..".") 
end 
addCommandHandler("getpos",coordenadas) 
  

Sino no anda soy malo

WRS( World Racing Server) [server] = 8%

  • Recently Browsing   0 members

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