Jump to content

Guide to showing images


AcidDK

Recommended Posts

i did this to add image to client side left lower part of screen but stuck on how remove it on client death heres is the code

this in server side for event

triggerClientEvent ( "onGreeting", getRootElement(), "" ) 

client

function pic(toggle) 
  
        local screenWidth, screenHeight = guiGetScreenSize() 
        local player = guiCreateStaticImage(screenWidth/2 - -290, screenHeight - 80, 220, 100, 'lama.png', false, nil) 
       end 
  
addEvent("onGreeting", true) 
addEventHandler("onGreeting", getRootElement(), pic) 
addEventHandler ( "onClientPlayerWasted", getRootElement(), picDied) 
  

i just need help with destroy on client death command

Link to comment

Try to do what I did:

1. make a global variable (at the top of script):

local image 

2. when you create static image use this variable to store the image element in it:

image = guiCreateStaticImage(....) 

3. if you want to delete the image use the "image" element as param in deleteElement func:

deleteElement( image ) 

I had problems with onClientPlayerWasted and every event, but I tested events using functions that have the same param as the event.

So if you want to use the event eg. onClientPlayerWasted add function to it with the params that event have (even if you don't need to use them):

function funcName( killer, weapon, bodypart )  
-- I don't use: killer, weapon, bodypart... but it must be included 
    deleteElement( image ) 
end 
addEventHandler( "onClientPlayerWasted", getLocalPlayer(), funcName ) 

Note: This example is client-sided.

Link to comment

i have a question to ask about this.

im just guessing as i dont really know... but it looks like this script Shows an image of the servers choice, then removes the image when the player gets killed....

so instead of removing the image when the player gets killed, is there a way to remove it after say a 20 second timer?

Link to comment

doesent work for some reason here is what i got if some one could help me

local image 
  
function pic(toggle) 
  
        local screenWidth, screenHeight = guiGetScreenSize() 
        local image = guiCreateStaticImage(screenWidth/2 - -290, screenHeight - 80, 220, 100, 'lama.png', false, nil) 
       end 
  
function picdel( killer, weapon, bodypart ) 
  
     destroyElement( image ) 
  
end 
  
addEvent("onGreeting", true) 
addEventHandler("onGreeting", getRootElement(), pic) 
addEventHandler ( "onClientPlayerWasted", getLocalPlayer(), picdel) 

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