Jump to content

Vehiculos por Team


Alexs

Recommended Posts

Hola a Todos, queria saber algun ejemplo de un script que bloquee vehiculos por team, es decir que si soy del team "MCC" puedo tomar un auto, pero si hay alguien del team "ALFA" a el le aparezca bloqueado, busque en la comunidad y el unico que halle estaba buggeado con lo de los Teams, y pensaba en usar cosas como:

getPlayerTeam --Para saber si el usuario esta en ese Team 
onClientVehicleStartEnter --Para bloquearlo cuando intente entrar 
setVehicleLocked --Para bloquearlo si no esta en el Team 

Y creo que para desbloquearlo se usa una linea asi:

setVehicleLocked ( vehiculo, false ) 

Pero no se me ocurre como juntarlo todo, alguien me da un ejemplo, o una base para esto Por favor??

Link to comment

Podrías usar un if, y elseifs mostrando si el jugador es del team X.

Entonces, la lista de coches de tu gamemode, puedes usar

-- Team 1 
if coche1 then 
setVehicleLocked (coche1, true) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
  
-- Team 2 
if coche1 then 
setVehicleLocked (coche1, false) 
elseif coche2 then 
setVehicleLocked (coche2, true) 
elseif coche3 then 
setVehicleLocked (coche3, false) 
elseif coche4 then 
setVehicleLocked (coche4, true) 
end 

Notando que coche1 es del team Y.

Y desde mi punto de vista, podrías hacer esto para todos los vehículos de cada team.

Poniendo por cada coche, un elseif.

Una vez hechos todos los elseif del team 1, haz lo mismo con el team 2 invirtiendo los bool

Link to comment
Podrías usar un if, y elseifs mostrando si el jugador es del team X.

Entonces, la lista de coches de tu gamemode, puedes usar

-- Team 1 
if coche1 then 
setVehicleLocked (coche1, true) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
  
-- Team 2 
if coche1 then 
setVehicleLocked (coche1, false) 
elseif coche2 then 
setVehicleLocked (coche2, true) 
elseif coche3 then 
setVehicleLocked (coche3, false) 
elseif coche4 then 
setVehicleLocked (coche4, true) 
end 

Notando que coche1 es del team Y.

Y desde mi punto de vista, podrías hacer esto para todos los vehículos de cada team.

Poniendo por cada coche, un elseif.

Una vez hechos todos los elseif del team 1, haz lo mismo con el team 2 invirtiendo los bool

entonces el caso es que el vehiculo aparezca bloqueado para un team, pero no para el otro, no bloquearlo cuando el user de un team distinto intenta entrar?

Link to comment
Y cuanto más teams, debes hacer lo mismo, solo poniendo false en sus respectivos coches.

Para mas información podés ir a SetVehicleLocked en la wiki.

Lo que no comprendo es como hacer que el script sepa el team, seria algo asi como:

local team = getPlayerTeam (player) 
  
if Team = "MCC" then 
setVehicleLocked (coche1, true) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 

Algo asi verdad?

Link to comment
Y cuanto más teams, debes hacer lo mismo, solo poniendo false en sus respectivos coches.

Para mas información podés ir a SetVehicleLocked en la wiki.

Lo que no comprendo es como hacer que el script sepa el team, seria algo asi como:

local team = getPlayerTeam (player) 
  
if Team = "MCC" then 
setVehicleLocked (coche1, true) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 

Algo asi verdad?

Podrias poner unos mensajes en el chatbox para que no crean que es un error ^^

  
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source ) 
  
if Team = "MCC" then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 

Link to comment

Entonces finalmente pruebo con un script asi:

local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

Link to comment
Y cuanto más teams, debes hacer lo mismo, solo poniendo false en sus respectivos coches.

Para mas información podés ir a SetVehicleLocked en la wiki.

Lo que no comprendo es como hacer que el script sepa el team, seria algo asi como:

local team = getPlayerTeam (player) 
  
if Team = "MCC" then 
setVehicleLocked (coche1, true) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 

Algo asi verdad?

Podrias poner unos mensajes en el chatbox para que no crean que es un error ^^

  
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source ) 
  
