-Doc- Posted February 22, 2016 Share Posted February 22, 2016 Hey, i have one question how to define 'player' in these function? Link to comment
tosfera Posted February 22, 2016 Share Posted February 22, 2016 these are client sided functions and don't need a player in them. If you're using isChatboxInputActive then it automatically only works for that client. If you want to get it from another player, you'll have to trigger an event under their name to the client, execute the function and send a trigger back to the source with the answer. Link to comment
-Doc- Posted February 22, 2016 Author Share Posted February 22, 2016 Show me a simple example? Link to comment
tosfera Posted February 22, 2016 Share Posted February 22, 2016 client function isPlayerConsoleActive ( thePlayer, callback ) if ( thePlayer == getLocalPlayer() ) then triggerServerEvent ( callback, source, thePlayer, isConsoleActive() ); end end addEvent ( "isPlayerConsoleActive", true ); addEventHandler ( "isPlayerConsoleActive", getRootElement(), isPlayerConsoleActive ); server addEvent ( "receiveActiveState", true ); addEventHandler ( "receiveActiveState", root, function ( thePlayer, state ) outputChatBox ( getPlayerName ( thePlayer ) .." his console is ".. ( state and "not" or "" ) .. " active.", source ); end ); addCommandHandler ( "isActive", function ( thePlayer, _, playername ) if ( playername ) then local player = getPlayerFromName ( playername ); if ( player ) then triggerClientEvent ( "isPlayerConsoleActive", thePlayer, player, "receiveActiveState" ); else outputChatBox ( "player not found.", thePlayer ); end end end ); by using the command: isActive the script will send a trigger towards the client from the player and return the answer to the callback. (not tested though, might be wrong) Link to comment
-Doc- Posted February 22, 2016 Author Share Posted February 22, 2016 Not working i just want to output in chat if is player typing and thats all. Link to comment
tosfera Posted February 22, 2016 Share Posted February 22, 2016 I've just tested it and it works. You just have to replace the command by something you need/want. As in; trigger it every 50ms or what so ever. The command is there to show the actual working progress of the script. Link to comment
Bonus Posted February 22, 2016 Share Posted February 22, 2016 (edited) That is a bit complicated if you want to see if someone writes without need to check. You have to use bindKey "t" to know when someone is writing. Then use isChatBoxInputActive to set him element data if hr is writing or not. You can use this elementdata to show you if someone is writing. Same with F8. Please just dont do it with a timer. Edited February 22, 2016 by Guest Link to comment
-Doc- Posted February 22, 2016 Author Share Posted February 22, 2016 Server side addEvent ( "receiveActiveState", true ); addEventHandler ( "receiveActiveState", root, function ( thePlayer, state ) outputChatBox ( getPlayerName ( thePlayer ) .." his console is ".. ( state and "not" or "" ) .. " active.", source ); end ); setTimer(check,50,0) function check ( thePlayer, _, playername ) if ( playername ) then local player = getPlayerFromName ( playername ); if ( player ) then triggerClientEvent ( "isPlayerConsoleActive", thePlayer, player, "receiveActiveState" ); else outputChatBox ( "player not found.", thePlayer ); end end end Link to comment
tosfera Posted February 22, 2016 Share Posted February 22, 2016 That is a bit complicated if you want to see if someone writes without need to check.You have to use bindKey "t" to know when someone is writing. Then use isChatBoxInputActive to set him element data if hr is writing or not. You can use this elementdata to show you if someone is writing. Same with F8. Please just dont do it with a timer. That's the more appropriate way and best way to go with, haven't thought about that. Link to comment
GTX Posted February 22, 2016 Share Posted February 22, 2016 (edited) Player can bind chat input to another key, so bindKey isn't an option. Put setTimer below triggered function. function check ( thePlayer, _, playername ) if ( playername ) then local player = getPlayerFromName ( playername ); if ( player ) then triggerClientEvent ( "isPlayerConsoleActive", thePlayer, player, "receiveActiveState" ); else outputChatBox ( "player not found.", thePlayer ); end end end setTimer(check,50,0) (By the way, setTimer - not a good idea imo) Edited February 22, 2016 by Guest Link to comment
-Doc- Posted February 22, 2016 Author Share Posted February 22, 2016 Already tried it. Link to comment
GTX Posted February 22, 2016 Share Posted February 22, 2016 Oh, right. You must loop through all players, because parameters in function are not declared. I don't recommend using outputChatBox in this case. You can draw a bubble above player's head instead. Link to comment
-Doc- Posted February 22, 2016 Author Share Posted February 22, 2016 (edited) Lul Edited February 22, 2016 by Guest Link to comment
Bonus Posted February 22, 2016 Share Posted February 22, 2016 (edited) Try this: local chatison = false addEventHandler ( "onClientKey", root, function ( ) local chatboxactive = isChatBoxInputActive() if not chatison and chatboxactive then chatison = true setElementData ( localPlayer, "chatIsOn", true ) elseif chatison and not chatboxactive then chatison = false setElementData ( localPlayer, "chatIsOn", false ) end end ) Edited February 22, 2016 by Guest Link to comment
-Doc- Posted February 22, 2016 Author Share Posted February 22, 2016 A;ready made it in another way thx for help Link to comment
-Doc- Posted February 23, 2016 Author Share Posted February 23, 2016 How to make sound to stop by fade effect? Link to comment
Bonus Posted February 23, 2016 Share Posted February 23, 2016 On every fade effect? Then you can modify fadeCamera, else just use triggerClientEvent after using fadeCamera. Link to comment
Bonus Posted February 23, 2016 Share Posted February 23, 2016 What? On every fade effect? Link to comment
-Doc- Posted February 23, 2016 Author Share Posted February 23, 2016 You know sound fade effect? I wanna make that Link to comment
Bonus Posted February 23, 2016 Share Posted February 23, 2016 You asked: How to make sound to stop by fade effect? Now you want a sound fade? Sry, but I don't really understand what exactly you want. Explain it a bit more pls. Link to comment
-Doc- Posted February 23, 2016 Author Share Posted February 23, 2016 I want to stop sound by fade effect! Link to comment
Bonus Posted February 23, 2016 Share Posted February 23, 2016 Oh, you don't talk about fadeCamera, you talk about the sound getting lower until its stopped. You can do it that way: local sound = nil local startvolume = 0 local actualvolume = 0 local steptostop = 0 local function fadeTheSoundAway ( ) actualvolume = actualvolume - startvolume/steptostop if actualvolume == 0 then stopSound ( sound ) else setSoundVolume ( sound , actualvolume ) end end function stopSoundWithFade ( sound, step ) if isElement ( sound ) and getElementType ( sound ) == "sound" and tonumber ( step ) then startvolume = getSoundVolume ( sound ) actualvolume = startvolume steptostop = tonumber ( step ) addEventHandler ( "onClientRender", root, fadeTheSoundAway ) return true end return false end ) With this code you should be able to use the function: stopSoundWithFade ( thesound, step ) thesound := sound element, which you want to stop step := float, sets the speed how fast the sound will stop For step you should use a higher number like 180. Then the sound will be stopped after 180 Frames (in 3 seconds with 60 FPS). 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