Absence2
Members-
Posts
267 -
Joined
-
Last visited
Everything posted by Absence2
-
Thank you , almost everything is figured out now, there's only one thing remaining and that is a Ped standing next to it. I tried with this: local jobmarker = createMarker ( 1019.2646484375, -1348.587890625, 12.548809051514, "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(" Jim's Rings Donut 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.27, 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) outputChatBox("(( Jim's Rings Donut Delivery Job ))", thePlayer, 255, 153, 0) end addEventHandler( "onClientMarkerHit", jobmarker, jobmarkerHit ) --Hide dxDrawings upon markerLeave function jobmarkerLeave () removeEventHandler("onClientRender",root,renderRectangle) end addEventHandler( "onClientMarkerLeave", jobmarker, jobmarkerLeave ) --acceptjob command while inside marker function useJob() if isElementWithinMarker(localPlayer, jobmarker) 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 employed at Jim's Rings Donut Delivery's.", thePlayer, 0, 190, 0, 0) end end end addCommandHandler("acceptjob", useJob) local jim = createPed( 1019.2646484375, -1348.587890625, 13.548809051514 ) setPedRotation( jim, 89 ) setElementDimension( jim, 0 ) setElementInterior( 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) But it bombed me with errors (the Ped thingies)
-
You make me feel like a complete noob ._., well can't deny facts! I just need help with one last thing, function useJob() if isElementWithinMarker(localPlayer, jobmarker) then triggerServerEvent("acceptJob", localPlayer, 7) end end addCommandHandler("job", useJob) If you successfuly got the job with /job a text appears in outputChatBox, like "You're now working for Jim's Rings" And if you're employed aldready: "You are already employed, please quit your other job first (( /quitjob ))" function acceptJob(button, state) if (button=="left") then local row, col = guiGridListGetSelectedItem(jobList) local job = getElementData(getLocalPlayer(), "job") if (row==-1) or (col==-1) then outputChatBox("Please select a job first!", 255, 0, 0) elseif (job>0) then outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", 255, 0, 0) else local job = 0 local jobtext = guiGridListGetItemText(jobList, guiGridListGetSelectedItem(jobList), 1) if ( jobtext=="Delivery Driver" or jobtext=="Taxi Driver" or jobtext=="Bus Driver" ) then -- Driving job, requires the license local carlicense = getElementData(getLocalPlayer(), "license.car") if (carlicense~=1) then outputChatBox("You require a drivers license to do this job.", 255, 0, 0) return end end
-
Thanks, works But I think I've put water over my head, the useJob function was merely a test on how to add a command within a Marker. local jobmarker = createMarker ( 1192.25390625, -1324.5009765625, 12.3984375, "cylinder", 1.2, 255, 255, 153, 50 ) function renderRectangle() local x,y = guiGetScreenSize() -- Get players resolution. dxDrawRectangle(233.0,472.0,363.0,125.0,tocolor(0,0,0,150),false) dxDrawText("Jim's Rings Donut Delivery Job",241.0,477.0,588.0,499.0,tocolor(255,255,255,255),0.6,"bankgothic","left","top",false,false,false) dxDrawLine(586.0,502.0,241.0,502.0,tocolor(255,255,255,255),1.0,false) end function jobmarkerHit () addEventHandler("onClientRender",root,renderRectangle) outputChatBox("This is a test message", 255, 153, 0) outputChatBox("This is a second test message", 255, 153, 0) end addEventHandler( "onClientMarkerHit", jobmarker, jobmarkerHit ) function jobmarkerLeave () removeEventHandler("onClientRender",root,renderRectangle) end addEventHandler( "onClientMarkerLeave", jobmarker, jobmarkerLeave ) function useJob() if isElementWithinMarker(localPlayer, jobmarker) then if exports.global:hasMoney(localPlayer, 50) then exports.global:giveMoney(localPlayer, 50) outputChatBox("You have been given 50$ due to testing purposes.", 0, 255, 0) else outputChatBox("You are not at the right place!", 255, 0, 0) end end end addCommandHandler("job", useJob) I'm trying to get the useJob function to a "givejob" thingy, but I have no idea what so ever on how to do it. This is the Job script I'm using, Client: wEmployment, jobList, bAcceptJob, bCancel = nil local jessie = createPed( 141, 359.712890625, 173.5654296875, 1008.3893432617 ) --local jessie = createPed( 141, 359.7060, 173.5371, 1008.3828 ) setPedRotation( jessie, 271 ) setElementDimension( jessie, 5 ) setElementInterior( jessie , 3 ) setElementData( jessie, "talk", 1 ) setElementData( jessie, "name", "Jessie Smith" ) setPedAnimation ( jessie, "INT_OFFICE", "OFF_Sit_Idle_Loop", -1, true, false, false ) setElementFrozen(jessie, true) function showEmploymentWindow() -- Employment Tooltip if(getResourceFromName("tooltips-system"))then triggerEvent("tooltips:showHelp",getLocalPlayer(),7) end triggerServerEvent("onEmploymentServer", getLocalPlayer()) local width, height = 300, 400 local scrWidth, scrHeight = guiGetScreenSize() local x = scrWidth/2 - (width/2) local y = scrHeight/2 - (height/2) wEmployment = guiCreateWindow(x, y, width, height, "Job Pinboard", false) jobList = guiCreateGridList(0.05, 0.05, 0.9, 0.8, true, wEmployment) local column = guiGridListAddColumn(jobList, "Job Title", 0.9) -- TRUCKER local row = guiGridListAddRow(jobList) guiGridListSetItemText(jobList, row, column, "Delivery Driver", false, false) -- TAXI local row = guiGridListAddRow(jobList) guiGridListSetItemText(jobList, row, column, "Taxi Driver", false, false) -- BUS local row = guiGridListAddRow(jobList) guiGridListSetItemText(jobList, row, column, "Bus Driver", false, false) -- CITY MAINTENACE local team = getPlayerTeam(getLocalPlayer()) local ftype = getElementData(team, "type") if ftype ~= 2 then local rowmaintenance = guiGridListAddRow(jobList) guiGridListSetItemText(jobList, rowmaintenance, column, "City Maintenance", false, false) end -- MECHANIC local row = guiGridListAddRow(jobList) guiGridListSetItemText(jobList, row, column, "Mechanic", false, false) -- LOCKSMITH local row = guiGridListAddRow(jobList) guiGridListSetItemText(jobList, row, column, "Locksmith", false, false) bAcceptJob = guiCreateButton(0.05, 0.85, 0.45, 0.1, "Accept Job", true, wEmployment) bCancel = guiCreateButton(0.5, 0.85, 0.45, 0.1, "Cancel", true, wEmployment) showCursor(true) addEventHandler("onClientGUIClick", bAcceptJob, acceptJob) addEventHandler("onClientGUIDoubleClick", jobList, acceptJob) addEventHandler("onClientGUIClick", bCancel, cancelJob) end addEvent("onEmployment", true) addEventHandler("onEmployment", getRootElement(), showEmploymentWindow) function acceptJob(button, state) if (button=="left") then local row, col = guiGridListGetSelectedItem(jobList) local job = getElementData(getLocalPlayer(), "job") if (row==-1) or (col==-1) then outputChatBox("Please select a job first!", 255, 0, 0) elseif (job>0) then outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", 255, 0, 0) else local job = 0 local jobtext = guiGridListGetItemText(jobList, guiGridListGetSelectedItem(jobList), 1) if ( jobtext=="Delivery Driver" or jobtext=="Taxi Driver" or jobtext=="Bus Driver" ) then -- Driving job, requires the license local carlicense = getElementData(getLocalPlayer(), "license.car") if (carlicense~=1) then outputChatBox("You require a drivers license to do this job.", 255, 0, 0) return end end if (jobtext=="Delivery Driver") then displayTruckerJob() job = 1 elseif (jobtext=="Taxi Driver") then job = 2 displayTaxiJob() elseif (jobtext=="Bus Driver") then job = 3 displayBusJob() elseif (jobtext=="City Maintenance") then job = 4 elseif (jobtext=="Mechanic") then displayMechanicJob() triggerServerEvent("giveMechanicJob", getLocalPlayer()) job = 5 elseif (jobtext=="Locksmith") then displayLocksmithJob() job = 6 end triggerServerEvent("acceptJob", getLocalPlayer(), job) destroyElement(jobList) destroyElement(bAcceptJob) destroyElement(bCancel) destroyElement(wEmployment) wEmployment, jobList, bAcceptJob, bCancel = nil, nil, nil, nil showCursor(false) end end end function cancelJob(button, state) if (source==bCancel) and (button=="left") then destroyElement(jobList) destroyElement(bAcceptJob) destroyElement(bCancel) destroyElement(wEmployment) wEmployment, jobList, bAcceptJob, bCancel = nil, nil, nil, nil showCursor(false) end end Server: mysql = exports.mysql chDimension = 125 chInterior = 3 -- CALL BACKS FROM CLIENT function onEmploymentServer() exports.global:sendLocalText(source, "Jessie Smith says: Hello, are you looking for a new job?", nil, nil, nil, 10) exports.global:sendLocalText(source, " *Jessie Smith hands over a list with jobs to " .. getPlayerName(source):gsub("_", " ") .. ".", 255, 51, 102) end addEvent("onEmploymentServer", true) addEventHandler("onEmploymentServer", getRootElement(), onEmploymentServer) function givePlayerJob(jobID) local charname = getPlayerName(source) exports['anticheat-system']:changeProtectedElementDataEx(source, "job", jobID) mysql:query_free("UPDATE characters SET job=" .. mysql:escape_string(jobID) .. ", jobcontract = 3 WHERE id = " .. mysql:escape_string(getElementData(source, "dbid")) ) exports.global:givePlayerAchievement(source, 30) if (jobID==4) then -- CITY MAINTENANCE exports.global:giveWeapon(source, 41, 1500, true) outputChatBox("Use this paint to paint over tags you find.", source, 255, 194, 14) exports['anticheat-system']:changeProtectedElementDataEx(source, "tag", 9) mysql:query_free("UPDATE characters SET tag=9 WHERE id = " .. mysql:escape_string(getElementData(source, "dbid")) ) end end addEvent("acceptJob", true) addEventHandler("acceptJob", getRootElement(), givePlayerJob) function quitJob(source) local logged = getElementData(source, "loggedin") if logged == 1 then local job = getElementData(source, "job") if job == 0 then outputChatBox("You are currently unemployed.", source, 255, 0, 0) else local result = mysql:query_fetch_assoc("SELECT jobcontract FROM characters WHERE id = " .. mysql:escape_string(getElementData(source, "dbid")) ) if result then local contracttime = tonumber( result["jobcontract"] ) or 0 if contracttime > 1 then outputChatBox( "You need to wait " .. contracttime .. " payday(s) before you can leave your job.", source, 255, 0, 0) else exports['anticheat-system']:changeProtectedElementDataEx(source, "job", 0) mysql:query_free("UPDATE characters SET job=0 WHERE id = " .. mysql:escape_string(getElementData(source, "dbid")) ) if job == 4 then exports['anticheat-system']:changeProtectedElementDataEx(source, "tag", 1) mysql:query_free("UPDATE characters SET tag=1 WHERE id = " .. mysql:escape_string(getElementData(source, "dbid")) ) end triggerClientEvent(source, "quitJob", source, job) end else outputDebugString( "QuitJob: SQL error" ) end end end end addCommandHandler("endjob", quitJob, false, false) addCommandHandler("quitjob", quitJob, false, false) function resetContract( thePlayer, commandName, targetPlayerName ) if exports.global:isPlayerAdmin( thePlayer ) then if targetPlayerName then local targetPlayer, targetPlayerName = exports.global:findPlayerByPartialNick( thePlayer, targetPlayerName ) if targetPlayer then if getElementData( targetPlayer, "loggedin" ) == 1 then local result = mysql:query_free("UPDATE characters SET jobcontract = 0 WHERE id = " .. mysql:escape_string(getElementData( targetPlayer, "dbid" )) .. " AND jobcontract > 0" ) if result then outputChatBox( "Reset Job Contract for " .. targetPlayerName, thePlayer, 0, 255, 0 ) else outputChatBox( "Failed to reset Job Contract Time.", thePlayer, 255, 0, 0 ) end else outputChatBox( "Player is not logged in.", thePlayer, 255, 0, 0 ) end end else outputChatBox( "SYNTAX: /" .. commandName .. " [player]", thePlayer, 255, 194, 14 ) end end end addCommandHandler("resetcontract", resetContract, false, false) function setMechanicData( ) exports['anticheat-system']:changeProtectedElementDataEx(source, "job", 5, true) end addEvent("giveMechanicJob", true) addEventHandler("giveMechanicJob", getRootElement(), setMechanicData) function checkJob(thePlayer, commandName) if (exports.global:isPlayerHeadAdmin(thePlayer)) then jobdata = getElementData(thePlayer, "job") outputChatBox("Job: "..jobdata, thePlayer, 255, 194, 14) end end addCommandHandler("checkjob", checkJob) To simplify it, I'm trying to make the /job command give you Job ID 7.
-
Like this? local jobmarker = createMarker ( 1192.25390625, -1324.5009765625, 13.3984375, "cylinder", 1.0, 0, 255, 255, 50 ) function jobmarkerFunction (thePlayer) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. addEventHandler("onClientRender",root, function() dxDrawRectangle(226.0,97.0,387.0,402.0,tocolor(255,255,255,255),false) end ) outputChatBox("This is a test message", thePlayer, 255, 153, 0) outputChatBox("This is a second test message", thePlayer, 255, 153, 0) end addEventHandler( "onClientMarkerHit", jobmarker, jobmarkerFunction ) function useJob(thePlayer, matchingDimension) if isElementWithinMarker(thePlayer, jobmarker) then if exports.global:hasMoney(thePlayer, 50) then exports.global:giveMoney(thePlayer, 50) outputChatBox("You have been given 50$ due to testing purposes.", thePlayer, 0, 255, 0) else outputChatBox("You are not at the right place!", thePlayer, 255, 0, 0) end end end addCommandHandler("job", useJob) The Rectangle shows but it doesn't hide after leaving the marker
-
Hehe, I figured half of it out after Scooby's post but not the second part, so I'll be using yours, Solid. But 10:bad argument @ 'isElementWithinMarker' that error still occurs after using /job, but it works.. Is it something I should be worried about? Also I guess I'm mixing client & server functions again, but, how do I add dxDrawings upon markerhit? like dxDrawRectangle ( x/3.8, y/3.8, x/2.02, y/2, tocolor ( 0, 0, 0, 150 ) ) Also, why does the every text duplicate upon markerhit?
-
Hello, I've been trying to script a Marker, adding the marker itself wasn't very hard, but now I need to add some handlers. So this is what I got: local jobmarker = createMarker ( 1192.25390625, -1324.5009765625, 13.3984375, "cylinder", 1.0, 0, 255, 255, 50 ) function jobmarker (thePlayer) outputChatBox("This is a test message", thePlayer, 255, 153, 0) outputChatBox("This is a second test message", thePlayer, 255, 153, 0) end addEventHandler( "onMarkerHit", jobmarker, jobmarker1 ) function useJob(thePlayer, matchingDimension) if isElementWithinMarker(thePlayer, jobmarker) then local localPlayer = getLocalPlayer ( ) if exports.global:hasMoney(player, 50) then exports.global:giveMoney(player, 50) outputChatBox("You have been given 50$ due to testing purposes.", player, 0, 255, 0) else outputChatBox("You are not at the right place!", thePlayer, 255, 0, 0) end end end addCommandHandler("job", useJob) attempt to call global 'GuiGetScreenSize' (a nil value) 14:bad argument @ 'isElementWithinMarker' 11: bad argument @ 'addeventhandler' [expected element at argument 2, got function] The outputChatBox messages doesn't show either. The whole thing is basically f*****'d
-
Well, when those resources are being loaded in it's completely black, only the chat will show (as far as I know) with some simple line: function welcomeMessage() outputChatBox ( "Welcome Message: Dadadum", source, 255, 255, 0, true ) end addEventHandler("onPlayerJoin", getRootElement(), welcomeMessage) But how do I do the same thing with an Image or a Slideshow while resources are being downloaded?
-
I used that because your codes was hard and I couldn't understand them By the way! Those Lines doesn't fit well with different resolutions, any suggestions? EDIT: I'm adding a couple of things now, but I need help because I got lost again I'm trying to add so it displays jobs. There is 7 jobs in total. This is my code right now: mysql = exports.mysql local bState, bDraw local sMsg = [[Recent Server Updates Illegal Gun Vendors Shop stands New HUD Helpchat on F1 User Panel New exteriors/interiors Minor bug fixes Mechanic Job fixed (You can only use it inside interiors) (There's garages for this, due to non-rp) Vehicle Color Fix, Furnite Shops added (Blue doll blip on F11) ]] local nSw,nSh = guiGetScreenSize( ) local nWindowW = 280 local bState, bDraw local sMsg = [[Recent Server Updates Illegal Gun Vendors Shop stands New HUD Helpchat on F1 User Panel New exteriors/interiors Minor bug fixes Mechanic Job fixed (You can only use it inside interiors) (There's garages for this, due to non-rp)) Vehicle Color Fix, Furnite Shops added (Blue doll blip on F11) ]] local nSw,nSh = guiGetScreenSize( ) local nWindowW = 380 local nWindowH = 400 local sWindowTitle = "" local nWindowTitleHeight = 20 local nWindowTitleColor = tocolor( 255,255,255,255 ) --local windowTitleBGColor = tocolor( 0,0,0,255 ) local nWindowBGColor = tocolor( 0,0,0,205 ) local nWindowX = nSw - 250 - nWindowW local nWindowY = nSh / 2.28 - nWindowH / 2 local nRepWinWidth, nRepWinHeight = 280, 450 local nRepWinX = nSw / 2 - ( nRepWinWidth / 2 ) local nRepWinY = nSh / 2 - ( nRepWinHeight / 2 ) local nX = nWindowX local nY = nWindowY + nWindowTitleHeight local nH = nWindowH - nWindowTitleHeight local x,y = guiGetScreenSize() local uRoot = guiCreateMemo( x/2.8, y/2.8, x/3.5, y/3.4,sMsg,false ) guiSetVisible( uRoot,false ) function fPress( ) bState = not bState guiSetVisible( uRoot,bState ) showCursor ( not isCursorShowing( ) ) bDraw = not bDraw end function fDraw( ) if bDraw then local playerName = getPlayerName ( localPlayer ) local money = getPlayerMoney( localPlayer ) local ping = getPlayerPing( localPlayer ) local playerX, playerY, playerZ = getElementPosition( localPlayer ) local playerZoneName = getZoneName( playerX, playerY, playerZ ) local health = getElementHealth( localPlayer ) local armour = getPedArmor( localPlayer ) local weaponType = getPedWeapon ( localPlayer ) local admin = getElementData(getLocalPlayer(), "adminlevel") local donator = tonumber(getElementData(getLocalPlayer(), "donatorlevel")) local muted = getElementData(getLocalPlayer(), "muted") local job = getElementData(getLocalPlayer(), "job") if weaponType then weaponType = getWeaponNameFromID( weaponType ) else weaponType = '' end local money = getElementData( localPlayer, "bankmoney" ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. dxDrawRectangle ( x/2.93, y/5.1, x/3.13, y/1.87, tocolor ( 255, 255, 255, 50 ) ) dxDrawRectangle ( x/2.9, y/5, x/3.2, y/1.9, tocolor ( 0, 0, 0, 200 ) ) dxDrawRectangle ( x/3.02, y/1.37, x/2.963, y/8.4, tocolor ( 255, 255, 255, 50 ) ) dxDrawRectangle ( x/3, y/1.36, x/3, y/9, tocolor ( 0, 0, 0, 200 ) ) dxDrawText( "Job: " ..tostring( job ),nSw/2.88, nSh/1.27, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Location: " ..tostring( playerZoneName ),nSw/2.88, nSh/1.43, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Ping: " ..tostring( ping ),nSw/1.84, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) if (admin==0) then dxDrawText( "Admin: No (LVL:" ..tostring(admin).. ")",nSw/2.88, nSh/1.35, nSw,nSh,tocolor(255,255,255,190),1,"default-bold","left","top",false,false,false) else dxDrawText( "Admin: Yes (LVL:" ..tostring(admin).. ")",nSw/2.88, nSh/1.35, nSw,nSh,tocolor(255, 194, 14,255),1,"default-bold","left","top",false,false,false) end if (donator==0) then dxDrawText( "Donator: No (LVL:" ..tostring(donator)..")",nSw/1.98, nSh/1.35, nSw,nSh,tocolor(167, 133, 63,255),1,"default-bold","left","top",false,false,false) else dxDrawText( "Donator: Yes (LVL:" ..tostring(donator)..")",nSw/1.98, nSh/1.35, nSw,nSh,tocolor(167, 133, 63,255),1,"default-bold","left","top",false,false,false) end if (muted==0) then dxDrawText( "Muted: No",nSw/2.88, nSh/1.31, nSw,nSh,tocolor(0,192,0,190),1,"default-bold","left","top",false,false,false) else dxDrawText( "Muted: Yes",nSw/2.88, nSh/1.31, nSw,nSh,tocolor(200,0,0,190),1,"default-bold","left","top",false,false,false) end dxDrawText( " Health: "..tostring( health ),nSw/2.88, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "" ..playerName,nSw/2.85, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText( " Bank ".. money, nSw/2.88, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( " Armour ".. tostring( armour ), nSw/2.88, nSh/4.1, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Skin: " .. tostring( getElementModel ( localPlayer ) ) , nSw/2, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Weapon: " .. weaponType, nSw/2, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( sWindowTitle,nWindowX,nWindowY,nWindowX + nWindowW,nWindowY + nWindowTitleHeight,nWindowTitleColor,0.5,"bankgothic","left","center") local veh = getPedOccupiedVehicle( localPlayer ) if veh then local vehicle = getVehicleName( veh,localPlayer ) dxDrawText( "Vehicle Name: " ..vehicle,nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false ) else dxDrawText( "Vehicle Name: None",nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false ) end end end bindKey( 'F7', 'down', fPress ) addEventHandler( 'onClientRender',root,fDraw ) This is the "job code": function acceptJob(button, state) if (button=="left") then local row, col = guiGridListGetSelectedItem(jobList) local job = getElementData(getLocalPlayer(), "job") if (row==-1) or (col==-1) then outputChatBox("Please select a job first!", 255, 0, 0) elseif (job>0) then outputChatBox("You are already employed, please quit your other job first (( /quitjob )).", 255, 0, 0) else local job = 0 local jobtext = guiGridListGetItemText(jobList, guiGridListGetSelectedItem(jobList), 1) if ( jobtext=="Delivery Driver" or jobtext=="Taxi Driver" or jobtext=="Bus Driver" ) then -- Driving job, requires the license local carlicense = getElementData(getLocalPlayer(), "license.car") if (carlicense~=1) then outputChatBox("You require a drivers license to do this job.", 255, 0, 0) return end end if (jobtext=="Delivery Driver") then displayTruckerJob() job = 1 elseif (jobtext=="Taxi Driver") then job = 2 displayTaxiJob() elseif (jobtext=="Bus Driver") then job = 3 displayBusJob() elseif (jobtext=="City Maintenance") then job = 4 elseif (jobtext=="Mechanic") then displayMechanicJob() triggerServerEvent("giveMechanicJob", getLocalPlayer()) job = 5 elseif (jobtext=="Locksmith") then displayLocksmithJob() job = 6 end triggerServerEvent("acceptJob", getLocalPlayer(), job) destroyElement(jobList) destroyElement(bAcceptJob) destroyElement(bCancel) destroyElement(wEmployment) wEmployment, jobList, bAcceptJob, bCancel = nil, nil, nil, nil showCursor(false) end end end I'm using thingies from that one to implant in the User Panel (First script) but I don't know how to add them up together.
-
You mean like this, right? And will this work? local bState, bDraw local sMsg = [[Recent Server Updates Illegal Gun Vendors Shop stands New HUD Helpchat on F1 User Panel New exteriors/interiors Minor bug fixes Mechanic Job fixed (You can only use it inside interiors) (There's garages for this, due to non-rp) Vehicle Color Fix, Furnite Shops added (Blue doll blip on F11) ]] local nSw,nSh = guiGetScreenSize( ) local nWindowW = 280 local bState, bDraw local sMsg = [[Recent Server Updates Illegal Gun Vendors Shop stands New HUD Helpchat on F1 User Panel New exteriors/interiors Minor bug fixes Mechanic Job fixed (You can only use it inside interiors) (There's garages for this, due to non-rp)) Vehicle Color Fix, Furnite Shops added (Blue doll blip on F11) ]] local nSw,nSh = guiGetScreenSize( ) local nWindowW = 380 local nWindowH = 400 local sWindowTitle = "User Control Panel" local nWindowTitleHeight = 20 local nWindowTitleColor = tocolor( 255,255,255,255 ) --local windowTitleBGColor = tocolor( 0,0,0,255 ) local nWindowBGColor = tocolor( 0,0,0,205 ) local nWindowX = nSw - 250 - nWindowW local nWindowY = nSh / 2.28 - nWindowH / 2 local nRepWinWidth, nRepWinHeight = 280, 450 local nRepWinX = nSw / 2 - ( nRepWinWidth / 2 ) local nRepWinY = nSh / 2 - ( nRepWinHeight / 2 ) local nX = nWindowX local nY = nWindowY + nWindowTitleHeight local nH = nWindowH - nWindowTitleHeight local x,y = guiGetScreenSize() local uRoot = guiCreateMemo( x/2.8, y/2.8, x/3.5, y/3.4,sMsg,false ) guiSetVisible( uRoot,false ) function fPress( ) bState = not bState guiSetVisible( uRoot,bState ) showCursor ( not isCursorShowing( ) ) bDraw = not bDraw end function fDraw( ) if bDraw then local playerName = getPlayerName ( localPlayer ) local money = getPlayerMoney( localPlayer ) local ping = getPlayerPing( localPlayer ) local playerX, playerY, playerZ = getElementPosition( localPlayer ) local playerZoneName = getZoneName( playerX, playerY, playerZ ) local health = getElementHealth( localPlayer ) local armour = getPedArmor( localPlayer ) local weaponType = getPedWeapon ( localPlayer ) if weaponType then weaponType = getWeaponNameFromID( weaponType ) else weaponType = '' end local money = getElementData( localPlayer, "bankmoney" ) local rootElement = getRootElement() local x,y = guiGetScreenSize() -- Get players resolution. dxDrawRectangle ( x/2.93, y/5.1, x/3.13, y/1.87, tocolor ( 255, 255, 255, 50 ) ) dxDrawRectangle ( x/2.9, y/5, x/3.2, y/1.9, tocolor ( 0, 0, 0, 200 ) ) dxDrawLine ( nRepWinX, nRepWinY + 15, nRepWinX + nRepWinWidth, nRepWinY + 15, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( nRepWinX, nRepWinY + 81, nRepWinX + nRepWinWidth, nRepWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( nRepWinX, nRepWinY + 102, nRepWinX + nRepWinWidth, nRepWinY + 102, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( nRepWinX, nRepWinY + 355, nRepWinX + nRepWinWidth, nRepWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawText( "Location: " ..tostring( playerZoneName ),nSw/2.88, nSh/1.43, nSw, nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Ping: " ..tostring( ping ),nSw/1.7, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText( " Health: "..tostring( health ),nSw/2.88, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( " Recent Updates & Announcements",nSw/2.85, nSh/3.15, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "" ..playerName,nSw/2.85, nSh/4.85, nSw,nSh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText( " Bank ".. money, nSw/2.88, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( " Armour ".. tostring( armour ), nSw/2.88, nSh/4.1, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Skin: " .. tostring( getElementModel ( localPlayer ) ) , nSw/2, nSh/3.7, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( "Weapon: " .. weaponType, nSw/2, nSh/3.4, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText( sWindowTitle,nWindowX,nWindowY,nWindowX + nWindowW,nWindowY + nWindowTitleHeight,nWindowTitleColor,0.5,"bankgothic","left","center") local veh = getPedOccupiedVehicle( localPlayer ) if veh then local vehicle = getVehicleName( veh,localPlayer ) dxDrawText( "Vehicle Name: " ..vehicle,nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false ) else dxDrawText( "Vehicle Name: None",nSw/2.88, nSh/1.485, nSw,nSh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false ) end end end bindKey( 'F7', 'down', fPress ) addEventHandler( 'onClientRender',root,fDraw )
-
Works like a charm, thank you! I just have a problem with the 'window' and 'memo' as it places itself on different spots on other resolutions
-
I am working on it, been putting in a lot of time in this. This is what I got now (Window shows if I press F7) but it doesn't stay up. (It hides after a second or two), (I'm trying to make it visible until I release the F7 key. myWindow = nil pressed = false ----------------------[KEY BINDS]-------------------- function bindKeys() bindKey("F7", "down", dx) end addEventHandler("onClientResourceStart", getRootElement(), bindKeys) function resetState() pressed = false end ---------------------------[user Panel]-------------------- local rootElement = getRootElement() local sw,sh = guiGetScreenSize() local windowW = 280 local windowH = 400 local windowTitle = "User Panel " local windowTitleHeight = 20 local windowTitleColor = tocolor(255,255,255,255) local windowTitleBGColor = tocolor(0,0,0,255) local windowBGColor = tocolor(0,0,0,205) local windowX = sw - 250 - windowW local windowY = sh / 2.28 - windowH / 2 local localPlayer = getLocalPlayer ( ) function dx (thePlayer) if not (pressed) then pressed = true setTimer(resetState, 50, 1) if ( myWindow == nil ) then local playerName = getPlayerName ( getLocalPlayer() ) local money = getPlayerMoney(thePlayer) local ping = getPlayerPing(getLocalPlayer()) local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) local playerZoneName = getZoneName( playerX, playerY, playerZ ) local health = getElementHealth(getLocalPlayer()) local armour = getPedArmor( getLocalPlayer() ) local weaponType = getPedWeapon ( getLocalPlayer() ) if weaponType then weaponType = getWeaponNameFromID( weaponType ) end local money = getElementData(localPlayer, "bankmoney") local repWinWidth, repWinHeight = 280, 450 local repx, repy = guiGetScreenSize() local repWinX = repx/1.95 - (repWinWidth/2) local repWinY = repy/2 - (repWinHeight/2) local x = windowX local y = windowY + windowTitleHeight local h = windowH - windowTitleHeight addEventHandler("onClientResourceStart",resourceRoot, function() GUIEditor_Memo = {} GUIEditor_Memo[1] = guiCreateMemo(277,185,269,214,"Recent Server Updates\n\nIllegal secrets\n\nShop stands\n\nNew HUD\n\nHelpchat on F1\n\nUser Panel\n\nNew exteriors/interiors\n\nMinor bug fixes\n\nMechanic Job fixed\n(You can only use it inside interiors)\n((There's garages for this, due to non-rp))\n\nVehicle Color Fix, Furnite Shops added\n(Blue doll blip on F11)",false) end ) dxDrawRectangle(x,y,windowW,h,windowBGColor) dxDrawLine ( repWinX, repWinY + 28, repWinX+repWinWidth, repWinY + 28, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( repWinX, repWinY + 81, repWinX+repWinWidth, repWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( repWinX, repWinY + 102, repWinX+repWinWidth, repWinY + 102, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( repWinX, repWinY + 355, repWinX+repWinWidth, repWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawText("Location: " ..playerZoneName,sw/2.88, sh/1.34, sw, sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Ping: " ..ping,sw/1.68, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Health: "..health,sw/2.88, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Recent Updates & Announcements",275.0,158.0,543.0,175.0,tocolor(255,255,0,190),0.6,"pricedown","center","top",false,false,false) dxDrawText("" ..playerName,sw/2.85, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Bank ".. money, sw/2.88, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Armour ".. armour, sw/2.88, sh/5.6, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Skin: " .. getElementModel ( getLocalPlayer() ) , sw/1.78, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Weapon: " .. weaponType, sw/2, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText(windowTitle,windowX,windowY,windowX+windowW,windowY+windowTitleHeight,windowTitleColor,0.5,"bankgothic","left","center") local veh = getPedOccupiedVehicle(localPlayer) if veh then local vehicle = getVehicleName(veh,thePlayer) dxDrawText("Vehicle Name: " ..vehicle,sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) else dxDrawText("Vehicle Name: None",sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false) end end function HandleTheRendering () addEventHandler("onClientRender",rootElement, dx) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) showCursor ( true ) else destroyElement(myWindow) myWindow = nil showCursor(false) end end
-
this? ".xml" type="client" /> resource=""/> local xml1 = xmlLoadFile( ".xml" ) local contents1 = xmlNodeGetValue( xml1 )
-
Hello, so I found this neat resource by solidsnake @community. So I started to configure it and ended up with this: myWindow = nil pressed = false ----------------------[KEY BINDS]-------------------- function bindKeys() bindKey("F7", "down", dx) end addEventHandler("onClientResourceStart", getRootElement(), bindKeys) function resetState() pressed = false end -- user panel local rootElement = getRootElement() local sw,sh = guiGetScreenSize() local windowW = 280 local windowH = 400 local windowTitle = "User Panel " local windowTitleHeight = 20 local windowTitleColor = tocolor(255,255,255,255) local windowTitleBGColor = tocolor(0,0,0,255) local windowBGColor = tocolor(0,0,0,205) local windowX = sw - 250 - windowW local windowY = sh / 2.28 - windowH / 2 local localPlayer = getLocalPlayer ( ) function dx (thePlayer) local playerName = getPlayerName ( getLocalPlayer() ) local money = getPlayerMoney(thePlayer) local ping = getPlayerPing(getLocalPlayer()) local playerX, playerY, playerZ = getElementPosition( getLocalPlayer()) local playerZoneName = getZoneName( playerX, playerY, playerZ ) local health = getElementHealth(getLocalPlayer()) local armour = getPedArmor( getLocalPlayer() ) local weaponType = getPedWeapon ( getLocalPlayer() ) if weaponType then weaponType = getWeaponNameFromID( weaponType ) end local money = getElementData(localPlayer, "bankmoney") local repWinWidth, repWinHeight = 280, 450 local repx, repy = guiGetScreenSize() local repWinX = repx/1.95 - (repWinWidth/2) local repWinY = repy/2 - (repWinHeight/2) local x = windowX local y = windowY + windowTitleHeight local h = windowH - windowTitleHeight dxDrawRectangle(x,y,windowW,h,windowBGColor) dxDrawLine ( repWinX, repWinY + 28, repWinX+repWinWidth, repWinY + 28, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( repWinX, repWinY + 81, repWinX+repWinWidth, repWinY + 81, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawLine ( repWinX, repWinY + 355, repWinX+repWinWidth, repWinY + 355, tocolor ( 255, 255, 255, 150 ), 1 ) dxDrawText("Location: " ..playerZoneName,sw/2.88, sh/1.34, sw, sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Ping: " ..ping,sw/1.68, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Health: "..health,sw/2.88, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("" ..playerName,sw/2.85, sh/6.9, sw,sh,tocolor(255,255,0,190),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Bank ".. money, sw/2.88, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Armour ".. armour, sw/2.88, sh/5.6, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Skin: " .. getPedSkin ( getLocalPlayer() ) , sw/1.78, sh/4.85, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText("Weapon: " .. weaponType, sw/2, sh/4.3, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) dxDrawText(windowTitle,windowX,windowY,windowX+windowW,windowY+windowTitleHeight,windowTitleColor,0.5,"bankgothic","left","center") local veh = getPedOccupiedVehicle(localPlayer) if veh then local vehicle = getVehicleName(veh,thePlayer) dxDrawText("Vehicle Name: " ..vehicle,sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,255),0.5,"bankgothic","left","top",false,false,false) else dxDrawText("Vehicle Name: None",sw/2.88, sh/1.39, sw,sh,tocolor(255,255,255,205),0.5,"bankgothic","left","top",false,false,false) end end function HandleTheRendering () addEventHandler("onClientRender",rootElement, dx) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) showCursor ( true ) else destroyElement(myWindow) myWindow = nil showCursor(false) end end end So I need some help with it, for starters, how do I hide it so it shows if you press F7? Edit: I guess this is right but I have an error: lua:92:'' expected near 'else'
-
Hello, I have a lot of problems with a script that will let you pay to pass by the tolls. http://pastie.org/3472540 ERROR: call: failed to call 'pool:allocateElement' [string "?"] (When I start the resource) When I type /gate Like: 160-170 bad argument @ 'getDistanceBetweenPoints3D' [expected number at argument 4, got boolean] tolls.lua:170: attempt to compare boolean with number the script doesn't work at all, only thing that works is that the toll/barrier spawns.
-
Not understand I haven't found any functions yet but I'll keep looking BUT > found a bug after adding: if isElement( odometer ) then The current kilometers disappears
-
When I'm inside a vehicle and I press 'i' - inventory shows but the odometer is over the inventory, like this: I want the odometer to hide when inventory is open while being inside a vehicle
-
Thanks but line 6 still had error so I added if isElement( odometer ) then like you did: local enginelessVehicle = { [510]=true, [509]=true, [481]=true } local odometer -- draw the odometer as soon as the player enters the car. function showOdometer( theVehicle, seat ) if isElement( odometer ) then if not guiGetVisible( odometer ) then local id = getElementModel( theVehicle ) if (seat < 2) then if not (enginelessVehicle[id]) then -- If the vehicle has an engine. local x, y = guiGetScreenSize() local vehicle = getPedOccupiedVehicle( source ) local km = getElementData(vehicle, "odometer") local km = math.floor(km/1000) local odoKM = string.format("%07d", km) odometer = guiCreateLabel(x-138, y-215, 200, 200, tostring(odoKM), false) guiSetFont(odometer, "default-bold-small") kilo = guiCreateLabel(x-122, y-202, 200, 200, "km", false) guiSetFont(kilo, "default-bold-small") end end end end end addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), showOdometer) -- hide the odometer as soon as the player exits the car. function hideOdometer( ) if not (isVehicleLocked(source)) then setTimer( -- So that the odometer doesn't disappear as soon as you press 'F'. function() if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end, 1700, 1) end end addEventHandler("onClientVehicleStartExit", getLocalPlayer(), hideOdometer) -- update the odometer as the player moves in his vehicle. function updateOdometer( currentKilometers ) if isElement( odometer ) then if (guiGetVisible(odometer)) then local currentKilometers = math.floor(currentKilometers/1000) local odoKM = string.format("%07d", currentKilometers) guiSetText(odometer, tostring(odoKM)) end end end addEvent("updateOdo", true) addEventHandler("updateOdo", getLocalPlayer(), updateOdometer) -- remove the odometer if the player is not a in a vehicle but he is still seeing it. function removeOdometer() if not (isPedInVehicle(getLocalPlayer())) then if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end end setTimer(removeOdometer, 50, 0) There is no more errors but how do I hide the odometer when I open the inventory?
-
Hey there! I'm basically trying to hide the odometer if a player presses 'I' (Opens the inventory) - minus the two errors (The odometer stays 'on top' of the inventory while it's shown/opened (> It's under the odometer) Here's the odometer script: enginelessVehicle = { [510]=true, [509]=true, [481]=true } -- draw the odometer as soon as the player enters the car. function showOdometer( theVehicle, seat ) if not (guiGetVisible(odometer)) then local id = getElementModel(theVehicle) if (seat < 2) then if not (enginelessVehicle[id]) then -- If the vehicle has an engine. local x, y = guiGetScreenSize() local vehicle = getPedOccupiedVehicle(getLocalPlayer()) local km = getElementData(vehicle, "odometer") local km = math.floor(km/1000) local odoKM = string.format("%07d", km) odometer = guiCreateLabel(x-138, y-215, 200, 200, tostring(odoKM), false) guiSetFont(odometer, "default-bold-small") kilo = guiCreateLabel(x-122, y-202, 200, 200, "km", false) guiSetFont(kilo, "default-bold-small") end end end end addEventHandler("onClientPlayerVehicleEnter", getLocalPlayer(), showOdometer) -- hide the odometer as soon as the player exits the car. function hideOdometer( ) if not (isVehicleLocked(source)) then setTimer( -- So that the odometer doesn't disappear as soon as you press 'F'. function() if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end, 1700, 1) end end addEventHandler("onClientVehicleStartExit", getLocalPlayer(), hideOdometer) -- update the odometer as the player moves in his vehicle. function updateOdometer( currentKilometers ) if (guiGetVisible(odometer)) then local currentKilometers = math.floor(currentKilometers/1000) local odoKM = string.format("%07d", currentKilometers) guiSetText(odometer, tostring(odoKM)) end end addEvent("updateOdo", true) addEventHandler("updateOdo", getLocalPlayer(), updateOdometer) -- remove the odometer if the player is not a in a vehicle but he is still seeing it. function removeOdometer() if not (isPedInVehicle(getLocalPlayer())) then if (odometer) then destroyElement(odometer) odometer = nil end if (kilo) then destroyElement(kilo) kilo = nil end end end setTimer(removeOdometer, 50, 0) And I figure this wont help but I'll post it anyways, it's a function whether to show the inventory window or not. bindKey( "i", "down", function( ) if (getElementData(localPlayer, "loggedin") == 1) then if show then show = false showCursor( false ) --exports["realism-system"]:showSpeedo() elseif not getElementData(localPlayer, "adminjailed") and not getElementData(localPlayer, "pd.jailstation") then show = true showCursor( true ) --exports["realism-system"]:hideSpeedo() else outputChatBox("You can't access your inventory in jail", 255, 0, 0) end end end ) No idea if existing errors might cause problems, but the errors are: line 5 & 47: bad argument @ 'guiGetVisible' [Expected gui-element at argument 1, got nil] line 47 only shows if you're on a bike/bmx/mountain bike etc.
-
Hai, I'm trying to setup my UCP for my server, but as far as I've looked, there hasn't been a single host being able host it / supports PHP. Any suggestions on FREE website hosts with possibly zero adverts or less than usual?
-
Still the same all blank, also if this helps, as you might see, I used most things from this( might help somehow ): function CreateCheckWindow() triggerEvent("cursorShow", getLocalPlayer()) Button = {} --Image = {} Window = guiCreateWindow(28,271,400,285,"Player check.",false) --Button[1] = guiCreateButton(0.3524,0.8387,0.2026,0.0968,"Recon player.",true,Window) --addEventHandler( "onClientGUIClick", Button[1], ReconPlayer) --Button[2] = guiCreateButton(0.5705,0.8387,0.2026,0.0968,"Freeze player.",true,Window) --addEventHandler( "onClientGUIClick", Button[2], FreezePlayer) Button[3] = guiCreateButton(0.85,0.86,0.12, 0.125,"Close",true,Window) addEventHandler( "onClientGUIClick", Button[3], CloseCheck ) Label = { guiCreateLabel(0.03,0.07,0.95,0.0887,"Name: N/A",true,Window), guiCreateLabel(0.03,0.12,0.66,0.0887,"IP: N/A",true,Window), guiCreateLabel(0.03,0.34,0.66,0.0887,"Money: N/A",true,Window), guiCreateLabel(0.03,0.39,0.17,0.0806,"Health: N/A",true,Window), guiCreateLabel(0.20,0.39,0.30,0.0806,"Armour: N/A",true,Window), guiCreateLabel(0.03,0.44,0.17,0.0806,"Skin: N/A",true,Window), guiCreateLabel(0.20,0.44,0.30,0.0806,"Weapon: N/A",true,Window), guiCreateLabel(0.03,0.49,0.66,0.0806,"Faction: N/A",true,Window), guiCreateLabel(0.03,0.27,0.66,0.0806,"Ping: N/A",true,Window), guiCreateLabel(0.03,0.56,0.66,0.0806,"Vehicle: N/A",true,Window), guiCreateLabel(0.03,0.63,0.66,0.0806,"Warns: N/A",true,Window), guiCreateLabel(0.6,0.41,0.4031,0.0766,"Location: N/A",true,Window), guiCreateLabel(0.6,0.12,0.4031,0.0766,"X:",true,Window), guiCreateLabel(0.6,0.17,0.4031,0.0766,"Y: N/A",true,Window), guiCreateLabel(0.6,0.22,0.4031,0.0766,"Z: N/A",true,Window), guiCreateLabel(0.6,0.29,0.2907,0.0806,"Interior: N/A",true,Window), guiCreateLabel(0.6,0.34,0.2907,0.0806,"Dimension: N/A",true,Window), guiCreateLabel(0.03,0.17,0.66,0.0887,"Admin Level: N/A", true,Window), guiCreateLabel(0.03,0.22,0.66,0.0887,"Donator Level: N/A",true,Window), guiCreateLabel(0.6,0.48,0.4093,0.0806,"Hours Ingame: N/A",true,Window), } -- player notes memo = guiCreateMemo(0.03, 0.7, 0.8, 0.27, "", true, Window) addEventHandler( "onClientGUIClick", Window, function( button, state ) if button == "left" and state == "up" then if source == memo then guiSetInputEnabled( true ) else guiSetInputEnabled( false ) end end end ) Button[4] = guiCreateButton(0.85,0.7,0.12, 0.14,"Save\nNote",true,Window) addEventHandler( "onClientGUIClick", Button[4], SaveNote, false ) Button[5] = guiCreateButton(0.6,0.56,0.4093,0.1,"History: N/A",true,Window) addEventHandler( "onClientGUIClick", Button[5], ShowHistory, false ) --Image[1] = guiCreateStaticImage(0.4758,0.1089,0.1278,0.2177,"search.png",true,Window) guiSetVisible(Window, false) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () CreateCheckWindow() end ) local levels = { "Trial Admin", "Admin", "Super Admin", "Lead Admin", "Head Admin", "Owner" } function OpenCheck( ip, adminreports, donatorlevel, note, history, warns ) player = source if adminreports == nil then adminreports = "-1" end if donatorlevel == nil then donatorlevel = "Unknown" end if warns == nil then warns = "-1" end if history == nil then history = "-1" end if note == nil then note = "ERROR: COULD NOT FETCH NOTE@" end guiSetText ( Label[2], "IP: " .. ip ) guiSetText ( Label[18], "Admin Level: " .. ( levels[getElementData(player, "adminlevel") or 0] or "Player" ) .. " (" .. adminreports .. " Reports)" ) guiSetText ( Label[19], "Donator Level: " .. donatorlevel ) guiSetText ( Label[11], "Warns: " .. warns ) guiSetText ( Button[5], "History: " .. history ) guiSetText ( memo, note or "Could not load") if not guiGetVisible( Window ) then guiSetVisible(Window, true) end end addEvent( "onCheck", true ) addEventHandler( "onCheck", getRootElement(), OpenCheck ) addEventHandler( "onClientRender", getRootElement(), function() if guiGetVisible(Window) and isElement( player ) then guiSetText ( Label[1], "Name: " .. getPlayerName(player) .. " (" .. getElementData( player, "gameaccountusername" ) .. ")") local x, y, z = getElementPosition(player) guiSetText ( Label[13], "X: " .. x ) guiSetText ( Label[14], "Y: " .. y ) guiSetText ( Label[15], "Z: " .. z ) guiSetText ( Label[3], "Money: $" .. exports.global:getMoney( player ) .. " (Bank: $" .. getElementData( player, "bankmoney" ) .. ")") guiSetText ( Label[4], "Health: " .. math.ceil( getElementHealth( player ) ) ) guiSetText ( Label[5], "Armour: " .. math.ceil( getPedArmor( player ) ) ) guiSetText ( Label[6], "Skin: " .. getElementModel( player ) ) local weapon = getPedWeapon( player ) if weapon then weapon = getWeaponNameFromID( weapon ) else weapon = "N/A" end guiSetText ( Label[7], "Weapon: " .. weapon ) local team = getPlayerTeam(player) if team then guiSetText ( Label[8], "Faction: " .. getTeamName(team) ) else guiSetText ( Label[8], "Faction: N/A") end guiSetText ( Label[9], "Ping: " .. getPlayerPing( player ) ) local vehicle = getPedOccupiedVehicle( player ) if vehicle then guiSetText ( Label[10], "Vehicle: " .. getVehicleName( vehicle ) .. " (" ..getElementData( vehicle, "dbid" ) .. ")" ) else guiSetText ( Label[10], "Vehicle: N/A") end guiSetText ( Label[12], "Location: " .. getZoneName( x, y, z ) ) guiSetText ( Label[16], "Interior: " .. getElementInterior( player ) ) guiSetText ( Label[17], "Dimension: " .. getElementDimension( player ) ) guiSetText ( Label[20], "Hours Ingame: " .. ( getElementData( player, "hoursplayed" ) or 0 ) ) end end ) function CloseCheck( button, state ) if source == Button[3] and button == "left" and state == "up" then triggerEvent("cursorHide", getLocalPlayer()) guiSetVisible( Window, false ) guiSetInputEnabled( false ) player = nil end end function SaveNote( button, state ) if source == Button[4] and button == "left" and state == "up" then local text = guiGetText(memo) if text then triggerServerEvent("savePlayerNote", getLocalPlayer(), player, text) end end end function ShowHistory( button, state ) if source == Button[5] and button == "left" and state == "up" then triggerServerEvent( "showAdminHistory", getLocalPlayer(), player ) end end local wHist, gHist, bClose -- window local actions = { [0] = "jail", [1] = "kick", [2] = "ban", [3] = "app", [4] = "warn", [5] = "aban" } function duration( d, a ) if a == 1 or a == 3 or a == 4 or a == 6 then return "" elseif a == 0 then return d .. " min" elseif a == 2 and d ~= 0 then return d .. " hrs" else return "perm" end end addEvent( "cshowAdminHistory", true ) addEventHandler( "cshowAdminHistory", getRootElement(), function( info ) if wHist then destroyElement( wHist ) wHist = nil showCursor( false ) else local sx, sy = guiGetScreenSize() local name if source ~= nil then name = getPlayerName( source ) else name = "Application" end wHist = guiCreateWindow( sx / 2 - 350, sy / 2 - 250, 700, 500, "Admin History: " .. getPlayerName( source ), false ) -- date, action, reason, duration, , a.username, c.charactername gHist = guiCreateGridList( 0.03, 0.04, 0.94, 0.88, true, wHist ) local colAction = guiGridListAddColumn( gHist, "Action", 0.07 ) local colChar = guiGridListAddColumn( gHist, "Character", 0.2 ) local colReason = guiGridListAddColumn( gHist, "Reason", 0.25 ) local colDuration = guiGridListAddColumn( gHist, "Time", 0.07 ) local colAdmin = guiGridListAddColumn( gHist, "Admin", 0.15 ) local colDate = guiGridListAddColumn( gHist, "Date", 0.2 ) for _, res in pairs( info ) do local row = guiGridListAddRow( gHist ) guiGridListSetItemText( gHist, row, colAction, actions[ tonumber( res[2] ) ] or "?", false, false ) guiGridListSetItemText( gHist, row, colChar, res[6], false, false ) guiGridListSetItemText( gHist, row, colReason, res[3], false, false ) guiGridListSetItemText( gHist, row, colDuration, duration( res[4], tonumber( res[2] ) ), false, false ) guiGridListSetItemText( gHist, row, colAdmin, res[5], false, false ) guiGridListSetItemText( gHist, row, colDate, res[1], false, false ) end --[[ for _, res in pairs( results ) do local row = guiGridListAddRow( gHist ) guiGridListSetItemText( gHist, row, colName, res[1]:gsub("_", " "), false, false ) guiGridListSetItemText( gHist, row, colVotes, tostring( res[2] ), false, true ) if total > 0 and res[1] ~= "Not voted" then guiGridListSetItemText( gHist, row, colPercent, ("%.2f%%"):format( tonumber( res[2] ) / total * 100 ), false, true ) else guiGridListSetItemText( gHist, row, colPercent, " ", false, false ) end end]] bClose = guiCreateButton( 0.03, 0.93, 0.94, 0.07, "Close", true, wHist ) addEventHandler( "onClientGUIClick", bClose, function( button, state ) if button == "left" and state == "up" then destroyElement( wHist ) wHist = nil showCursor( false ) end end, false )
-
that works quite well but it's just the texts that is missing the window is blank but no errors
-
Yeh, it doesn't work Draken , take a look at the second last post by me I'm trying to make that one work properly, I guess it more likely that one will work above the others somehow
-
It gives in an in-look to others, it is quite useful, plus, if ran on RPG / RP, it can easily be converted to bank money.
-
Doesn't work, the window just goes blank + no errors. edit: it also doesn't let people toggle the window, which is weird If you press F4, that window will never go away until you log I think I figured one out but .. error: 86: bad argument @ destroyelement this is what I got now: myWindow = nil pressed = false player = localPlayer function resetState( ) pressed = false end ---------------------------[HELP]-------------------- function F4Uc( key, keyState ) if not (pressed) then pressed = true setTimer(resetState, 200, 1) if not myWindow then myWindow = guiCreateWindow ( 0.20, 0.20, 0.6, 0.6, "Test Window", true ) Label = { guiCreateLabel(15 , 24, 220, 17,"Name: N/A",true,Window), guiCreateLabel(15 , 24 ,220 , 17,"IP: N/A",true,Window), guiCreateLabel(0.03,0.34,0.66,0.0887,"Money: N/A",true,Window), guiCreateLabel(0.03,0.39,0.17,0.0806,"Health: N/A",true,Window), guiCreateLabel(0.20,0.39,0.30,0.0806,"Armour: N/A",true,Window), guiCreateLabel(0.03,0.44,0.17,0.0806,"Skin: N/A",true,Window), guiCreateLabel(0.20,0.44,0.30,0.0806,"Weapon: N/A",true,Window), guiCreateLabel(0.03,0.49,0.66,0.0806,"Faction: N/A",true,Window), guiCreateLabel(0.03,0.27,0.66,0.0806,"Ping: N/A",true,Window), guiCreateLabel(0.03,0.56,0.66,0.0806,"Vehicle: N/A",true,Window), guiCreateLabel(0.03,0.63,0.66,0.0806,"Warns: N/A",true,Window), guiCreateLabel(0.6,0.41,0.4031,0.0766,"Location: N/A",true,Window), guiCreateLabel(0.6,0.12,0.4031,0.0766,"X:",true,Window), guiCreateLabel(0.6,0.17,0.4031,0.0766,"Y: N/A",true,Window), guiCreateLabel(0.6,0.22,0.4031,0.0766,"Z: N/A",true,Window), guiCreateLabel(0.6,0.29,0.2907,0.0806,"Interior: N/A",true,Window), guiCreateLabel(0.6,0.34,0.2907,0.0806,"Dimension: N/A",true,Window), guiCreateLabel(0.03,0.17,0.66,0.0887,"Admin Level: N/A", true,Window), guiCreateLabel(0.03,0.22,0.66,0.0887,"Donator Level: N/A",true,Window), guiCreateLabel(0.6,0.48,0.4093,0.0806,"Hours Ingame: N/A",true,Window), } end end end bindKey( "F4", "down", F4Uc ) addEventHandler( "onClientRender", root, function() if isElement( myWindow ) and guiGetVisible( myWindow ) then guiSetText ( Label[1], "Name: " .. getPlayerName(player) .. " (" ..tostring( getElementData( player, "gameaccountusername" ) ) .. ")") local x, y, z = getElementPosition(player) guiSetText ( Label[13], "X: " .. x ) guiSetText ( Label[14], "Y: " .. y ) guiSetText ( Label[15], "Z: " .. z ) guiSetText ( Label[3], "Money: $" .. tostring( exports.global:getMoney( player ) ) .. " (Bank: $" .. tostring( getElementData( player, "bankmoney" ) ) .. ")") guiSetText ( Label[4], "Health: " .. tostring( math.ceil( getElementHealth( player ) ) ) ) guiSetText ( Label[5], "Armour: " .. tostring( math.ceil( getPedArmor( player ) ) ) ) guiSetText ( Label[6], "Skin: " .. tostring( getElementModel( player ) ) ) local weapon = getPedWeapon( player ) if weapon then weapon = getWeaponNameFromID( weapon ) else weapon = "N/A" end guiSetText ( Label[7], "Weapon: " ..tostring( weapon ) ) local team = getPlayerTeam(player) if team then guiSetText ( Label[8], "Faction: " ..tostring( getTeamName( team ) ) ) else guiSetText ( Label[8], "Faction: N/A") end guiSetText ( Label[9], "Ping: " ..tostring( getPlayerPing( player ) ) ) local vehicle = getPedOccupiedVehicle( player ) if vehicle then guiSetText ( Label[10], "Vehicle: " .. getVehicleName( vehicle ) .. " (" ..tostring( getElementData( vehicle, "dbid" ) ) .. ")" ) else guiSetText ( Label[10], "Vehicle: N/A") end guiSetText ( Label[12], "Location: " .. tostring( getZoneName( x, y, z ) ) ) guiSetText ( Label[16], "Interior: " .. tostring( getElementInterior( player ) ) ) guiSetText ( Label[17], "Dimension: " .. tostring( getElementDimension( player ) ) ) guiSetText ( Label[20], "Hours Ingame: " .. tostring( getElementData( player, "hoursplayed" ) or 0 ) ) showCursor ( true ) else destroyElement(myWindow) myWindow = nil showCursor(false) end end )
-
The text/content is in .xml, which means, I can't use "lua" > functions, handlers.. and so on, do you understand now? I tried this: myWindow = nil pressed = false ----------------------[KEY BINDS]-------------------- function bindKeys() bindKey("F4", "down", F4Uc) end addEventHandler("onClientResourceStart", getRootElement(), bindKeys) function resetState() pressed = false end ---------------------------[HELP]-------------------- function F4Uc( key, keyState ) if not (pressed) then pressed = true setTimer(resetState, 200, 1) if ( myWindow == nil ) then myWindow = guiCreateWindow ( 0.20, 0.20, 0.6, 0.6, "Test Window", true ) Label = { guiCreateLabel(0.20, 0.20, 0.6, 0.6,"Name: N/A",true,Window), guiCreateLabel(0.20, 0.21, 0.6, 0.6,"IP: N/A",true,Window), guiCreateLabel(0.03,0.34,0.66,0.0887,"Money: N/A",true,Window), guiCreateLabel(0.03,0.39,0.17,0.0806,"Health: N/A",true,Window), guiCreateLabel(0.20,0.39,0.30,0.0806,"Armour: N/A",true,Window), guiCreateLabel(0.03,0.44,0.17,0.0806,"Skin: N/A",true,Window), guiCreateLabel(0.20,0.44,0.30,0.0806,"Weapon: N/A",true,Window), guiCreateLabel(0.03,0.49,0.66,0.0806,"Faction: N/A",true,Window), guiCreateLabel(0.03,0.27,0.66,0.0806,"Ping: N/A",true,Window), guiCreateLabel(0.03,0.56,0.66,0.0806,"Vehicle: N/A",true,Window), guiCreateLabel(0.03,0.63,0.66,0.0806,"Warns: N/A",true,Window), guiCreateLabel(0.6,0.41,0.4031,0.0766,"Location: N/A",true,Window), guiCreateLabel(0.6,0.12,0.4031,0.0766,"X:",true,Window), guiCreateLabel(0.6,0.17,0.4031,0.0766,"Y: N/A",true,Window), guiCreateLabel(0.6,0.22,0.4031,0.0766,"Z: N/A",true,Window), guiCreateLabel(0.6,0.29,0.2907,0.0806,"Interior: N/A",true,Window), guiCreateLabel(0.6,0.34,0.2907,0.0806,"Dimension: N/A",true,Window), guiCreateLabel(0.03,0.17,0.66,0.0887,"Admin Level: N/A", true,Window), guiCreateLabel(0.03,0.22,0.66,0.0887,"Donator Level: N/A",true,Window), guiCreateLabel(0.6,0.48,0.4093,0.0806,"Hours Ingame: N/A",true,Window), } addEventHandler( "onClientRender", getRootElement(), function() if guiGetVisible(Window) and isElement( player ) then guiSetText ( Label[1], "Name: " .. getPlayerName(player) .. " (" .. getElementData( player, "gameaccountusername" ) .. ")") local x, y, z = getElementPosition(player) guiSetText ( Label[13], "X: " .. x ) guiSetText ( Label[14], "Y: " .. y ) guiSetText ( Label[15], "Z: " .. z ) guiSetText ( Label[3], "Money: $" .. exports.global:getMoney( player ) .. " (Bank: $" .. getElementData( player, "bankmoney" ) .. ")") guiSetText ( Label[4], "Health: " .. math.ceil( getElementHealth( player ) ) ) guiSetText ( Label[5], "Armour: " .. math.ceil( getPedArmor( player ) ) ) guiSetText ( Label[6], "Skin: " .. getElementModel( player ) ) local weapon = getPedWeapon( player ) if weapon then weapon = getWeaponNameFromID( weapon ) else weapon = "N/A" end guiSetText ( Label[7], "Weapon: " .. weapon ) local team = getPlayerTeam(player) if team then guiSetText ( Label[8], "Faction: " .. getTeamName(team) ) else guiSetText ( Label[8], "Faction: N/A") end guiSetText ( Label[9], "Ping: " .. getPlayerPing( player ) ) local vehicle = getPedOccupiedVehicle( player ) if vehicle then guiSetText ( Label[10], "Vehicle: " .. getVehicleName( vehicle ) .. " (" ..getElementData( vehicle, "dbid" ) .. ")" ) else guiSetText ( Label[10], "Vehicle: N/A") end guiSetText ( Label[12], "Location: " .. getZoneName( x, y, z ) ) guiSetText ( Label[16], "Interior: " .. getElementInterior( player ) ) guiSetText ( Label[17], "Dimension: " .. getElementDimension( player ) ) guiSetText ( Label[20], "Hours Ingame: " .. ( getElementData( player, "hoursplayed" ) or 0 ) ) end end end ERROR: 87: ) expected (to close ( at line 44
