Jump to content

Problems


Jaysds1

Recommended Posts

  • Replies 365
  • Created
  • Last Reply

Top Posters In This Topic

I have this same problem...

When the text shown, I want it to disappear until they enter another zone...

Client-side only:

local rootElement = getRootElement() 
local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
  
function createText ( ) 
    local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() )  -- Get player's coordinates. 
    local playerZoneName =  getZoneName( playerX, playerY, playerZ )          -- Get name of the player's zone. 
  
    dxDrawText( playerZoneName, 0.95, screenHeight-37, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" )    -- Draw Zone Name text shadow. 
    dxDrawText( playerZoneName, 0.95, screenHeight-40, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- Draw Zone Name text. 
end 
  
  
function HandleTheRendering() 
    showPlayerHudComponent("area_name", false) 
    addEventHandler("onClientRender",rootElement, createText) -- keep the text visible with onClientRender. 
    setTimer(removeEventHandler,1500,0,"onClientRender",rootElement,createText) 
end 
addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) 

Link to comment

Try:

local rootElement = getRootElement() 
local screenWidth, screenHeight = guiGetScreenSize() -- Get the screen resolution 
  
function createText ( ) 
    local playerX, playerY, playerZ = getElementPosition( getLocalPlayer() )  -- Get player's coordinates. 
    local playerZoneName =  getZoneName( playerX, playerY, playerZ )          -- Get name of the player's zone. 
  
    dxDrawText( playerZoneName, 0.95, screenHeight-37, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" )    -- Draw Zone Name text shadow. 
    dxDrawText( playerZoneName, 0.95, screenHeight-40, screenWidth, screenHeight, tocolor ( 255, 255, 255, 255 ), 1, "pricedown" ) -- Draw Zone Name text. 
end 
  
  
function HandleTheRendering() 
    showPlayerHudComponent("area_name", false) 
    addEventHandler("onClientRender",rootElement, createText) -- keep the text visible with onClientRender. 
    setTimer(function() removeEventHandler("onClientRender",rootElement,createText) end,1500,0) 
end 
addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) 

Link to comment

How do you make the camera change based on a timer?

function 
    fadeCamera(source, true, 5) 
    setCameraMatrix(source, 1636.267578125,-2286.37890625,72.458694458008, 1682.93359375,-2286.330078125,13.508057594299) 
setTimer(function() fadeCamera(source, true, 5) setCameraMatrix(source, 1786.759765625,1450.986328125,92.410263061523, 1688.240234375,1448.77734375,10.767894744873)end, 9000,0) 
    setTimer(function() fadeCamera(source, true, 5) setCameraMatrix(source, -1685.783203125,-580.9912109375,272.26177978516, -1570.81640625,-455.7080078125,14)end, 9000,0) 
end 

Thanks for helping

Link to comment

You should make a table, a timer to change the matrix to a random value from the table.

Example:

local Table = { 
{0, 0, 0, 1, 1, 1}, 
{1, 1, 1, 2, 2, 2} 
} 
  
local timer = {} 
  
function Show(player) 
    local x, y, z, lx, ly, lz = unpack(Table[math.random(#Table)]) -- get a random value from the Table and unpack it to get the coords 
    fadeCamera(player, false, 1, 0, 0, 0) 
    setTimer(setCameraMatrix, 1000, 1, player, x, y, z, lx, ly, lz) 
    setTimer(fadeCamera, 1000, 1, player, true) 
    setTimer(Show, 8000, 1, player) 
end 

Link to comment

JR10, It doesn't work...

i added my coordinates and restarted it but the camera is blank/black.:

local Table = { 
{1636.267578125,-2286.37890625,72.458694458008, 1682.93359375,-2286.330078125,13.508057594299}, 
{1786.759765625,1450.986328125,92.410263061523, 1688.240234375,1448.77734375,10.767894744873}, 
{-1685.783203125,-580.9912109375,272.26177978516, -1570.81640625,-455.7080078125,14}} 
  
local timer = {} 
  
function Show() 
    local x, y, z, lx, ly, lz = unpack(Table[math.random(#Table)]) -- get a random value from the Table and unpack it to get the coords 
    fadeCamera(source, true, 5) 
    setTimer(setCameraMatrix, 100, 1, source, x, y, z, lx, ly, lz) 
    setTimer(fadeCamera, 100, 1, source, true) 
    setTimer(Show, 8000, 1, source) 
end 

Link to comment

Because you changed it wrong,

i made you Show function to use it.

local Table = { 
{1636.267578125,-2286.37890625,72.458694458008, 1682.93359375,-2286.330078125,13.508057594299}, 
{1786.759765625,1450.986328125,92.410263061523, 1688.240234375,1448.77734375,10.767894744873}, 
{-1685.783203125,-580.9912109375,272.26177978516, -1570.81640625,-455.7080078125,14}} 
  
local timer = {} 
  
function Show(player) 
    local x, y, z, lx, ly, lz = unpack(Table[math.random(#Table)]) -- get a random value from the Table and unpack it to get the coords 
    fadeCamera(player, true, 5) 
    setTimer(setCameraMatrix, 100, 1, player, x, y, z, lx, ly, lz) 
    setTimer(fadeCamera, 100, 1, player, true) 
    setTimer(Show, 8000, 1, player) 
end 
addEventHandler("onPlayerJoin", root, function() Show(source) end) 

Link to comment
  • 2 weeks later...

Hi again,

I want to know if this code respawns all vehicles

addCommandHandler("rav", 
function() 
outputChatBox("RESPAWNING ALL UNOCCUPIED VEHICLES IN 30Secs") 
    local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table   
    for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... 
        if (getVehicleOccupants(vehicle) == false) then 
            resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
            setTimer(function() respawnVehicle(vehicle) end,30000,0) 
        end 
    end 
end) 

Thanks for checking it...

Link to comment
addCommandHandler("rav", 
function() 
outputChatBox("RESPAWNING ALL UNOCCUPIED VEHICLES IN 30Secs") 
    setTimer(function () 
    local vehicles = getElementsByType ( "vehicle" ) -- Return all the vehicles in a table  
    for k, vehicle in ipairs ( vehicles ) do -- For every vehicle do the following... 
    if isEmpty( vehicle ) then 
    local seats = getVehicleMaxPassengers(vehicle) 
                resetVehicleIdleTime ( vehicle ) -- Reset the vehicle's idle time 
                respawnVehicle ( vehicle ) 
            end 
        end 
    end, 30000, 1) 
end) 
  
function isEmpty( vehicle ) 
    local passengers = getVehicleMaxPassengers( vehicle ) 
    if type( passengers ) == 'number' then 
        for seat = 0, passengers do 
            if getVehicleOccupant( vehicle, seat ) then 
                return false 
            end 
        end 
    end 
    return true 
end 

Edited by Guest
Link to comment

Hello again,

I have this problem with a script I'm working on...

When the player enters the vehicle and turns left or right, the left or right blinker/light is suppose to blink,

Here's my script:

addEventHandler("onVehicleEnter", getRootElement(), 
 function(player) 
    local vehicle = getPedOccupiedVehicle(player) 
    if getControlState(player, vehicle_left) then 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
    else 
        setVehicleOverrideLights(vehicle,0) 
    end 
    if getControlState(player, vehicle_right) then 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
    else 
        setVehicleOverrideLights(vehicle,0) 
    end 
 end) 

and thanks for help...

Link to comment

Maybe you should put a string, not a variable (vehicle_left, vehicle_right)...?

addEventHandler("onVehicleEnter", getRootElement(), 
 function(player) 
    local vehicle = getPedOccupiedVehicle(player) 
    if getControlState(player, "vehicle_left") then 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
    else 
        setVehicleOverrideLights(vehicle,0) 
    end 
    if getControlState(player, "vehicle_right") then 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
    else 
        setVehicleOverrideLights(vehicle,0) 
    end 
 end) 

Link to comment

This is the error that is shown when a person enters a vehicle:

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:22: Bad 'ped' pointer @ 'getPedOccupiedVehicle'(1)

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:23: Bad 'player' pointer @ 'getControlState'(1)

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:37: Bad argument @ 'setVehicleOverrideLights'

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:38: Bad argument @ 'setVehicleLightState'

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:39: Bad argument @ 'setVehicleLightState'

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:43: Bad 'ped' pointer @ 'getPedOccupiedVehicle'(1)

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:44: Bad 'player' pointer @ 'getControlState'(1)

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:58: Bad argument @ 'setVehicleOverrideLights'

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:59: Bad argument @ 'setVehicleLightState'

[2011-08-11 12:27:45] WARNING: JEngine\server.lua:60: Bad argument @ 'setVehicleLightState'

i changed the script a little, here:

addEventHandler("onVehicleEnter", getRootElement(), 
function(player) 
turnLeft(player, "vehicle_left") 
turnRight(player, "vehicle_right") 
end) 
function turnLeft(player, key) 
    local vehicle = getPedOccupiedVehicle(player) 
    if (getControlState(player, key)) then 
        setVehicleLightState(vehicle, 1,1) 
        setVehicleLightState(vehicle, 3,1) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,1000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,1000,0) 
    else 
        setVehicleOverrideLights(vehicle,0) 
        setVehicleLightState(vehicle,1,0) 
        setVehicleLightState(vehicle,3,0) 
    end 
end 
function turnRight(player, key) 
    local vehicle = getPedOccupiedVehicle(player) 
    if (getControlState(player, key)) then 
        setVehicleLightState(vehicle, 0,1) 
        setVehicleLightState(vehicle, 2,1) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 1) end,5000,0) 
        setTimer(function() setVehicleOverrideLights(vehicle, 2) end,5000,0) 
    else 
        setVehicleOverrideLights(vehicle,0) 
        setVehicleLightState(vehicle,0,0) 
        setVehicleLightState(vehicle,2,0) 
    end 
end 

I sort of copied what wiki showed.

Link to comment

Try:

addEventHandler("onVehicleEnter", getRootElement(), 
 function(player) 
    local vehicle = source 
    if getControlState(player, "vehicle_left") then 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
    else 
        setVehicleOverrideLights(vehicle,0) 
    end 
    if getControlState(player, "vehicle_right") then 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
        setVehicleOverrideLights(vehicle, 1) 
        setVehicleOverrideLights(vehicle, 2) 
    else 
        setVehicleOverrideLights(vehicle,0) 
    end 
 end) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...