v36u Posted August 28, 2018 Posted August 28, 2018 So, i've been working on this resource, and i want it to do the following thing : when a player wears a ghillie suit and stands still for 3 seconds, his player model goes a little bit transparent, like "blending with the environment". Here is the code : Client Side : function getPlayerStance () currentskin = getElementData (localPlayer, "skin") if currentskin == 285 then if getPedMoveState (localPlayer) == "stand" or getPedMoveState (localPlayer) == "crouch" then triggerServerEvent ("onPlayerGhillieStateOn", localPlayer) else triggerServerEvent ("onPlayerGhillieStateOff", localPlayer) end else triggerServerEvent ("onPlayerGhillieStateOff", localPlayer) end end setTimer (getPlayerStance, 3000,0) Server Side : function onPlayerGhillieStateOn () setElementAlpha (client, 50) end addEvent ("onPlayerGhillieStateOn" , true) addEventHandler ("onPlayerGhillieStateOn", root, onPlayerGhillieStateOn) function onPlayerGhillieStateOff () setElementAlpha (client, 255) end addEvent ("onPlayerGhillieStateOff", true) addEventHandler ("onPlayerGhillieStateOff", root, onPlayerGhillieStateOff) And i managed to only get this working : Spoiler Thanks in advance ^^
SycroX Posted August 28, 2018 Posted August 28, 2018 (edited) setTimer(function() for _,player in ipairs(getElementsByType("player")) do if getElementModel(player) == 285 then if getPlayerIdleTime(player) >= 3000 then setElementAlpha(player, 50) else setElementAlpha(player, 255) end else setElementAlpha(player, 255) end end end, 1000, 0) Edited August 28, 2018 by #َxLysandeR 1 1
v36u Posted August 28, 2018 Author Posted August 28, 2018 I got the same thing but it flashes faster than in my video. I want it to be transparent continuously, not flickering or something.
iMr.WiFi..! Posted August 28, 2018 Posted August 28, 2018 5 minutes ago, JanKy said: I got the same thing but it flashes faster than in my video. I want it to be transparent continuously, not flickering or something. Code seems working good. Did you get any debug? 1
v36u Posted August 28, 2018 Author Posted August 28, 2018 Absolutely no error in the debugscript. It is server sided, and all looks right. I changed the timer from "1000" which is a second to "100" ( which i believe it's the minimum ) and it almost works, but still flickers. But i don't think this is the right thing to do, tho'.
Discord Moderators Pirulax Posted August 28, 2018 Discord Moderators Posted August 28, 2018 I wouldn't set a timer to 100ms(50 is the min btw) on server-side.. Nah, try printing getPlayerIdleTime() with print() 1
pa3ck Posted August 29, 2018 Posted August 29, 2018 You probably have some resource running that sets back the alpha of the player. In your first code you set it every 3 seconds even when it's already 50, then it's being set back, that is why it flickers every 3 seconds. In Lysanders code it sets it every 1 second that is why it flickers even faster. Search for the keyword setElementAlpha in your resources folder using Notepad++ or similar. 1
v36u Posted August 29, 2018 Author Posted August 29, 2018 Oh, damn. Thank you, all of you. Sometimes i don't see these "little" things. Problem solved ^^
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