bebo1king Posted October 19, 2015 Share 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 Link to comment
HUNGRY:3 Posted October 19, 2015 Share Posted October 19, 2015 Because you should use "onClientRender" Event for Dx functions! Link to comment
bebo1king Posted October 19, 2015 Author Share 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 )); Link to comment
MIKI785 Posted October 19, 2015 Share 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. Link to comment
bebo1king Posted October 19, 2015 Author Share 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 Link to comment
HUNGRY:3 Posted October 19, 2015 Share 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 Link to comment
bebo1king Posted October 19, 2015 Author Share Posted October 19, 2015 line8 attempt to concatenate local 'stuntType' (a nil value) Link to comment
bebo1king Posted October 19, 2015 Author Share 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 Link to comment
Dealman Posted October 19, 2015 Share 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. Link to comment
bebo1king Posted October 19, 2015 Author Share 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 Link to comment
Dealman Posted October 19, 2015 Share 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) Link to comment
bebo1king Posted October 19, 2015 Author Share 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) Link to comment
Dealman Posted October 19, 2015 Share 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. Link to comment
Tekken Posted October 19, 2015 Share 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 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