Jump to content

Guide to showing images


AcidDK

Recommended Posts

Posted

Hi.

I've been all over the wiki and this board now, and I can't find out how to create images and show them in game. Can some one possibly make a short guide for it?

Thanks in advance.

Posted

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

Posted

Af far as I know, destroyElement should delete the image.

destroyElement is used to remove vehicles, textdisplays, etc. Everything what's "element"

Posted
i cant figger out how destroy the element on my client script though could u give a example

Well.. store the element in a global variable and destroy it with destroyElement when needed?

Posted

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.

Posted

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?

Posted

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) 

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