
Absence2
Members-
Posts
267 -
Joined
-
Last visited
Everything posted by Absence2
-
Well, then I have a problem It goes 'nil' and floods the debug with it , window wont show and so on, works well without 'Relative' but that wont work well for the resolution settings though local sText = '' local uTimer function fDraw( quitReason ) sText = sText..string.format( 'Server: %s has %s the server %s \n', getPlayerName( source ), eventName == 'onClientPlayerQuit' and 'left' or eventName == 'onClientPlayerJoin' and 'join', eventName == 'onClientPlayerQuit' and '(' .. quitReason .. ')' or '' ) if isTimer( uTimer ) then killTimer( uTimer ) end uTimer = setTimer( function( ) sText = '' end, 5000, 1 ) end addEventHandler( 'onClientRender', root, function( ) if sText ~= '' then dxDrawRelativeText( sText,254.0,0.0,585.0,25.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawRelativeRectangle( 258.0,0.0,328.0,21.0,tocolor( 0,0,0,150 ),false ) end end ) addEventHandler ( 'onClientPlayerQuit', root, fDraw ) addEventHandler ( 'onClientPlayerJoin', root, fDraw )
-
Do I just change dxDrawText( sText,388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) to dxDrawRelativeText( sText,388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawRelativeRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) Because I tried and it goes nil everytime, not really sure what to do with "Relative", never seen in any script I've bumped in to so far.
-
it does look nice but it doesn't seem to work, asked a guy to login / logout and no text was shown. Scratch that, it does work, thank you so much for your help I really appreciate it! And I guess I missed something with the relative - it's nil. local sText = '' local uTimer function fDraw( ) sText = sText..string.format( '#FFFFFFServer: #FFFFFF%s has %s the server %s \n', getPlayerName( source ), eventName == 'onClientPlayerQuit' and 'left' or eventName == 'onClientPlayerJoin' and 'join', eventName == 'onClientPlayerQuit' and '(' .. quitReason .. ')' or '' ) if isTimer( uTimer ) then killTimer( uTimer ) end uTimer = setTimer( function( ) sText = '' end, 5000, 1 ) end addEventHandler( 'onClientRender', root, function( ) if sText ~= '' then dxDrawRelativeText( sText,254.0,0.0,585.0,25.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawRelativeRectangle( 258.0,0.0,328.0,21.0,tocolor( 0,0,0,150 ),false ) end end ) addEventHandler ( 'onClientPlayerQuit', root, fDraw ) addEventHandler ( 'onClientPlayerJoin', root, fDraw ) I guess I'm supposed to add something else but didn't you say like this earlier , also I "figured it out", join works, quit doesn't, it's something quitreason, saying it's nil or something Do I just add this: function dxDrawRelativeText( text,posX,posY,right,bottom,color,scale,mixed_font,alignX,alignY,clip,wordBreak,postGUI ) local resolutionX = 1280 local resolutionY = 1024 local sWidth,sHeight = guiGetScreenSize( ) return dxDrawText( tostring( text ), ( posX/resolutionX )*sWidth, ( posY/resolutionY )*sHeight, ( right/resolutionX )*sWidth, ( bottom/resolutionY)*sHeight, color,( sWidth/resolutionX )*scale, mixed_font, alignX, alignY, clip, wordBreak, postGUI ) end in the .lua file or what?
-
But I can't keep quitreason if it's playerjoin, or can I?
-
Oh, like this then: local sText = '' local uTimer addEventHandler ( 'onClientPlayerJoin', root, function() sText = sText..string.format( '#FFFFFFServer: #FFFFFF%s has joined the server (%s) \n',getPlayerName( source ) ) if isTimer( uTimer ) then killTimer( uTimer ) end uTimer = setTimer( function( ) sText = '' end, 5000, 1 ) end ) addEventHandler( 'onClientRender', root, function( ) if sText ~= '' then dxDrawRelativeText( sText,388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawRelativeRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) end end ) Also the onClientPlayerJoin, doesn't work, it gave error at line 34 about the string format (I can't login atm so I can't check exactly >.<)
-
Oh, okay, fantastic but I'm still worried about the resolution, or should it work fine on any resolution?
-
Use my code Which one you posted two & what's the difference between those two?
-
It's really hard to test this script without anyone around ._. Anyways, since that doesn't seem to stick to one spot on "every" resolution, I tried this: local sText, sReason = '','' local uTimer addEventHandler ( 'onClientPlayerQuit', root, function( quitReason ) sText, sReason = getPlayerName( source ), quitReason if isTimer( uTimer ) then killTimer( uTimer ) end uTimer = setTimer( function( ) sText = '' end, 5000, 1 ) end ) addEventHandler( 'onClientRender', root, function( ) local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. if sText ~= '' then dxDrawText( '#FFFFFFServer: #FFFFFF'.. sText .. ' has left the server (' .. sReason .. ')',nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.55,"bankgothic","left","top",false,false,false) dxDrawRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) end end ) local sText = '' local uTimer addEventHandler ( 'onClientPlayerJoin', root, function() sText = getPlayerName( source ) if isTimer( uTimer ) then killTimer( uTimer ) end uTimer = setTimer( function( ) sText = '' end, 5000, 1 ) end ) addEventHandler( 'onClientRender', root, function( ) local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. if sText ~= '' then dxDrawText( '#FFFFFFServer: #FFFFFF'.. sText .. ' has joined the server ',nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.55,"bankgothic","left","top",false,false,false) dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) end end ) Will this work or is it just rubbish Oh and by the way, how the hell do I calculate the positions? I have to try for like ages until I get it right PLUS I have to test when players login or quit, so it's very hard
-
(And I'll test it soon, thanks, imposible to figure that out by myself..) What do you mean? Like a row? like: name name name or when another guy logs in the previous name goes off? Also, this would be the playerjoin right? local sText = '' local uTimer addEventHandler ( 'onClientPlayerJoin', root, function() sText = getPlayerName( source ) if isTimer( uTimer ) then killTimer( uTimer ) end uTimer = setTimer( function( ) sText = '' end, 5000, 1 ) end ) addEventHandler( 'onClientRender', root, function( ) if sText ~= '' then dxDrawText( '#FFFFFFServer: #FFFFFF'.. sText .. ' has joined the server ',388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) dxDrawRectangle( 631.0,7.0,160.0,20.0,tocolor( 0,0,0,150 ),false ) end end ) Just have to make sure, your scripts are bit different from the other ones I have seen o_o
-
Haha , looks like we're looking for the same thing! https://forum.multitheftauto.com/viewtop ... 5350abc175
-
I tested with and without it, both of them, separete and so on, always returned nil, wasn't sure what to do and left them in there. I am completely lost
-
I am trying, that is why I'm here. function quiterPlayer ( quitReason ) local quiterPlayerName = getPlayerName ( source ) local root = getRootElement() local rootChildren = getElementChildren( root ) dxDrawText("#FFFFFFServer: #FFFFFF"..quiterPlayerName .. " has left the server (" .. quitReason .. ")",388.0,134.0,558.0,163.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) end addEventHandler ( "onClientPlayerQuit", getRootElement(), quiterPlayer ) addEventHandler("onClientResourceStart",resourceRoot, function() end ) -- Direct X Drawing addEventHandler("onClientRender",root, function() dxDrawRectangle(631.0,7.0,160.0,20.0,tocolor(0,0,0,150),false) end ) what about this then? though, this error turned up, input:8: attempt to call global 'getRootElement' (a nil value)
-
I ended up with this, no idea if it works as I can't see myself is this right?: addEventHandler("onClientResourceStart",resourceRoot, function() end ) -- Direct X Drawing addEventHandler("onClientRender",root, function() function remotePlayerJoin() dxDrawText("* " .. getPlayerName(source) .. " has joined the server",618.0,6.0,795.0,27.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) end addEventHandler("onClientPlayerJoin", getRootElement(), remotePlayerJoin) end ) -- Direct X Drawing addEventHandler("onClientRender",root, function() function remotePlayerJoin() dxDrawText("* " .. getPlayerName(source) .. " has left the server ("..reason..")",618.0,6.0,795.0,27.0,tocolor(255,255,255,255),1.0,"default","left","top",false,false,false) end addEventHandler("onClientPlayerJoin", getRootElement(), remotePlayerJoin) end ) addEventHandler("onClientResourceStart",resourceRoot, function() end ) -- Direct X Drawing addEventHandler("onClientRender",root, function() dxDrawRectangle(631.0,7.0,160.0,20.0,tocolor(0,0,0,150),false) end ) I also noticed that this caused a LOT of server lags for some reason
-
Hello, I'm just wondering if it is possible to use OnPlayerJoin and OnPlayerQuit together with dxDrawText somehow, including other server sided functions, such as onPlayerStealthKill
-
I think you have to explain more in detail, even I did not understand exactly what you meant with "random section".
-
I am working on it, I guess I'm just slow.. And yes, you're right, sorry, I didn't realize that the error had dissapeared after correcting the first issue.
-
Yup, it's working, thanks for the help, both of you I'm just worried about this one: bad argument @ 'addEventHandler' [expected element at arguement 2, got nil]
-
Edited my post and I know, I'm not that big of a noob EDIT: Wait a minute.. I fixed it, I had added the onguiclick outside the eventhandler.
-
That did work on stopsnake but not /snake, but I suppose that is because they're in two different .lua files (same folder due), any suggestions? >.< also I get this error: bad argument @ 'addEventHandler' [expected element at arguement 2, got nil] something to worry about? playSnake = guiCreateButton(0.05, 0.85, 0.20, 0.10, "Close", true, gameWindow) function clickHandler() executeCommandHandler("snake") end addEventHandler("onClientGUIClick",playSnake,clickHandler,false)
-
I don't get it, how do I attach that^ to a onClientGuiClick / guibutton ?
-
Hello, I just found this wonderful resource, https://community.multitheftauto.com/index.php?p= ... ails&id=30 but I would like to expand it's uses by adding a few GUIs instead of commands. So can I somehow add a GUI button and onClientGUIclick it triggers a commandhandler? ( /snake ) I've tried by adding so on onClientGUIclick it opens gameWindow but that failed and did not work at all. Client: size = 0.02 direction = "right" lastdir = "right" pause = false started = false firstStart = false checkbox = {} positions = {} positions[1] = 0.1 positions[2] = 10 positions[3] = 20 positions[4] = 30 positions[5] = 40 positions[6] = 50 positions[7] = 60 positions[8] = 70 positions[9] = 80 positions[10] = 90 function mainWindow () if not gameWindow then firstStart = true gameWindow = guiCreateWindow (0.2, 0.2, 0.6, 0.6, "Snake!", true) gameArea = guiCreateGridList (0.3, 0.06, 0.7, 0.95, true, gameWindow) score = guiCreateLabel(0.05, 0.1, 0, 0, "Score: 0", true, gameWindow) speed1 = guiCreateLabel(0.1, 0.53, 0, 0, "Speed", true, gameWindow) guiSetFont(speed1, "default-bold-small") guiSetSize ( speed1, guiLabelGetTextExtent ( speed1 ), guiLabelGetFontHeight ( speed1 ), false ) local sizeD = guiLabelGetFontHeight ( speed1 ) difficulty = guiCreateProgressBar (0.05, 0.55, 0.20, 0.10, true, gameWindow) local x, y = guiGetPosition(difficulty, false) local sx, sy = guiGetSize(difficulty, false) guiSetPosition(difficulty, x, y + sizeD, false) guiProgressBarSetProgress(difficulty, 1) addEventHandler("onClientGUIClick", difficulty, function (button, state, posX, posY) local cX = guiGetScreenSize() * getCursorPosition" class="kw4">getCursorPosition" class="kw4">getCursorPosition() local pX, pY = guiGetPosition(difficulty, false) local x = cX / pX local x = x - 8 local x = x * 28 local progress = x if progress <= 1 then progress = 1 elseif progress >= 100 then progress = 100 end guiProgressBarSetProgress(difficulty, math.floor(progress)) end, false) guiSetFont (score, "default-bold-small") startPause = guiCreateButton(0.05, 0.7, 0.20, 0.10, "Start!", true, gameWindow) addEventHandler("onClientGUIClick", startPause, startOrPauseSnake, false) guiSetSize ( score, guiLabelGetTextExtent ( score ), guiLabelGetFontHeight ( score ), false ) currentScore = 0 showCursor(true) else guiSetVisible(gameWindow, true) showCursor(true) end bindKey ("arrow_u", "down", function () direction = "up" end) bindKey ("arrow_r", "down", function () direction = "right" end) bindKey ("arrow_d", "down", function () direction = "down" end) bindKey ("arrow_l", "down", function () direction = "left" end) bindKey ("space", "down", startOrPauseSnake) end addCommandHandler("snake", mainWindow) --progress == - 10 per progress function startOrPauseSnake () local progress = guiProgressBarGetProgress(difficulty) time = 450 - ( progress * 4.5 ) + 50 if started == false then started = true if gameOver then destroyElement(gameOver) end guiSetText(startPause, "Pause!") checkbox = {} direction = "right" lastdir = "right" currentScore = 0 guiSetText (score, "Score: "..currentScore) checkbox[1] = guiCreateCheckBox(0.4,0.4, size, size, "", true, true, gameArea) checkbox[2] = guiCreateCheckBox(0.4-size,0.4, size, size, "", false, true, gameArea) checkbox[3] = guiCreateCheckBox(0.4-size-size,0.4, size, size, "", false, true, gameArea) checkbox[4] = guiCreateCheckBox(0.4-size-size-size,0.4, size, size, "", false, true, gameArea) x = positions[math.random(1, 10)] / 100 y = positions[math.random(1, 10)] / 100 fruit = guiCreateCheckBox (x, y, size, size, "", true, true, gameArea) movement = setTimer(moveit, time, 0) last = #checkbox else if pause == false then guiSetText(startPause, "Start!") killTimer(movement) pause = true else guiSetText(startPause, "Pause!") movement = setTimer(moveit, time, 0) pause = false end end end function stopTheSnake () if ( wannaStart ) then guiSetVisible(wannaStart, false) showCursor(false) end if firstStart == false then return end if started == true and pause == false then killTimer(movement) pause = true guiSetText(startPause, "Start!") guiSetVisible(gameWindow, false) showCursor(false) elseif started == true and pause == true then guiSetVisible(gameWindow, false) showCursor(false) elseif started == false then guiSetVisible(gameWindow, false) showCursor(false) end unbindKey ("arrow_u", "down") unbindKey ("arrow_r", "down") unbindKey ("arrow_d", "down") unbindKey ("arrow_l", "down") unbindKey ("space", "down", startOrPauseSnake) end addEvent("stopSnakeC", true) addEventHandler("stopSnakeC", getRootElement(), stopTheSnake) addCommandHandler("stopsnake", stopTheSnake) addEvent("startSnakeC", true) addEventHandler("startSnakeC", getRootElement(), function () if not wannaStart then showCursor(true) wannaStart = guiCreateWindow (0.4,0.3, 0, 0, "Play Snake?", true) guiSetSize(wannaStart, 250, 200, false) playText = guiCreateLabel(0.1, 0.3, 0.9,0.7, "Would you like to play some snake while you wait?", true, wannaStart) guiSetFont(playText, "default-bold-small") guiLabelSetHorizontalAlign(playText, "left", true) --guiSetSize ( playText, guiLabelGetTextExtent ( playText ), guiLabelGetFontHeight ( playText ), false ) yeaplay = guiCreateButton(0.1, 0.8, 0.3, 0.2, "Yes", true, wannaStart) addEventHandler("onClientGUIClick", yeaplay, function () guiSetVisible(wannaStart, false) mainWindow () end, false) noplay = guiCreateButton(0.6, 0.8, 0.3, 0.2, "No", true, wannaStart) addEventHandler("onClientGUIClick", noplay, function () guiSetVisible(wannaStart, false) showCursor(false) end, false) else guiSetVisible(wannaStart, true) showCursor(true) end end) posX = {} posY = {} function moveit () --posX[1], posY[1] = guiGetPosition(checkbox[1], true) i = 0 if direction == "right" then if lastdir == "left" then direction = "left" else lastdir = "right" for k,v in ipairs(checkbox) do i = i + 1 if v == checkbox[1] then posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i] + (size ), posY[i], true) --posX, posY = guiGetPosition(v, true) else posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i-1], posY[i-1], true) end end end elseif direction == "down" then if lastdir == "up" then direction = "up" else lastdir = "down" for k,v in ipairs(checkbox) do i = i + 1 if v == checkbox[1] then posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i], posY[i] + (size ), true) --posX, posY = guiGetPosition(v, true) else posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i-1], posY[i-1], true) end end end elseif direction == "left" then if lastdir == "right" then direction = "right" else lastdir = "left" for k,v in ipairs(checkbox) do i = i + 1 if v == checkbox[1] then posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i] - (size), posY[i], true) --posX, posY = guiGetPosition(v, true) else posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i-1], posY[i-1], true) end end end elseif direction == "up" then if lastdir == "down" then direction = "down" else lastdir = "up" for k,v in ipairs(checkbox) do i = i + 1 if v == checkbox[1] then posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i], posY[i] - (size ), true) --posX, posY = guiGetPosition(v, true) else posX[i], posY[i] = guiGetPosition(v, true) guiSetPosition(v, posX[i-1], posY[i-1], true) end end end end headX, headY = guiGetPosition(checkbox[1], true) if headX < -0.01 or headX >= 0.99 or headY < -0.01 or headY >= 0.99 then killTimer(movement) --outputChatBox ("Game Over") gameOver = guiCreateLabel (0.3, 0.5, 0, 0, "Game over!", true, gameArea) guiSetFont (gameOver, "default-bold-small") guiSetSize ( gameOver, guiLabelGetTextExtent ( gameOver ), guiLabelGetFontHeight ( gameOver ), false ) last = #checkbox blinks = 0 snakeVisible = true gameover1 = setTimer (destroySnake, 400, 10) end for k,v in ipairs(checkbox) do if v ~= checkbox[1] then local x, y = guiGetPosition(v, true) if x == headX and y == headY then killTimer(movement) --outputChatBox ("Game Over") gameOver = guiCreateLabel (0.3, 0.5, 0, 0, "Game over!", true, gameArea) guiSetSize ( gameOver, guiLabelGetTextExtent ( gameOver ), guiLabelGetFontHeight ( gameOver ), false ) last = #checkbox guiSetFont (gameOver, "default-bold-small") blinks = 0 snakeVisible = true gameover1 = setTimer (destroySnake, 400, 10)
-
What you mean? You mean this https://wiki.multitheftauto.com/wiki/OnClientGUIChanged ? I think so but I still don't understand how to do it EDIT: It seems way too hard for me to be honest, so I decided to add the command while inside a specific marker (I'm using these for jobs originally, that's why there's Bus thingies, trying to fix the main thing first). So this is what I got: local jobmarker13 = createMarker ( 737.0986328125, -1344.3818359375, 12.518682479858, "cylinder", 1.3, 255, 255, 153, 15 ) function renderRectangleCar() local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. --Draw texts and background dxDrawRectangle ( x/3.3, y/1.59, x/2.2, y/4.35, tocolor ( 255, 255, 255, 60 ) ) dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) dxDrawText("Los Santos Bus Driver Job",nSw/3, nSh/1.57, nSw, nSh,tocolor(0,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText("Use /acceptjob to accept this job",nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.55,"bankgothic","left","top",false,false,false) dxDrawText("Objective: Drive your route with bus ",nSw/3, nSh/1.3, nSw, nSh,tocolor(255,255,255,185),0.48,"bankgothic","left","top",false,false,false) dxDrawText("Job Pays: 95$ per stop (( Checkpoint )) ",nSw/3, nSh/1.25, nSw, nSh,tocolor(255,255,255,185),0.48,"bankgothic","left","top",false,false,false) dxDrawText("/quitjob if this job doesn't suit you",nSw/3, nSh/1.2, nSw, nSh,tocolor(255,0,0,185),0.48,"bankgothic","left","top",false,false,false) end --Add text on markerHit function jobmarker13Hit () if isElementWithinMarker(localPlayer, jobmarker13) then addEventHandler("onClientRender",root,renderRectangleCar) outputChatBox(" [English] Peter Edwards says: Hello there, you interested in a job?", 255, 255, 255) end end addEventHandler( "onClientMarkerHit", jobmarker13, jobmarker13Hit ) --Hide dxDrawings upon markerLeave function jobmarker13Leave () removeEventHandler("onClientRender",root,renderRectangleCar) end addEventHandler( "onClientMarkerLeave", jobmarker13, jobmarker13Leave ) --acceptjob command while inside marker function useLight() if isElementWithinMarker(localPlayer, jobmarker13) then local theVehicle = getPedOccupiedVehicle ( thePlayer ) if ( not theVehicle ) then return outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end red = tonumber ( red ) green = tonumber ( green ) blue = tonumber ( blue ) -- check if the colour values for red, green and blue are valid if red and green and blue then local color = setVehicleHeadLightColor ( theVehicle, red, green, blue ) if(not color) then outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) else outputChatBox ( "Vehicle lights color changed sucessfully", thePlayer, 255, 194, 14 ) end else outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end end end addCommandHandler("carlights", useLight) But isn't working, 39: bad argument @ 'isElementWithinMarker' gives the error while outside the marker & inside and doesn't change the vehicle lights.
-
Hello, I've been trying to figure out how to attach: function changeCarLightsColor ( thePlayer, command, red, green, blue ) local theVehicle = getPedOccupiedVehicle ( thePlayer ) if ( not theVehicle ) then return outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end red = tonumber ( red ) green = tonumber ( green ) blue = tonumber ( blue ) -- check if the colour values for red, green and blue are valid if red and green and blue then local color = setVehicleHeadLightColor ( theVehicle, red, green, blue ) if(not color) then outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) else outputChatBox ( "Vehicle lights color changed sucessfully", thePlayer, 255, 194, 14 ) end else outputChatBox( "SYNTAX: /carlights [color1] [color2] [color3]", thePlayer, 255, 194, 14 ) end end addCommandHandler ( "carlights", changeCarLightsColor ) To a GUI, The GUI I am using is: addEventHandler("onClientResourceStart",resourceRoot, function() GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Label = {} GUIEditor_Edit = {} GUIEditor_Window[1] = guiCreateWindow(281,193,320,236,"Vehicle Headlights",false) GUIEditor_Edit[1] = guiCreateEdit(74,70,163,26,"",false,GUIEditor_Window[1]) GUIEditor_Edit[2] = guiCreateEdit(75,127,164,26,"",false,GUIEditor_Window[1]) GUIEditor_Edit[3] = guiCreateEdit(76,184,164,28,"",false,GUIEditor_Window[1]) GUIEditor_Label[1] = guiCreateLabel(76,43,158,18,"Red, 0-255",false,GUIEditor_Window[1]) GUIEditor_Label[2] = guiCreateLabel(75,103,160,19,"Green, 0-255",false,GUIEditor_Window[1]) GUIEditor_Label[3] = guiCreateLabel(79,160,131,21,"Blue, 0-255",false,GUIEditor_Window[1]) GUIEditor_Button[1] = guiCreateButton(250,184,57,40,"Close",false,GUIEditor_Window[1]) GUIEditor_Button[2] = guiCreateButton(250,145,55,29,"Buy Lights",false,GUIEditor_Window[1]) end ) How do I make the guiEdits functionable?
-
Alright, I'll give it a try and yeh, I just noticed aldready fixed, thanks anyways ^.^ EDIT: how am I supposed to add a 3D text above a specific area/NPC's head?, I only want it to show on one spot. EDIT: How do I do this with the marker , it seems easier. Like this: Also, how can I restrict the marker from letting people see it while being in the air? It's visible from any range, as long as you're over it. local jobmarker2 = createMarker ( 1917.20703125, -1863.583984375, 12.561410903931, "cylinder", 1.3, 255, 255, 153, 15 ) function renderRectangleMechanic() local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. --Draw texts and background guiCreateStaticImage(581,625,105,78,"images/key.png",false) dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) dxDrawText(" Los Santos Mechanic Job",nSw/3, nSh/1.57, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText(" Use /acceptjob to accept this job",nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.6,"bankgothic","left","top",false,false,false) dxDrawText("This job pays: N/A$ per person (( Player )) ",nSw/3, nSh/1.25, nSw, nSh,tocolor(255,255,255,185),0.5,"bankgothic","left","top",false,false,false) dxDrawText("/quitjob if this job does not suit you",nSw/3, nSh/1.2, nSw, nSh,tocolor(255,255,255,185),0.55,"bankgothic","left","top",false,false,false) end --Add text on markerHit function jobmarker2Hit () if isElementWithinMarker(localPlayer, jobmarker2) then addEventHandler("onClientRender",root,renderRectangleMechanic) end end addEventHandler( "onClientMarkerHit", jobmarker2, jobmarker2Hit ) --Hide dxDrawings upon markerLeave function jobmarker2Leave () removeEventHandler("onClientRender",root,renderRectangleMechanic) end addEventHandler( "onClientMarkerLeave", jobmarker2, jobmarker2Leave ) --acceptjob command while inside marker function useJob() if isElementWithinMarker(localPlayer, jobmarker2) then local job = getElementData(localPlayer, "job") if ( job > 0 ) then outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", thePlayer, 0, 255, 0, 0) else triggerServerEvent("acceptJob", localPlayer, 5) outputChatBox("You are now a licensed mechanic.", thePlayer, 0, 190, 0, 0) end end end addCommandHandler("acceptjob", useJob)
-
Ah, thank you for all your help, but I somehow bumped into another problem on the way which I just spotted. There's 5 different jobs and every job has a different .lua file, for some reason, they mix together (dxDrawings only) This is what I have.... local jobmarker5 = createMarker ( -70.373046875, -1136.9384765625, 0.078125, "cylinder", 1.3, 255, 255, 153, 15 ) function renderRectangle() local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. --Draw texts and background dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) dxDrawText(" Los Santos Delivery Job",nSw/3, nSh/1.57, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText("Use /acceptjob to accept this job",nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText("/quitjob if this job do not suit you",nSw/3, nSh/1.2, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) end --Add text on markerHit function jobmarkerHit () addEventHandler("onClientRender",root,renderRectangle) end addEventHandler( "onClientMarkerHit", jobmarker5, jobmarkerHit ) --Hide dxDrawings upon markerLeave function jobmarkerLeave () removeEventHandler("onClientRender",root,renderRectangle) end addEventHandler( "onClientMarkerLeave", jobmarker5, jobmarkerLeave ) --acceptjob command while inside marker function useJob() if isElementWithinMarker(localPlayer, jobmarker5) then local job = getElementData(localPlayer, "job") if ( job > 0 ) then outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", thePlayer, 0, 255, 0, 0) else triggerServerEvent("acceptJob", localPlayer, 7) outputChatBox("You are now an employee at Jim's Rings Donut Delivery's.", thePlayer, 0, 190, 0, 0) end end end addCommandHandler("acceptjob", useJob) Here's a second job marker (Might help): local jobmarker4 = createMarker ( 1783.376953125, -1885.7841796875, 12.391790390015, "cylinder", 1.3, 255, 255, 153, 15 ) function renderRectangle() local screenWidth, screenHeight = guiGetScreenSize() local nSw,nSh = guiGetScreenSize( ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. --Draw texts and background dxDrawRectangle ( x/3.4, y/1.6, x/2.13, y/4.2, tocolor ( 0, 0, 0, 150 ) ) dxDrawText(" Los Santos Taxi Driver Job",nSw/3, nSh/1.57, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText("Use /acceptjob to accept this job",nSw/3, nSh/1.47, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) dxDrawText("/quitjob if this job do not suit you",nSw/3, nSh/1.2, nSw, nSh,tocolor(255,255,255,185),0.7,"bankgothic","left","top",false,false,false) end --Add text on markerHit function jobmarker4Hit () addEventHandler("onClientRender",root,renderRectangle) end addEventHandler( "onClientMarkerHit", jobmarker4, jobmarkerHit ) --Hide dxDrawings upon markerLeave function jobmarkerLeave () removeEventHandler("onClientRender",root,renderRectangle) end addEventHandler( "onClientMarkerLeave", jobmarker4, jobmarkerLeave ) --acceptjob command while inside marker function useJob() if isElementWithinMarker(localPlayer, jobmarker4) then local job = getElementData(localPlayer, "job") if ( job > 0 ) then outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", thePlayer, 0, 255, 0, 0) else triggerServerEvent("acceptJob", localPlayer, 2) outputChatBox("You are now a licensed taxi driver.", thePlayer, 0, 190, 0, 0) end end end addCommandHandler("acceptjob", useJob) And one question, is it possible to add an image or text above this guy's head (that is attached to him). local jim = createPed( 0, 1019.2646484375, -1348.587890625, 13.548809051514, 89 ) -- 0 = CJ skin. setElementDimension( jim, 0 ) setElementData( jim, "talk", 1 ) setElementData( jim, "name", "Jim Clark" ) setPedAnimation ( jim, "INT_OFFICE", "OFF_Sit_Idle_Loop", -1, true, false, false ) setElementFrozen(jim, true)