John Smith Posted July 17, 2014 Share Posted July 17, 2014 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
#DRAGON!FIRE Posted July 17, 2014 Share Posted July 17, 2014 triggerServerEvent triggerClientEvent dxDrawImage Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 what do i need triggerServerEvent for? i can trigger events as much as i like but i dont know how to draw different image just for 1 PLAYER Link to comment
Et-win Posted July 17, 2014 Share Posted July 17, 2014 getElementData dxDrawImage --With event: onClientRender Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 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
Et-win Posted July 17, 2014 Share Posted July 17, 2014 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'. Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 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
Et-win Posted July 17, 2014 Share Posted July 17, 2014 triggerClientEvent(killer, "onLevelHundred",killer) That is the source where you gave it up, not sendTo. Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 i put it like that and even players who dont have any data which im setting can see the image Link to comment
Et-win Posted July 17, 2014 Share Posted July 17, 2014 Whole function would be good to see. Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 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
Et-win Posted July 17, 2014 Share Posted July 17, 2014 As far as I know it just has to work, maybe can someone else help. Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 i really hope there is someone else who can help me,because noone answered in here yet except you Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 i re-edited this post so much,i will just reply if i find any problem because i think i know what i have been doing wrong Link to comment
John Smith Posted July 17, 2014 Author Share Posted July 17, 2014 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
Et-win Posted July 18, 2014 Share Posted July 18, 2014 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 ) Link to comment
John Smith Posted July 20, 2014 Author Share Posted July 20, 2014 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
Et-win Posted July 20, 2014 Share Posted July 20, 2014 Like I told you with the triggerClientEvent. I doubt you have it correct. Repost scripts. Link to comment
John Smith Posted July 20, 2014 Author Share Posted July 20, 2014 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
Et-win Posted July 20, 2014 Share Posted July 20, 2014 Your client-side function gets started as soon as the resource is started. Logical that it draws for everyone. The trigger should start the 'onClientRender', not 'onClientResourceStart'. Link to comment
John Smith Posted July 20, 2014 Author Share Posted July 20, 2014 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
Et-win Posted July 20, 2014 Share Posted July 20, 2014 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
Dealman Posted July 20, 2014 Share Posted July 20, 2014 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
John Smith Posted July 20, 2014 Author Share Posted July 20, 2014 @Dealman, no im just trying to draw it for each person differently(probs localPlayer) @Et-win, sry but replace that line with what exactly? Link to comment
Et-win Posted July 20, 2014 Share Posted July 20, 2014 John, he just gave you what I meant....... Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now