Jump to content

Changing an image by hitting a marker


[FOTL]Aphex

Recommended Posts

So I want to change a gui image when you hit a marker, so far I have this...

server

function omg_ramptest() 
    CP1 = createMarker (2445, -1660, 13, "cylinder", 4, 255, 0, 0, 255) 
    omgMover1(1) 
end 
  
function randomCar(player, dimension) 
    if source == CP1 then 
        if getElementType(player) == "player" then 
            local veh = getPedOccupiedVehicle(player) 
            if veh then 
                triggerClientEvent ( "triggered", getRootElement(), 1 ) 
            end 
        end 
    end 
end 
addEventHandler('onMarkerHit', getRootElement(), randomCar) 

client

function makeicon() 
    local x,y = guiGetScreenSize() 
    local iconimg = guiCreateStaticImage( (x/2)-25, y/15, 50, 50, "icon5.png", false ) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), makeicon) 
  
function changeicon() 
    guiStaticImageLoadImage ( iconimg, icon2.png ) 
end 
  
function trigger ( message ) 
    outputChatBox ( "The server says: " .. message ) 
    changeicon 
end 
addEvent( "triggered", true ) 
addEventHandler( "triggered", getRootElement(), trigger ) 

The initial image (icon5.png) displays and when you hit the marker I get the "The server says:" message, but ONLY when I delete the trigger function and contain it in it's own lua file. I can't get it to trigger the guiStaticImageLoadImage function.

Any ideas?

Edited by Guest
Link to comment
function makeicon() 
    local x,y = guiGetScreenSize() 
    local iconimg = guiCreateStaticImage( (x/2)-25, y/15, 50, 50, "icon5.png", false ) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), makeicon) 
  
function changeicon() 
    guiStaticImageLoadImage ( iconimg, "icon2.png" ) 
end 
  
function trigger ( message ) 
    outputChatBox ( "The server says: " .. message ) 
    changeicon ( ) 
end 
addEvent( "triggered", true ) 
addEventHandler( "triggered", getRootElement(), trigger ) 

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...