Jump to content

dxDrawImage for 1 player


Recommended Posts

how could i draw a dx image just for localPlayer?

i got some element data and i got couple of pictures and if player has like data 200 it should draw '1.png'

or if data is 400 it should draw image '2.png'

how could i draw image for just 1 player?so not everyone has same picture

Link to comment

omg im already using element data,and i know how to make image.............................................

i just dont know how to separate players so i could draw image just for 1 person

one player had element data 200 and i 400 and it drawn image for both of us instead of me

do you get it now,what im trying to do?

Link to comment
triggerClientEvent 

Read the wiki, you will see a argument called "sendTo".

You are checking the player's data, so if you use getElementData by a player and it has 200, then put that player who has that value by 'sendTo'.

server

        elseif (tonumber(exp) >= 560001 and tonumber(exp) <=600000) then 
        setElementData(killer, "LV", 100) 
        triggerClientEvent("onLevelHundred",killer) -- killer is defined already so no worries about it 

client

function onLevelHundred() 
dxDrawImage ( screenWidth/3.25, screenHeight/1.045, 32, 32, '1.png', 0, -120 ) 
end 
addEvent("onLevelHundred",true) 
addEventHandler("onLevelHundred",localPlayer,onLevelHundred) 
  
function HandleTheRendering ( ) 
    addEventHandler("onClientRender", getRootElement(), onLevelHundred)  -- Keep everything visible with onClientRender. 
end 
addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) 

im using just 1 pic at the moment for LV(level) 100 but it draws image for anyone

im unsure how to trigger client event properly,its confusing me as i dont understand the examples out there

Link to comment
  
function funcc(ammo, killer, weapon, bodypart) 
    if (killer and getElementType(killer) == "player" and killer ~= source) then 
-- defining some things 
  
  
  
  
  
  
--getting lots of numbers and if its that number(e.g above 600k) then 
--it triggers client event for drawning image 
  

i doubt that u really need whole script for this

Link to comment

okay sry for 3rd post but i have been doing some things and i found where is the problem but i dont know how to fix it

function onLevelHundred() 
dxDrawImage ( screenWidth/3.25, screenHeight/1.045, 32, 32, '1.png', 0, -120 ) 
end 
addEvent("onLevelHundred",true) 
addEventHandler("onLevelHundred",localPlayer,onLevelHundred) 
  
function HandleTheRendering ( ) 
    addEventHandler("onClientRender", getRootElement(), onLevelHundred)  -- Keep everything visible with onClientRender. 
end 
addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) 

in second function handletherendering getRootElement() or resourceRoot or both cause the image to be visible to everyone,but i dont know how to fix this. i tried changing it to localPlayer but no success

anyone knows how to fix this?

Link to comment

Of course, how stupid that I didn't see that... Anyway, you start the function onLevelHundred when the resource gets started, this is for every client. You could check client-side which data the client has, to check or it needs to draw the picture or not. (Not sure or that will work) You can also send some stuff with the trigger to the client, like the data and then check which picture you have to draw with that data.

(Sorry if it didn't make sense, I'm extremely tired :P)

Link to comment

its not the problem about checking players data,i have a problem how can i draw it for just 1 player?

i can use my lines of code and check if player has wdiqwjeioqwjeqwoiqwej data but if it has,its still gonna draw picture for everyone lol

i just need help how to draw it for one player..(killer)

(i currently have only 1 picture but it still draws for everyone)

please help

Link to comment

serverside part where i trigger client event as u told me how to

        elseif (tonumber(exp) >= 560001 and tonumber(exp) <=600000) then 
        setElementData(killer, "LV", 100) 
        triggerClientEvent(killer,"onLevelHundred",killer) 

client

function onLevelHundred() 
dxDrawImage ( screenWidth/3.25, screenHeight/1.045, 32, 32, '1.png', 0, -120 ) --  
end 
addEvent("onLevelHundred",true) 
addEventHandler("onLevelHundred",localPlayer,onLevelHundred) 
  
function HandleTheRendering ( ) 
    addEventHandler("onClientRender", getRootElement(), onLevelHundred)  -- Keep everything visible with onClientRender. 
end 
addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) 

Link to comment

im sorry but i dont understand what you mean..

first event handler makes sure dx function text gets drawn in every frame but second event handler just starts the function to draw it

im really sorry could you show me how the code is suppost to look like?im still new at scripting

Link to comment

Yes, the second one starts "addEventHandler("onClientRender", getRootElement(), onLevelHundred)" which means to start drawing the picture. Which means, it draws by everyone. Replace "addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering)" which the trigger.

Link to comment

Rather confused as to what you want, but is it something like this you need?

function drawLevelHundredImage_Handler() 
    dxDrawImage(screenWidth/3.25, screenHeight/1.045, 32, 32, '1.png', 0, -120) 
end 
     
function onClientLevelHundred_Handler() 
    addEventHandler("onClientRender", getRootElement(), drawLevelHundredImage_Handler) -- Only start drawing when the event "onLevelHundred" is triggered. 
end 
addEvent("onLevelHundred", true) 
addEventHandler("onLevelHundred", root, onClientLevelHundred_Handler) 

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