Jump to content

Den.

Members
  • Posts

    64
  • Joined

  • Last visited

Everything posted by Den.

  1. Use this createveh function instead: function createveh(button, state) if button == 'left' and state == 'down' then local x, y, z = getElementPosition ( localPlayer ) local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) if vehicle then triggerServerEvent("onSpawnVeh", localPlayer, tonumber(vehicle)) guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end end addEventHandler("onClientGUIClick", spawn, createveh, false) onClientGUIClick is triggered for when a GUI button is clicked, and released. Hence state could be 'up' or 'down'.
  2. No, it should add 100 to driving every 5 minutes, can't see what's wrong with the timer. Looks fine. setTimer -And anytime .
  3. Okay, I changed it to check distance from old position to current position. local time = 5 * 60000 --The time between each check. local increment = 100 --How much the element data "driving" should be increased function countDrivingTime() local thePlayers = getElementsByType("player") --Get all players for key, thePlayer in ipairs(thePlayers) do if isPedInVehicle(thePlayer) then -- If thePlayer is in a vehicle local pos = getElementData(thePlayer, "oldpos") or {0, 0, 0} local oldx, oldy, oldz = unpack(pos) local x, y, z = getElementPosition(thePlayer) if getDistanceBetweenPoints3D(x, y, z, oldx, oldy, oldz) > 5 then --If he moved a distance of 5 away from old position local driving = getElementData(thePlayer, "driving") driving = driving and driving + increment or 0 setElementData(thePlayer, "driving", driving) end setElementData(thePlayer, "oldpos", {x, y, z}) end end end setTimer(countDrivingTime, time, 0) --Timer to check the players. --Reset driving counter when player exits, remove it if you don't want it. addEventHandler("onPlayerVehicleExit", root, function() setElementData(source, "driving", nil) setElementData(source, "oldpos", nil) end) However, if the timer is as long as 5 minutes, then if a player went from point x to point y, then returned to point x in 5 mins; His driving data isn't going to be incremented because the distance from the old position (point x) to the current position ( point x as well) is 0.
  4. It is untested, not sure if this is what you wanted but: If a player keeps driving a vehicle for a while, it will increment his "driving" element data. If he exits, the element data is set back to nil. local time = 5 * 60000 --The time between each check. local increment = 100 --How much the element data "driving" should be increased function countDrivingTime() local thePlayers = getElementsByType("player") --Get all players for key, thePlayer in ipairs(thePlayers) do if isPedInVehicle(thePlayer) then -- If thePlayer is in a vehicle local driving = getElementData(thePlayer, "driving") driving = driving and driving + increment or 0 --If driving is a value, then increment it. setElementData(thePlayer, "driving", driving) --Set the data. end end end setTimer(countDrivingTime, time, 0) --Timer to check the players. --Reset driving counter when player exits, remove it if you don't want it. addEventHandler("onPlayerVehicleExit", root, function() if getElementData(source, "driving") then setElementData(source, "driving", nil) end end) However, if you want to measure the IDLE TIME ( that is when the player is in a vehicle, but doesn't move with it at all ); You're going to have to save the old position, and then see if it equals the current position in this check.
  5. Den.

    guiGetText

    Use this instead: moneyBox = tonumber(guiGetText( editBox )) guiGetText returns a string, not a number.
  6. You are purposely setting the marker to be visible to that specific player ( thePlayer ). setElementVisibleTo(playerMarkerTable[thePlayer], root, false) --Set marker invisible to all. setElementVisibleTo(playerMarkerTable[thePlayer], thePlayer, true) -- Set marker visible to thePlayer. What are you trying to do here? I've already replied in your other topic, also. If you want only the player who typed the command to be able to interact with that marker then check at the beginning if source( which is the marker hit ) is in fact playerMarkerTable[thePlayer] ( which should be the player's marker ). But it should already be visible to that one player only.
  7. The event name is "onClientGUIClick" and not "onClientGuiClick". You also didn't need to pass any arguments to the pickup function, because the player who clicked the button would be localPlayer in all cases. Use this client-side code. local x, y = guiGetScreenSize() local pickupBtn function drawNotice( ) pickupBtn = guiCreateButton(x-208, y-215, 50, 50, "Pick up", false) addEventHandler("onClientGUIClick", pickupBtn, function(button, state) if button == "left" and state == "down" then pickup() end end) end addEvent("notify:basket", true) addEventHandler("notify:basket", getLocalPlayer(), drawNotice) function removeNotice( ) guiSetVisible(pickupBtn, false) end addEvent("removenotify:basket", true) addEventHandler("removenotify:basket", getLocalPlayer(), removeNotice) function pickup() triggerServerEvent("pickupBall", localPlayer, localPlayer) end You should also remove commandName from the server-side function arguments, as well as use source in pickupBall instead of sending the localPlayer twice as source and as an argument. EDIT: I think this is also the vG/rG script.
  8. Den.

    guiGetText

    Where is editBox defined in the script?
  9. triggerClientEvent is obviously a server-side function only, therefore; You cannot use it client-side. Replace it with triggerEvent if you want to trigger the event client-side, or triggerServerEvent if you want to trigger that event server-side. If you get errors similar to that in the future, you should check the wiki for the function you're using.
  10. Here's the edited code for the visibility of the marker: function testejam(thePlayer, command) if ( getElementData ( thePlayer, "dbid" ) == 2 ) then setElementData(thePlayer, "time", getTickCount ()) end local pid = getElementData ( thePlayer, "dbid" ) local ciga = getElementData ( thePlayer, "dbid" ) destroyElement(markeritis) markeritis = createMarker ( blueBerryRally[ciga][1], blueBerryRally[ciga][2], blueBerryRally[ciga][3], "checkpoint", 6, 190, 156, 252, 170, thePlayer ) setElementVisibleTo(markeritis, root, false) setElementVisibleTo(markeritis, thePlayer, true) if ( #blueBerryRally == ciga ) then outputChatBox("You finished, nice", thePlayer, 255, 255, 0) outputChatBox("Your time:"..(getTickCount () - getElementData( thePlayer, "time" )) / 1000 .."sec.", root, 255, 255, 0) setElementData(thePlayer, "dbid", 1) end setElementData ( thePlayer, "dbid", getElementData ( thePlayer, "dbid" ) + 1 ) addEventHandler( "onMarkerHit", markeritis, testejam ) end addCommandHandler("race", testejam) As for the timing and finding out who finished first: --t is the table that holds all the finish times of the players. --It should be in this layout for the function to work: t[thePlayer] = finishtime function findRaceWinner(t) if t and type(t) == 'table' then local time, winner = math.huge for thePlayer, theTime in pairs(t) do if theTime < time then winner, time = thePlayer, theTime end end return winner, time end return false end -Yes it is very possible to make it work for multiple people. Each player should get his own marker now with the visibility fixed, you will probably run into a few issues though. -To make a dynamic variable name, you can utilize a table. --name refers to the player name. -- local x = 6 table[name..x] = value Another way would be to use _G, which is a table of all global variables ( of this resource, I think ). But that will create a GLOBAL dynamic variable, not a local one. local x = 6 _G[name..x] = value Note: I didn't mess with the rest of your script, didn't remove redundancies like pid, etc; You should remove it since you don't need it.
  11. I think the problem is on line 93: You are checking if the player's marker ( txJobMarker1[hitElement] ) belongs to the player, which is always true in all cases. So replace that with source, which is the marker hit, then you would be checking if the marker that was just hit by the player is truly his marker/customer. if (getElementData(source,"JobOwner") == getPlayerName(hitElement)) then I also don't understand what you are trying to do with the if on line 96.
  12. Den.

    fire

    Try this. (client side) bindKey("fire", "down", function() if getPedWeapon(localPlayer) == 9 then --Get the player's weapon, and see if it is a chainsaw. outputChatBox("Cos") end end) Your problem was that you were misusing the function getPedWeapon, and not checking if the weapon is a chainsaw.
  13. Den.

    Job [Help]

    Price, I think you are trying to use what Dealman posted server-side; Dealman's code is a client-side script. If you wish to change it to server-side, then change the event in line 25 to onResourceStart ( instead of onClientResourceStart) and change each outputChatBox in the function fetchRandomOnStart_Handle to fit the server-side arguments.
×
×
  • Create New...