isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 Can someone just do it for me I tried many times and I still didn't get how to do it just add the draw text on screen in the script when you get freeze and another time when you get unfreeze that's all I want
iMr.3a[Z]eF Posted July 14, 2013 Posted July 14, 2013 As i always says use this resource GUIEditor To Visit Us Press Here: mtasa://5.9.206.180:22002
isa_Khamdan Posted July 14, 2013 Author Posted July 14, 2013 I tried but I still don't get it can someone just fix this little code for me? it won't take long :c
Castillo Posted July 15, 2013 Posted July 15, 2013 Maybe because you aren't thinking at all, it's not a hard script, and on the wiki, there are examples about triggering. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 I tried this but it's not working can you tell me what is the problem now? *Client Side local function drawMessage () local screenWidth, screenHeight = guiGetScreenSize (); dxDrawText ("YOU ARE NOW FROZEN", screenWidth - 50, screenHeight); end; addEvent ("onPlayerFrozen", true); addEvent ("onPlayerUnfrozen", true); addEventHandler ("onPlayerFrozen", getRootElement (), function () addEventHandler ("onClientRender", getRootElement (), drawMessage); end); addEventHandler ("onPlayerUnfrozen", getRootElement (), function () removeEventHandler ("onClientRender", getRootElement (), drawMessage); end); *Server Side addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ) , function ( hitElement, matchingDimension ) if getElementType (hitElement) ~= "player" then return; end; if ( getElementType ( hitElement ) == "vehicle" ) then setElementFrozen ( hitElement, true ) triggerClientEvent (hitElement, "onPlayerFrozen", getRootElement ()); setTimer ( function (thePlayer) triggerClientEvent (thePlayer, "onPlayerUnfrozen", getRootElement ()); setElementFrozen (thePlayer, false); end, 5000, 1, hitElement); end end ); Edit : I used Debugscript 3 to check for errors but there are no errors at all and the marker still not showing so I can test it
Castillo Posted July 15, 2013 Posted July 15, 2013 -- client side: function drawMessage ( ) local screenWidth, screenHeight = guiGetScreenSize ( ) dxDrawText ( "YOU ARE NOW FROZEN", screenWidth / 2, screenHeight / 2 ) end addEvent ( "setMessageVisible", true ) addEventHandler ( "setMessageVisible", root, function ( state ) removeEventHandler ( "onClientRender", getRootElement (), drawMessage ) if ( state ) then addEventHandler ( "onClientRender", getRootElement (), drawMessage ) end end ) -- server side: addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ), function ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) ~= "player" ) then return end local vehicle = getPedOccupiedVehicle ( hitElement ) if ( vehicle ) then setElementFrozen ( vehicle, true ) triggerClientEvent ( hitElement, "setMessageVisible", hitElement, true ) setTimer ( function ( thePlayer, vehicle ) triggerClientEvent ( thePlayer, "setMessageVisible", thePlayer, false ) setElementFrozen ( vehicle, false ) end ,5000, 1, hitElement, vehicle ) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 Now the Timer doesn't work + text now showing? Edit: that's the meta.xml I am using "CP" author="N" type="script" version="1.0" />
Castillo Posted July 15, 2013 Posted July 15, 2013 Copy both again. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 Copy both again. Works now but it only show text when you get freeze? There is no Unfreeze text
Castillo Posted July 15, 2013 Posted July 15, 2013 Well, there's no point on showing a text for unfreezing, but you can edit it if you want. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 Well, there's no point on showing a text for unfreezing, but you can edit it if you want. Ok now I made it and it's working fine but the unfreeze message never disappear? client side function drawMessage1 ( ) local screenWidth, screenHeight = guiGetScreenSize ( ) dxDrawText ( "YOU ARE NOW FROZEN", screenWidth / 2, screenHeight / 2 ) end addEvent ( "text1", true ) addEventHandler ( "text1", root, function ( state ) removeEventHandler ( "onClientRender", getRootElement (), drawMessage1 ) if ( state ) then addEventHandler ( "onClientRender", getRootElement (), drawMessage1 ) end end ) function drawMessage2 ( ) local screenWidth, screenHeight = guiGetScreenSize ( ) dxDrawText ( "YOU ARE NOW UNFROZEN", screenWidth / 2, screenHeight / 2 ) end addEvent ( "text2", true ) addEventHandler ( "text2", root, function ( state ) removeEventHandler ( "onClientRender", getRootElement (), drawMessage2 ) if ( state ) then addEventHandler ( "onClientRender", getRootElement (), drawMessage2 ) end end ) server side addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ), function ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) ~= "player" ) then return end local vehicle = getPedOccupiedVehicle ( hitElement ) if ( vehicle ) then setElementFrozen ( vehicle, true ) triggerClientEvent ( hitElement, "text1", hitElement, true ) setTimer ( function ( thePlayer, vehicle ) triggerClientEvent ( thePlayer, "text1", thePlayer, false ) triggerClientEvent ( hitElement, "text2", hitElement, true ) setElementFrozen ( vehicle, false ) end ,5000, 1, hitElement, vehicle ) end end )
Castillo Posted July 15, 2013 Posted July 15, 2013 -- client side: local msg = "" function drawMessage ( ) local screenWidth, screenHeight = guiGetScreenSize ( ) dxDrawText ( msg, screenWidth / 2, screenHeight / 2 ) end addEvent ( "setMessageVisible", true ) addEventHandler ( "setMessageVisible", root, function ( state, msg_ ) removeEventHandler ( "onClientRender", getRootElement (), drawMessage ) if ( state ) then msg = msg_ addEventHandler ( "onClientRender", getRootElement (), drawMessage ) end end ) -- server side: addEventHandler ( "onMarkerHit", createMarker ( 1791.537, 656.511, 17.626, 'cylinder', 2.0, 255, 0, 0, 150 ), function ( hitElement, matchingDimension ) if ( getElementType ( hitElement ) ~= "player" ) then return end local vehicle = getPedOccupiedVehicle ( hitElement ) if ( vehicle ) then setElementFrozen ( vehicle, true ) triggerClientEvent ( hitElement, "setMessageVisible", hitElement, true, "YOU ARE NOW FROZEN" ) setTimer ( function ( thePlayer, vehicle ) triggerClientEvent ( thePlayer, "setMessageVisible", thePlayer, true, "YOU ARE NOW UNFROZEN" ) setElementFrozen ( vehicle, false ) setTimer ( triggerClientEvent, 3000, 1, thePlayer, "setMessageVisible", thePlayer, false ) end ,5000, 1, hitElement, vehicle ) end end ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 Thanks a lot for everything but can you tell me how can I set the font size / Color?
Castillo Posted July 15, 2013 Posted July 15, 2013 Read all the arguments of dxDrawText at the wiki page. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 ok I added this and it worked how can I make it in the center of the screen? dxDrawText ( msg, 20, screenHeight - 41, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" )
Castillo Posted July 15, 2013 Posted July 15, 2013 Change the position. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 Change the position. No I want it in the center in all screen resolutions
Castillo Posted July 15, 2013 Posted July 15, 2013 dxDrawText ( msg, 20, screenHeight, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown", "center", "center" ) San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
isa_Khamdan Posted July 15, 2013 Author Posted July 15, 2013 dxDrawText ( msg, 20, screenHeight, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown", "center", "center" ) it's on the center of the width only?
Moderators IIYAMA Posted July 15, 2013 Moderators Posted July 15, 2013 dxDrawText ( msg,0, 0, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown", "center", "center" ) dxDrawText ( msg,0, 0, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown", "center", "center" )The start position of the boundingbox is x=0 y=0 The end position is the max size of your screen: screenWidth, screenHeight The center is between the start and the end. Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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