Jump to content

Ayuda con este script


Aono

Recommended Posts

Hola, estaba tratando de crear un script para que un admin ponga un comando y aparezca un carro, y luego lo teletransporte adentro del auto, pero no me funciona el script es algo asi:

function funcion( source, commandName) 
Jugador = getLocalPlayer() 
x,y,z = getElementPosition ( Jugador ) 
if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
local carrouno = createVehicle ( 411, x, y, z ) 
warpPlayerIntoVehicle ( Jugador, carrouno ) 
end 
addCommandHandler ( "infernus", funcion) 

tambien me gustaria que al salir el admin del vehiculo este se destruya pero no se como hacer eso

Link to comment
function infernus(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    Object1 = createVeichle(411, x, y, z-1)--- ID del auto  
    outputChatBox("creaste el auto", thePlayer, 0, 250, 0) 
    else(isPedInVehicle(thePlayer)) then 
        local vehicle = getPedOccupiedVehicle(thePlayer) 
        attachElements(Object1, vehicle) 
         
    end 
  end 
addCommandHandler("auto", infernus) 

  
function infernus(thePlayer) 
    if (isElement(Object1)) then 
        destroyElement(Object1) 
        outputChatBox("destruido", thePlayer, 0, 0, 255) 
              
    else 
        outputChatBox("destruido", thePlayer, 250, 0, 0) 
    end 
end 
addCommandHandler("destroy", infernus) 

con eso puedes destruir el auto no lo e probado avísame si funciona o tiene algún error

Edited by Guest
Link to comment
  
function infernus(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    Object1 = createVeichle(411, x, y, z-1)--- ID del auto  
    outputChatBox("creaste el auto", thePlayer, 0, 250, 0) 
    else(isPedInVehicle(thePlayer)) then 
        local vehicle = getPedOccupiedVehicle(thePlayer) 
        attachElements(Object1, vehicle) 
         
    end 
  end 
addCommandHandler("auto", infernus) 
  
function infernus(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    else (isElement(Object1)) then 
     
        destroyElement(Object1) 
        outputChatBox("destruido", thePlayer, 0, 0, 255) 
              
    else 
        outputChatBox("destruido", thePlayer, 250, 0, 0) 
    end 
end 
addCommandHandler("destroy", infernus) 

prueva y decime si te funciono no esta provado aun :cry::cry:

Link to comment
  
function infernus(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    Object1 = createVeichle(411, x, y, z-1)--- ID del auto 
    outputChatBox("creaste el auto", thePlayer, 0, 250, 0) 
    elseif (isPedInVehicle(thePlayer)) then 
        local vehicle = getPedOccupiedVehicle(thePlayer) 
        attachElements(Object1, vehicle)        
    end 
  end 
addCommandHandler("auto", infernus) 
  
function infernus(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    elseif (isElement(Object1)) then   
        destroyElement(Object1) 
        outputChatBox("destruido", thePlayer, 0, 0, 255)              
    else 
        outputChatBox("destruido", thePlayer, 250, 0, 0) 
    end 
end 
addCommandHandler("destroy", infernus) 

Link to comment

Pusieron createVeichle, Aono intenta esto:

function infernus(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    Object1 = createVehicle(411, x, y, z-1)--- ID del auto 
    outputChatBox("creaste el auto", thePlayer, 0, 250, 0) 
    elseif (isPedInVehicle(thePlayer)) then 
        local vehicle = getPedOccupiedVehicle(thePlayer) 
        attachElements(Object1, vehicle)        
    end 
  end 
addCommandHandler("auto", infernus) 
  
function infernus(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then 
    elseif (isElement(Object1)) then   
        destroyElement(Object1) 
        outputChatBox("destruido", thePlayer, 0, 0, 255)              
    else 
        outputChatBox("destruido", thePlayer, 250, 0, 0) 
    end 
end 
addCommandHandler("destroy", infernus) 

Link to comment

No me funciona :( dice

WARNING: autosadmin\server.lua:3: Bad argument @ ´getPlayerAccount´ [Expected element at argument 1, got nil] 
autosadmin\server.lua:3: Bad argument @ ´getAccountName´ [Expected account at argument 1, got boolean] 
ERROR: autosadmin\server.lua:3: attempt to concatenate a boolean value 
  

Y no tengo la menor idea de que significa

Link to comment
No me funciona :( dice

WARNING: autosadmin\server.lua:3: Bad argument @ ´getPlayerAccount´ [Expected element at argument 1, got nil] 
autosadmin\server.lua:3: Bad argument @ ´getAccountName´ [Expected account at argument 1, got boolean] 
ERROR: autosadmin\server.lua:3: attempt to concatenate a boolean value 
  

Y no tengo la menor idea de que significa

aveses llegan a salir los mensajes , se pudo crear el auto con el guion que te dio Frank ?

Link to comment
  • MTA Team

El error radica en que la variable de getPlayerAccount la setearon a source, cuando en la funcion la estan definiendo como thePlayer :)

Ademas estan definiendo ambas funciones con el mismo nombre.

Tambien attachElements es bizzaro.

Y te falto la funcion que te mete dentro del auto recien creado.

Y agregan -1 a la coordenada Z lo cual meteran el auto parcialmente en la tierra.

Usa esto:(no esta probado)

function infernus(thePlayer) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then 
    if (isPedInVehicle(thePlayer)) then   
outputChatBox("Sal de tu auto actual", thePlayer, 0, 250, 0) 
end 
    Object1 = createVehicle(411, x+2, y+2, z)--- ID del auto 
    outputChatBox("creaste el auto", thePlayer, 0, 250, 0) 
    warpPedIntoVehicle (thePlayer,Object1) 
    end 
  end 
addCommandHandler("auto", infernus) 
  
function destruir(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then 
    if (isElement(Object1)) then   
        destroyElement(Object1) 
        outputChatBox("destruido", thePlayer, 0, 0, 255)             
    else 
        outputChatBox("Error, auto inexistente", thePlayer, 250, 0, 0) 
    end 
end 
end 
addCommandHandler("destroy", destruir) 

Link to comment

Tenias Muchos errores, Prueba Esto:

addCommandHandler("auto", 
function (thePlayer) 
 if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) and (isPedInVehicle(thePlayer)) then   
   outputChatBox("Sal de tu auto actual", thePlayer, 0, 250, 0) 
else 
     local x, y, z = getElementPosition(thePlayer) 
     Object1 = createVehicle(411, x+2, y+2, z)--- ID del auto 
     outputChatBox("Auto creado con Exito!", thePlayer, 0, 250, 0) 
     warpPedIntoVehicle (thePlayer,Object1) 
    end 
  end 
) 
  
addCommandHandler("destroy", 
function (thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) and (isElement(Object1)) then   
        destroyElement(Object1) 
        outputChatBox("Auto Destruido", thePlayer, 0, 0, 255)             
    else 
        outputChatBox("Error, auto inexistente", thePlayer, 250, 0, 0) 
    end 
end 
) 

Link to comment

Si tu quieres que el auto se destruya cuando el conductor salga, que en este caso seria el administrador que lo aparecio, se destruya.

local adminVehicle = {} 
  
function infernus(thePlayer, cmdName) 
    local x, y, z = getElementPosition(thePlayer) 
    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) then 
        if (isPedInVehicle(thePlayer)) then   
            outputChatBox("Sal de tu auto actual ( "..getVehicleName(getPedOccupiedVehicle(thePlayer)).." )", thePlayer, 0, 250, 0) 
        else 
            adminVehicle[thePlayer] = createVehicle(411, x+2, y+2, z)--- ID del auto 
            if adminVehicle[thePlayer] then 
                outputChatBox("Creaste el auto", thePlayer, 0, 250, 0) 
                warpPedIntoVehicle(thePlayer, adminVehicle[thePlayer]) 
            else 
                outputChatBox("Ha ocurrido un error al crear el vehiculo. Revisa bien los argumentos", thePlayer, 255, 0, 0) 
            end 
        end 
    else 
        outputChatBox("Tu no eres del grupo ACL 'Admin' por lo tanto no puedes usar este comando. ( /"..cmdName.." )", thePlayer, 255, 0, 0) 
    end 
  end 
addCommandHandler("auto", infernus) 
  
function destroyAdminVehicle(thePlayer, seat) 
    if adminVehicle[thePlayer] and source == adminVehicle[thePlayer] and seat == 0 then 
        outputChatBox("Tu vehiculo '"..getVehicleName(source).."' ha sido destruido", thePlayer, 0, 255, 0) 
        destroyElement(source) 
        adminVehicle[thePlayer] = nil 
    end 
end 
addEventHandler("onVehicleExit", root, destroyAdminVehicle) 

Link to comment
  • Recently Browsing   0 members

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