bebo1king Posted October 19, 2015 Posted October 19, 2015 Hello , i am trying to make so simple mod but i got some problems local screenW,screenH = guiGetScreenSize () addEventHandler( "onClientPlayerStuntStart", getRootElement( ), function ( stuntType ) --outputChatBox( "You started stunt: " .. stuntType ); end ); addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), function ( stuntType, stuntTime, distance ) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end ); the problem is the dxDrawText is showing so fast then it disappear Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
HUNGRY:3 Posted October 19, 2015 Posted October 19, 2015 Because you should use "onClientRender" Event for Dx functions!
bebo1king Posted October 19, 2015 Author Posted October 19, 2015 Because you should use "onClientRender" Event for Dx functions! i see it same addEventHandler ( "onClientRender", getRootElement( ), addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), function ( stuntType, stuntTime, distance ) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end )); Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
MIKI785 Posted October 19, 2015 Posted October 19, 2015 Well thats just horrible thing to do, now youre adding the event every frame, do it the other way around, put the onClientRender into the other one. Lua Scripter Owner of mshost.cz MTA portal.
bebo1king Posted October 19, 2015 Author Posted October 19, 2015 Well thats just horrible thing to do, now youre adding the event every frame, do it the other way around, put the onClientRender into the other one. i dont understand you give me example better Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
HUNGRY:3 Posted October 19, 2015 Posted October 19, 2015 addEventHandler( "onClientPlayerStuntFinish", getRootElement( ), function() addEventHandler("onClientRender",root,lol) end ) function lol( stuntType, stuntTime, distance ) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end
bebo1king Posted October 19, 2015 Author Posted October 19, 2015 line8 attempt to concatenate local 'stuntType' (a nil value) Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
bebo1king Posted October 19, 2015 Author Posted October 19, 2015 (edited) addEventHandler( "onClientPlayerStuntFinish", root,function lol( stuntType, stuntTime, distance ) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end function() addEventHandler("onClientRender",root,lol) end ) now the proplem is line1 '(' is expected near lol this script proplems more than lines Edited October 19, 2015 by Guest Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
Dealman Posted October 19, 2015 Posted October 19, 2015 You forgot the parenthesis at the end of your function. I'd highly recommend you check out the Debugging section of the Wiki. I'd argue against writing your code like that, and instead write it like this; function ExampleCode(stuntType, stuntTime, distance) -- Code here end addEventHandler("onClientPlayerStuntFinish", root, ExampleCode) Personally I think it's much easier to read your own code when structured this way instead. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
bebo1king Posted October 19, 2015 Author Posted October 19, 2015 ok now there is no error but we will back to the main point i was asking help for is that the problem is the dxDrawText is showing so fast then it disappear the full code right now local screenW,screenH = guiGetScreenSize () function lol(stuntType, stuntTime, distance) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end addEventHandler("onClientPlayerStuntFinish", root, lol) function nothing () addEventHandler("onClientRender",root,lol) end Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
Dealman Posted October 19, 2015 Posted October 19, 2015 Because this code is never executed; function nothing () addEventHandler("onClientRender",root,lol) end Try this; local screenW,screenH = guiGetScreenSize () function lol(stuntType, stuntTime, distance) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end function nothing() addEventHandler("onClientRender", root, lol) end addEventHandler("onClientPlayerStuntFinish", root, nothing) If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
bebo1king Posted October 19, 2015 Author Posted October 19, 2015 Because this code is never executed; function nothing () addEventHandler("onClientRender",root,lol) end Try this; local screenW,screenH = guiGetScreenSize () function lol(stuntType, stuntTime, distance) dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end function nothing() addEventHandler("onClientRender", root, lol) end addEventHandler("onClientPlayerStuntFinish", root, nothing) here is the error of your code lua:4: attempt to concatnate local 'stunt'type (a nil value) Skype :bebo.ahmad34 My channel on youtupe : https://www.youtube.com/channel/UCOXfmMopyyBL5NBeO0RS04g/videos
Dealman Posted October 19, 2015 Posted October 19, 2015 That's an error in your code, not mine. Do you even read the error? lua:4: attempt to concatnate local 'stunt'type (a nil value) This means the error occurred at Line 4 in your code. The variable stuntType is returning a nil value - which means it's empty or doesn't exist. If I help you in a thread and you need further assistance, please don't PM me - use the thread you created instead. This way everyone on the forum can take advantage of it.
Tekken Posted October 19, 2015 Posted October 19, 2015 Try this: local screenW, screenH = guiGetScreenSize(); addEventHandler("onClientPlayerStuntFinish", getRootElement(), function(sty, sti, dis) stuntType = sty; stuntTime = sti; distance = dis; addEventHandler("onClientRender", getRootElement(), drawStunt); setTimer( removeEventHandler("onClientRender", getRootElement(), drawStunt) stuntType = nil; stuntTime = nil; distance = nil; end, 1000, 1); end); function drawStunt() dxDrawText("You finished stunt: " .. stuntType ..", Time: " .. tostring( stuntTime ).. ", Distance: " .. tostring( distance ), screenW * 0.2219, screenH * 0.7935, screenW * 0.8839, screenH * 0.8963, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false); end Resources I made: attachToBones - A newer bone_attach. Simple Level system - Just a simple level system. Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!
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