if Team = "MCC" then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 

el setVehicleLocked no se le triggea a todos???

Osea, no podes poner que a uno se le lockee y a otro no...Yo recomendaria una tabla con los modelos de autos que puede usar o sino lo mejor es una base de datos SQL..

Yo uso un sistema de patente y sistema de llaves. Lo que hago es lo siguiente :

Para reconocer la llave del auto le pones a la misma llave la patente del vehiculo. Yo con las facciones puse que por ejemplo, todos los autos de la policia tengan la misma patente y entonces si sos policia, te dan una llave con esa patente.

Entonces que va a pasar, si no tenes llave, vos entras al auto pero no podes arrancar el motor por no tener las llaves.

El lock, es algo mas complicado de hacer...pero seguramente de alguna forma se debe poder hacer.

Esta function capaz te puede ayudar :

function isPlayerInRangeOfPoint(player, x, y, z, range) 
    local px, py, pz = getElementPosition(player) 
    return ((x-px)^2+(y-py)^2+(z-pz)^2)^0.5 <= range 
end 
-- Entonces si hay un auto de tal team y un jugador de otro team...ahi lockeas el auto. Si el auto pertenece al team, -----unlockeas 

Link to comment
Entonces finalmente pruebo con un script asi:
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche2 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche3 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche4 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
if coche1 then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
elseif team == "ALFA" then 
if coche1 then 
setVehicleLocked (coche1, false) 
elseif coche2 then 
setVehicleLocked (coche2, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche3 then 
setVehicleLocked (coche3, false) 
elseif coche4 then 
setVehicleLocked (coche4, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
end 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

Link to comment
Entonces finalmente pruebo con un script asi:
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche2 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche3 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche4 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
if coche1 then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
elseif team == "ALFA" then 
if coche1 then 
setVehicleLocked (coche1, false) 
elseif coche2 then 
setVehicleLocked (coche2, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche3 then 
setVehicleLocked (coche3, false) 
elseif coche4 then 
setVehicleLocked (coche4, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
end 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

Espera, me confundi con el tipo de arriba, entonces esta funcion es inutil??

Link to comment
Entonces finalmente pruebo con un script asi:
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche2 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche3 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche4 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function vehiculosbloq (source) 
local team = getPlayerTeam (player) 
local playerTeam = getPlayerTeam ( source )  
if team == "MCC" then 
if coche1 then 
setVehicleLocked (coche1, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche2 then 
setVehicleLocked (coche2, false) 
elseif coche3 then 
setVehicleLocked (coche3, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche4 then 
setVehicleLocked (coche4, false) 
end 
elseif team == "ALFA" then 
if coche1 then 
setVehicleLocked (coche1, false) 
elseif coche2 then 
setVehicleLocked (coche2, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
elseif coche3 then 
setVehicleLocked (coche3, false) 
elseif coche4 then 
setVehicleLocked (coche4, true) 
outputChatBox ( getPlayerName ( source ) .. " No puedes entrar a este vehiculo , es privado de los: " .. getTeamName ( playerTeam ) , 255,0,0) 
end 
end 
addEventHandler ( "onResourceStart", getRootElement(), vehiculosbloqs ) 
  

Espera, me confundi con el tipo de arriba, entonces esta funcion es inutil??

Si te referis a mi, si..Porque?

Vos no podes hacer lockear a una PERSONA ESPECIFICA. Sino que si pones setVehicleLocked(coche,false) , a todos se les va a unlockear, por eso no va a funcionar.

Y si no me crees, probalo...

Link to comment
lol creo q tendremos que esperar a solid ._.

Creo que es mejor

Si te referis a mi, si..Porque?

Vos no podes hacer lockear a una PERSONA ESPECIFICA. Sino que si pones setVehicleLocked(coche,false) , a todos se les va a unlockear, por eso no va a funcionar.

Y si no me crees, probalo...

Y me podes ayudar a hacer uno funcional?

Link to comment

nose si sirva ._.

local coche1 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche2 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche3 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
local coche4 = createVehicle ( vehicleID, x, y, z, rotX, rotY, rotZ ) 
  
function CancelarEvento() 
   cancelEvent () 
end 
addEventHandler ( "onVehicleStartEnter", CancelarEvento ) 
  

Buee pero no se como unirlos ._.

Link to comment
Te aconsejo que uses el evento onVehicleStartEnter, asi cancelas el evento si el jugador no esta en el team X.

...............ME ESTAN JODIENDO!!???!!............

Esa fue mi primera idea xDDD jajaja, vere si puedo hacer eso...

Edit:

local team = getPlayerTeam (player) 
  
function bloqmcc (source) 
if team == "MCC" 
then cancelEvent () 
addEventHandler ("onVehicleStartEnter", bloqmcc) 

creo que me faltan cosas.... pero es lo primero q se me ocurre...

Link to comment

Uhm, no, eso no tiene sentido, sin ofender.

Te hare un ejemplo.

local vehicle = createVehicle ( 411, 0, 0, 5 ) -- Creamos un Infernus en las coordenadas: 0, 0, 5. 
  
addEventHandler ( "onVehicleStartEnter", root, 
    function ( thePlayer, seat ) 
        if ( seat ~= 0 ) then -- Si el asiento no es el 0.. 
            return -- Cancelamos la funcion. 
        end 
         
        if ( source == vehicle ) then -- Si el vehiculo que esta intentando entrar es el que creamos.. 
            if ( getPlayerTeam ( thePlayer ) and getTeamName ( getPlayerTeam ( thePlayer ) ) ~= "MCC" ) then -- Si el jugador que intenta entrar tiene un team y el nombre del team no es "MCC".. 
                outputChatBox ( "Este vehiculo esta restringido a MCC", thePlayer, 255, 0, 0 ) 
                cancelEvent ( ) 
            end 
        end 
    end 
) 

Link to comment
Uhm, no, eso no tiene sentido, sin ofender.

Te hare un ejemplo.

local vehicle = createVehicle ( 411, 0, 0, 5 ) -- Creamos un Infernus en las coordenadas: 0, 0, 5. 
  
addEventHandler ( "onVehicleStartEnter", root, 
    function ( thePlayer, seat ) 
        if ( seat ~= 0 ) then -- Si el asiento no es el 0.. 
            return -- Cancelamos la funcion. 
        end 
         
        if ( source == vehicle ) then -- Si el vehiculo que esta intentando entrar es el que creamos.. 
            if ( getPlayerTeam ( thePlayer ) and getTeamName ( getPlayerTeam ( thePlayer ) ) ~= "MCC" ) then -- Si el jugador que intenta entrar tiene un team y el nombre del team no es "MCC".. 
                outputChatBox ( "Este vehiculo esta restringido a MCC", thePlayer, 255, 0, 0 ) 
                cancelEvent ( ) 
            end 
        end 
    end 
) 

entonces si por ejemplo, deseo que funcione en varios vehiculos hago algo asi:

local vehicle = createVehicle ( 411, 0, 0, 5 ) -- Creamos un Infernus en las coordenadas: 0, 0, 5. 
local vehicle2 = createVehicle ( 410, 0, 0, 8 ) -- Creamos otro Vehiculo 
  
addEventHandler ( "onVehicleStartEnter", root, 
    function ( thePlayer, seat ) 
        if ( seat ~= 0 ) then -- Si el asiento no es el 0.. 
            return -- Cancelamos la funcion. 
        end 
         
        if ( source == vehicle, vehicle2 ) then -- Si el vehiculo son los 2 creados? 
            if ( getPlayerTeam ( thePlayer ) and getTeamName ( getPlayerTeam ( thePlayer ) ) ~= "MCC" ) then -- Si el jugador que intenta entrar tiene un team y el nombre del team no es "MCC".. 
                outputChatBox ( "Este vehiculo esta restringido a MCC", thePlayer, 255, 0, 0 ) 
                cancelEvent ( ) 
            end 
        end 
    end 
) 

o esta mal eso de

( source == vehicle, vehicle2 ) 

Link to comment
  • Recently Browsing   0 members

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