iFoReX Posted May 6, 2012 Posted May 6, 2012 Im having a GUI Skins for my server , but my text doesnt appear cl-side GUIEditor_Button = {} GUIEditor_Edit = {} rotation = 0 GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons", getLocalPlayer(), function() guiSetVisible(GUIEditor_Button[1],true) guiSetVisible(GUIEditor_Button[2],true) guiSetVisible(GUIEditor_Button[3],true) guiSetVisible(GUIEditor_Edit[1],true) showCursor(true) dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) ---Here the text( doesnt appear ) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[3] then guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) setCameraTarget( localPlayer ) destroyElement(ped) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif source == GUIEditor_Button[1] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end ) function rotateTempPed ( ) if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end addEventHandler("onClientRender", root, rotateTempPed) numero = 0 function on_pushButton_2_clicked(button,state) if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[1], on_pushButton_2_clicked) function on_pushButton_3_clicked(button,state) if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], on_pushButton_3_clicked) sv-side addEventHandler("onPlayerLogin", getRootElement(), function() triggerClientEvent(source, "onVisibleButtons", source) local x,y,z,lx,ly,lz = 755.94171142578, -1258.78125, 18.399745941162, 756.03051757813, -1239.4184570313, 13.552116394043 setCameraMatrix(source,x,y,z,lx,ly,lz) end ) thanks in advance image :
ben_wright Posted May 6, 2012 Posted May 6, 2012 https://wiki.multitheftauto.com/wiki/DxDrawText onClientRender
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 GUIEditor_Button = {} GUIEditor_Edit = {} rotation = 0 GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) function texto() ls = dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons", getLocalPlayer(), function() guiSetVisible(GUIEditor_Button[1],true) guiSetVisible(GUIEditor_Button[2],true) guiSetVisible(GUIEditor_Button[3],true) guiSetVisible(GUIEditor_Edit[1],true) addEventHandler("onClientRender",root, texto) showCursor(true) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[3] then guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) setCameraTarget( localPlayer ) destroyElement(ped) destroyElement(ls) ---Here I tried destroy the text , but in the debugscript 3, ( destroyElement( bad argument ) ) D: local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif source == GUIEditor_Button[1] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end ) function rotateTempPed ( ) if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end addEventHandler("onClientRender", root, rotateTempPed) numero = 0 function on_pushButton_2_clicked(button,state) if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[1], on_pushButton_2_clicked) function on_pushButton_3_clicked(button,state) if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], on_pushButton_3_clicked) yeh I find the problem , now I want destroy the text when the Player press the GUIEditor_Button[3], but I dont know how D: please help me
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 thanks you! I searched in wiki 'cancelEventHandler'
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 now Doesnt work my second text 'LV' GUIEditor_Button = {} GUIEditor_Edit = {} rotation = 0 GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) function texto() ls = dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons", getLocalPlayer(), function() guiSetVisible(GUIEditor_Button[1],true) guiSetVisible(GUIEditor_Button[2],true) guiSetVisible(GUIEditor_Button[3],true) guiSetVisible(GUIEditor_Edit[1],true) addEventHandler("onClientRender",root, texto) showCursor(true) bindKey("space", "down", lvT) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[3] then guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) setCameraTarget( localPlayer ) destroyElement(ped) unbindKey("space") removeEventHandler("onClientRender", root, texto) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif source == GUIEditor_Button[1] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end ) function rotateTempPed ( ) if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end addEventHandler("onClientRender", root, rotateTempPed) numero = 0 function on_pushButton_2_clicked(button,state) if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[1], on_pushButton_2_clicked) function on_pushButton_3_clicked(button,state) if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], on_pushButton_3_clicked) function lvT() removeEventHandler("onClientRender", root, texto) lv = dxDrawText("Las Venturas",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 why it doesnt work ? D: GUIEditor_Button = {} GUIEditor_Edit = {} rotation = 0 GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) function texto() ls = dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons", getLocalPlayer(), function() guiSetVisible(GUIEditor_Button[1],true) guiSetVisible(GUIEditor_Button[2],true) guiSetVisible(GUIEditor_Button[3],true) guiSetVisible(GUIEditor_Edit[1],true) addEventHandler("onClientRender",root, texto) showCursor(true) bindKey("space", "down", theR) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end ) addEventHandler("onClientGUIClick", root, function() if source == GUIEditor_Button[3] then guiSetVisible(GUIEditor_Button[1],false) guiSetVisible(GUIEditor_Button[2],false) guiSetVisible(GUIEditor_Button[3],false) guiSetVisible(GUIEditor_Edit[1],false) showCursor(false) setCameraTarget( localPlayer ) destroyElement(ped) unbindKey("space") removeEventHandler("onClientRender", root, texto) removeEventHandler("onClientRender", root, theR) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif source == GUIEditor_Button[1] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end ) function rotateTempPed ( ) if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end addEventHandler("onClientRender", root, rotateTempPed) numero = 0 function on_pushButton_2_clicked(button,state) if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[1], on_pushButton_2_clicked) function on_pushButton_3_clicked(button,state) if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end end addEventHandler("onClientGUIClick", GUIEditor_Button[2], on_pushButton_3_clicked) function lvT() removeEventHandler("onClientRender", root, texto) lv = dxDrawText("Las Venturas",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) if (lv) then sf = dxDrawText("San Fierro",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end end function theR() addEventHandler("onClientRender", root, lvT) end I want if the Player has pressed the "space" , if the player press again he change the dxDrawText to SF
Michael# Posted May 6, 2012 Posted May 6, 2012 So, declare a var with the text and when press space change var text to SF.
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 mmm... better I do with Labels, with DxTexts is very hard
Michael# Posted May 6, 2012 Posted May 6, 2012 Samething. addEvent ( 'onVisibleButtons', true ) local iRotation = 0 aLocations = { 'Los Santos'; 'San Fierro'; 'Las Venturas'; } aGUI = { guiCreateButton ( 0.3688, 0.84, 0.0625, 0.055, '<', true ) guiCreateButton ( 0.5013, 0.84, 0.0625, 0.055, '>', true ) guiCreateButton ( 0.4013, 0.9067, 0.1287, 0.065, 'Empezar a Jugar', true ) guiCreateEdit ( 0.4412, 0.8367, 0.05, 0.0567, '', true ) } guiEditSetReadOnly ( aGUI[4], true ) for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, false ) end -- addEventHandler ( 'onClientResourceStart', resourceRoot, function ( ) addEventHandler ( 'onClientGUIClick', root, btnSource ) addEventHandler ( 'onClientRender', root, rotatePed ) end ) -- addEventHandler ( 'onVisibleButtons', localPlayer, function ( ) for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, true ) end showCursor ( true ) addEventHandler ( 'onClientRender', root, drawTextOne ) bindKey ( 'space', 'down', changeLoc ) uPed = createPed ( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end ) function drawTextOne ( ) dxDrawText ( tostring ( aLocations[1] ), 433, 539, 641, 585, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left', 'top', false, false, true ) cCity = aLocations[1] end function drawTextTwo ( ) dxDrawText ( tostring ( aLocations[2] ), 433, 539, 641, 585, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left', 'top', false, false, true ) cCity = aLocations[2] end function drawTextThree ( ) dxDrawText ( tostring ( aLocations[3] ), 433, 539, 641, 585, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left','top', false, false, true ) cCity = aLocations[3] end function btnSource ( ) if ( source == aGUI[3] ) then for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, false ) end showCursor ( false ) setCameraTarget ( localPlayer ) destroyElement ( uPed ) unbindKey ( 'space' ) removeEventHandler ( 'onClientRender', root, drawText ) setElementPosition ( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif ( source == aGUI[1] ) then if ( getElementModel ( uPed ) == 0 ) then setElementModel ( uPed, 288 ) else setElementModel ( uPed, getElementModel ( uPed ) - 1 ) end guiSetText ( aGUI[4], getElementModel ( uPed ) ) elseif ( source == aGUI[2] ) then if ( getElementModel ( uPed ) == 288 ) then setElementModel ( uPed, 0 ) else setElementModel ( uPed, getElementModel ( uPed ) + 1 ) end guiSetText ( aUI[4], getElementModel ( uPed ) end end function rotatePed ( ) if ( not isElement ( uPed ) ) then return end iRotation = iRotation + 1 setPedRotation ( uPed, iRotation ) end function changeLoc ( ) if ( cCity == aLocations[1] ) then removeEventHandler ( 'onClientRender', root, drawTextOne ) addEventHandler ( 'onClientRender', root, drawTextTwo ) elseif ( cCity == aLocations[2] ) then removeEventHandler ( 'onClientRender', root, drawTextTwo ) addEventHandler ( 'onClientRender', root, drawTextThree ) elseif ( cCity == aLocations[3] ) then removeEventHandler ( 'onClientRender', root, drawTextThree ) addEventHandler ( 'onClientRender', root, drawTextOne ) end end Try that.
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 Wooow Nice code I go to test and I tell how work Doesnt work D:
X-SHADOW Posted May 6, 2012 Posted May 6, 2012 Fixed For You addEvent ( 'onVisibleButtons', true ) local iRotation = 0 aLocations = { 'Los Santos'; 'San Fierro'; 'Las Venturas'; } aGUI ={} guiCreateButton ( 0.3688, 0.84, 0.0625, 0.055, '<', true ) guiCreateButton ( 0.5013, 0.84, 0.0625, 0.055, '>', true ) guiCreateButton ( 0.4013, 0.9067, 0.1287, 0.065, 'Empezar a Jugar', true ) guiCreateEdit ( 0.4412, 0.8367, 0.05, 0.0567, '', true ) guiEditSetReadOnly ( aGUI[4], true ) for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, false ) end -- addEventHandler ( 'onClientResourceStart', resourceRoot, function ( ) addEventHandler ( 'onClientGUIClick', root, btnSource ) addEventHandler ( 'onClientRender', root, rotatePed ) end ) -- addEventHandler ( 'onVisibleButtons', localPlayer, function ( ) for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, true ) end showCursor ( true ) addEventHandler ( 'onClientRender', root, drawTextOne ) bindKey ( 'space', 'down', changeLoc ) uPed = createPed ( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end ) function drawTextOne ( ) dxDrawText ( tostring ( aLocations[1] ), 433, 539, 641, 585, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left', 'top', false, false, true ) cCity = aLocations[1] end function drawTextTwo ( ) dxDrawText ( tostring ( aLocations[2] ), 433, 539, 641, 585, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left', 'top', false, false, true ) cCity = aLocations[2] end function drawTextThree ( ) dxDrawText ( tostring ( aLocations[3] ), 433, 539, 641, 585, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left','top', false, false, true ) cCity = aLocations[3] end function btnSource ( ) if ( source == aGUI[3] ) then for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, false ) end showCursor ( false ) setCameraTarget ( localPlayer ) destroyElement ( uPed ) unbindKey ( 'space' ) removeEventHandler ( 'onClientRender', root, drawText ) setElementPosition ( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif ( source == aGUI[1] ) then if ( getElementModel ( uPed ) == 0 ) then setElementModel ( uPed, 288 ) else setElementModel ( uPed, getElementModel ( uPed ) - 1 ) end guiSetText ( aGUI[4], getElementModel ( uPed ) ) elseif ( source == aGUI[2] ) then if ( getElementModel ( uPed ) == 288 ) then setElementModel ( uPed, 0 ) else setElementModel ( uPed, getElementModel ( uPed ) + 1 ) end guiSetText ( aUI[4], getElementModel ( uPed )) end end function rotatePed ( ) if ( not isElement ( uPed ) ) then return end iRotation = iRotation + 1 setPedRotation ( uPed, iRotation ) end function changeLoc ( ) if ( cCity == aLocations[1] ) then removeEventHandler ( 'onClientRender', root, drawTextOne ) addEventHandler ( 'onClientRender', root, drawTextTwo ) elseif ( cCity == aLocations[2] ) then removeEventHandler ( 'onClientRender', root, drawTextTwo ) addEventHandler ( 'onClientRender', root, drawTextThree ) elseif ( cCity == aLocations[3] ) then removeEventHandler ( 'onClientRender', root, drawTextThree ) addEventHandler ( 'onClientRender', root, drawTextOne ) end end
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 now GUI Elements appear when I start the resource
Kenix Posted May 6, 2012 Posted May 6, 2012 Try this addEvent ( 'onVisibleButtons', true ) local iRotation = 0 local nScreenX, nScreenY = guiGetScreenSize( ) local pPed aLocations = { 'Los Santos'; 'San Fierro'; 'Las Venturas'; } aGUI = { guiCreateButton ( 0.3688, 0.84, 0.0625, 0.055, '<', true ); guiCreateButton ( 0.5013, 0.84, 0.0625, 0.055, '>', true ); guiCreateButton ( 0.4013, 0.9067, 0.1287, 0.065, 'Empezar a Jugar', true ); guiCreateEdit ( 0.4412, 0.8367, 0.05, 0.0567, '', true ); } guiEditSetReadOnly ( aGUI[4], true ) for _, pGui in pairs ( aGUI ) do guiSetVisible ( pGui, false ) end function drawText ( ) local nCount = getTickCount( ) if nCount - getTickCount( ) == dxDrawText ( tostring ( aLocations[1] ), 0.433 * nScreenX, 0.539 * nScreenY, 0.641 * nScreenX, 0.585 * nScreenY, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left', 'top', false, false, true ) cCity = aLocations[1] end function drawTextTwo ( ) dxDrawText ( tostring ( aLocations[2] ), 0.433 * nScreenX, 0.539 * nScreenY, 0.641 * nScreenX, 0.585 * nScreenY, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left', 'top', false, false, true ) cCity = aLocations[2] end function drawTextThree ( ) dxDrawText ( tostring ( aLocations[3] ), 0.433 * nScreenX, 0.539 * nScreenY, 0.641 * nScreenX, 0.585 * nScreenY, tocolor ( 255, 255, 255, 255 ), 3, 'default', 'left','top', false, false, true ) cCity = aLocations[3] end function btnSource ( ) if ( source == aGUI[3] ) then for _, guiElement in pairs ( aGUI ) do guiSetVisible ( guiElement, false ) end showCursor ( false ) setCameraTarget ( localPlayer ) destroyElement ( pPed ) unbindKey ( 'space' ) removeEventHandler ( 'onClientRender', root, drawText ) setElementPosition ( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) elseif ( source == aGUI[1] ) then if ( getElementModel ( pPed ) == 0 ) then setElementModel ( pPed, 288 ) else setElementModel ( pPed, getElementModel ( pPed ) - 1 ) end guiSetText ( aGUI[4], getElementModel ( pPed ) ) elseif ( source == aGUI[2] ) then if ( getElementModel ( pPed ) == 288 ) then setElementModel ( pPed, 0 ) else setElementModel ( pPed, getElementModel ( pPed ) + 1 ) end guiSetText ( aUI[4], getElementModel ( pPed ) ) end end function rotatePed ( ) if ( not isElement ( pPed ) ) then return end iRotation = iRotation + 1 if iRotation == 360 then iRotation = 0 end setPedRotation ( pPed, iRotation ) end function changeLoc ( ) if ( cCity == aLocations[1] ) then removeEventHandler ( 'onClientRender', root, drawTextOne ) addEventHandler ( 'onClientRender', root, drawTextTwo ) elseif ( cCity == aLocations[2] ) then removeEventHandler ( 'onClientRender', root, drawTextTwo ) addEventHandler ( 'onClientRender', root, drawTextThree ) elseif ( cCity == aLocations[3] ) then removeEventHandler ( 'onClientRender', root, drawTextThree ) addEventHandler ( 'onClientRender', root, drawTextOne ) end end addEventHandler ( 'onVisibleButtons', localPlayer, function ( ) for _, pGui in pairs ( aGUI ) do guiSetVisible ( pGui, true ) end showCursor ( true ) addEventHandler ( 'onClientRender', root, drawTextOne ) addEventHandler ( 'onClientRender', root, rotatePed ) addEventHandler ( 'onClientGUIClick', guiRoot, btnSource ) bindKey ( 'space', 'down', changeLoc ) pPed = createPed ( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end )
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 try this: rotation = 0 addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons",root,function() GUIEditor_Button = {} GUIEditor_Edit = {} GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) showCursor(true) addEventHandler("onClientRender",root,dx) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) ---Here the text( doesnt appear ) end) function dx() dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end addEventHandler("onClientGUIClick", root,function() if source == GUIEditor_Button[3] then elements = {GUIEditor_Button[1],GUIEditor_Button[2],GUIEditor_Button[3],GUIEditor_Edit[1]} for i,v in ipairs(elements)do guiSetVisible(v,false) end showCursor(false) setCameraTarget() destroyElement(ped) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) removeEventHandler("onClientRender",root,dx) elseif source == GUIEditor_Button[1] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end,false) addEventHandler("onClientRender", root,function() if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end) numero = 0 addEventHandler("onClientGUIClick", GUIEditor_Button[1],function(button,state) if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end end,false) addEventHandler("onClientGUIClick", GUIEditor_Button[2],function(button,state) if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end end,false) addEventHandler("onPlayerLogin",root,function() triggerClientEvent(source, "onVisibleButtons", root) setCameraMatrix(source,755.94171142578, -1258.78125, 18.399745941162, 756.03051757813, -1239.4184570313, 13.552116394043) end)
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 Kenix ur code doesnt work D:, and ur code Jaiysd doesnt work too
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 tested: rotation = 0 GUIEditor_Button = {} GUIEditor_Edit = {} addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons",root,function() GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) showCursor(true) addEventHandler("onClientRender",root,dx) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end) function dx() dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end numero = 0 addEventHandler("onClientGUIClick", root,function() if source == GUIEditor_Button[3] then elements = {GUIEditor_Button[1],GUIEditor_Button[2],GUIEditor_Button[3],GUIEditor_Edit[1]} for i,v in ipairs(elements)do guiSetVisible(v,false) end showCursor(false) setCameraTarget(localPlayer) destroyElement(ped) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) removeEventHandler("onClientRender",root,dx) elseif source == GUIEditor_Button[1] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end elseif source == GUIEditor_Button[2] then guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end end end,true) addEventHandler("onClientRender", root,function() if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end) addEventHandler("onPlayerLogin",root,function() triggerClientEvent(source, "onVisibleButtons", root) setCameraMatrix(source,755.94171142578, -1258.78125, 18.399745941162, 756.03051757813, -1239.4184570313, 13.552116394043) end)
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 I've tested this: GUIEditor_Button = {} GUIEditor_Edit = {} rotation = 0 addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons", getLocalPlayer(), function() GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"0",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) addEventHandler("onClientRender",root, texto) showCursor(true) bindKey("space", "down", theR) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) end) function texto() ls = dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end numero = 0 addEventHandler("onClientGUIClick", root,function(button,state) if source == GUIEditor_Button[3] then local elements ={GUIEditor_Button[1],GUIEditor_Button[2],GUIEditor_Button[3],GUIEditor_Edit[1]} for i,v in ipairs(elements)do destroyElement(v) end showCursor(false) setCameraTarget( localPlayer ) destroyElement(ped) unbindKey("space") removeEventHandler("onClientRender", root, texto) removeEventHandler("onClientRender", root, theR) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) setPedSkin(localPlayer,numero) setElementFrozen(localPlayer,false) elseif source == GUIEditor_Button[1] then if (button == "left" and state == "up") then if(numero == 1) then return end numero = numero - 1 setElementModel(ped,numero) end guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then if (button == "left" and state == "up") then if (numero == 288) then return end numero = numero + 1 setElementModel(ped,numero) end guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end,true) addEventHandler("onClientRender", root,function( ) if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end) function theR() addEventHandler("onClientRender", root, lvT) end function lvT() removeEventHandler("onClientRender", root, texto) lv = dxDrawText("Las Venturas",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) if (lv) then sf = dxDrawText("San Fierro",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end end addEventHandler("onPlayerLogin",root,function() triggerClientEvent(source, "onVisibleButtons", root) setCameraMatrix(source,755.94171142578, -1258.78125, 18.399745941162, 756.03051757813, -1239.4184570313, 13.552116394043) end)
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 This is the closest I could get: GUIEditor_Button = {} GUIEditor_Edit = {} rotation = 0 addEvent("onVisibleButtons", true) addEventHandler("onVisibleButtons", getLocalPlayer(), function() GUIEditor_Button[1] = guiCreateButton(0.3688,0.84,0.0625,0.055,"<",true) GUIEditor_Button[2] = guiCreateButton(0.5013,0.84,0.0625,0.055,">",true) GUIEditor_Button[3] = guiCreateButton(0.4013,0.9067,0.1287,0.065,"Empezar a Jugar",true) GUIEditor_Edit[1] = guiCreateEdit(0.4412,0.8367,0.05,0.0567,"0",true) guiEditSetReadOnly(GUIEditor_Edit[1],true) lsT() showCursor(true) bindKey("space", "down", theR) ped = createPed( 0, 756.03051757813, -1239.4184570313, 13.552116394043 ) setElementData(ped,"City","LS") end) numero = 0 addEventHandler("onClientGUIClick", root,function(button,state) if source == GUIEditor_Button[3] then local elements ={GUIEditor_Button[1],GUIEditor_Button[2],GUIEditor_Button[3],GUIEditor_Edit[1]} for i,v in ipairs(elements)do destroyElement(v) end showCursor(false) setCameraTarget( localPlayer ) destroyElement(ped) unbindKey("space") removeEventHandler("onClientRender", root, texto) removeEventHandler("onClientRender", root, theR) local table = {{731.21276855469, -1276.6033935547, 17.6484375}} setElementPosition( localPlayer, 731.21276855469, -1276.6033935547, 17.6484375 ) setPedSkin(localPlayer,numero) setElementFrozen(localPlayer,false) elseif source == GUIEditor_Button[1] then if (button == "left" and state == "up") then if(numero == 0) then numero = 288 setElementModel(ped,numero) end numero = numero - 1 setElementModel(ped,numero) end guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") elseif source == GUIEditor_Button[2] then if (button == "left" and state == "up") then if (numero == 289) then numero = 0 setElementModel(ped,numero) end numero = numero + 1 setElementModel(ped,numero) end guiSetText(GUIEditor_Edit[1], " "..getElementModel(ped).."") end end,true) addEventHandler("onClientRender", root,function( ) if isElement ( ped ) then rotation = rotation + 1 if ( rotation > 359 ) then rotation = 0 end setPedRotation ( ped, rotation ) end end) function lsT() addEventHandler("onClientRender", root, lsT) dxDrawText("Los Santos",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end function theR() if(getElementData(ped,"City")=="LS")then removeEventHandler("onClientRender", root, lsT) setTimer(lvT,1000,1) setElementData(ped,"City","LV") elseif(getElementData(ped,"City")=="LV")then removeEventHandler("onClientRender",root,lvT) setTimer(sfT,1000,1) setElementData(ped,"City","SF") elseif(getElementData(ped,"City")=="SF")then removeEventHandler("onClientRender",root,sfT) setTimer(lsT,1000,1) setElementData(ped,"City","LS") end end function lvT() addEventHandler("onClientRender", root, lvT) dxDrawText("Las Venturas",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end function sfT() addEventHandler("onClientRender", root, sfT) sf = dxDrawText("San Fierro",433.0,539.0,641.0,585.0,tocolor(255,255,255,255),3.0,"default","left","top",false,false,true) end (WARNING: THE DEBUG MESSAGE GOES ON BUT THE DX TEXT CHANGES)
iFoReX Posted May 6, 2012 Author Posted May 6, 2012 thank you work 100% now how I can change the Camera if the player press space ? example = Las Venturas ( camera in Las Venturas ) thank you in advanced
Jaysds1 Posted May 6, 2012 Posted May 6, 2012 right here, just add in setCameraMatrix() function theR() if(getElementData(ped,"City")=="LS")then removeEventHandler("onClientRender", root, lsT) setTimer(lvT,1000,1) setElementData(ped,"City","LV") setCameraMatrix(X,Y,Z,RX,RY,RZ) --HERE, ADD X,Y,Z and RX,RY,RZ elseif(getElementData(ped,"City")=="LV")then removeEventHandler("onClientRender",root,lvT) setTimer(sfT,1000,1) setElementData(ped,"City","SF") setCameraMatrix(X,Y,Z,RX,RY,RZ)--HERE, ADD X,Y,Z and RX,RY,RZ elseif(getElementData(ped,"City")=="SF")then removeEventHandler("onClientRender",root,sfT) setTimer(lsT,1000,1) setElementData(ped,"City","LS") setCameraMatrix(X,Y,Z,RX,RY,RZ)--HERE, ADD X,Y,Z and RX,RY,RZ end end BTW, you don't care about the debugmessages?
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