Jump to content

Cronoss

Members
  • Posts

    173
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Cronoss

  1. I want to save the last position of a car (with owner) but the console keeps giving me a error (getAccount line) function guardarAuto(player) local veh = getNearestVehicle(player,5) or Ped.getOccupiedVehicle(player) if (veh) then local acc = player:getAccount() local owner = acc:getName() local location = player:getPosition() local rotation = player:getRotation() local int = player:getInterior() local dim = player:getDimension() local loc = toJSON({location.x,location.y,location.z}) local rot = toJSON({rotation.x,rotation.y,rotation.z}) if (veh:getData("vehicles:owner") == owner) then local id = getElementData(veh, "vehicles:id") end end end) addEventHandler("onPlayerQuit", root, guardarAuto) I know I post many scripting questions, sorry
  2. I wanted to add instructions when the player enter on a marker, I tested and it works, but, is there a better way to make the same action with another command? addEventHandler("onPlayerMarkerHit", root, function() outputChatBox("Presiona la H para acceder al panel", source) end ) ->this includes ALL the markers, that's why I'm asking
  3. Hello I was wondering... it is possible to edit this script? so instead of triggering the Gui panel "on marker hit" , the trigger event happens when the player press a letter. If is it possible I would like the explanation too, because I'm new at this, you can tell by my recent posts addEventHandler("onPlayerMarkerHit", getRootElement(), function(markerHit, matchingDimension) for id, marker in pairs(_marker) do if (markerHit == marker.marker) then triggerClientEvent(source, "vehicles:CarshopShowMenu", source, marker.marker:getData("vehicles:shop_name"), marker.marker:getData("vehicles:shop_data"), marker.marker:getData("vehicles:name"), marker.marker:getData("vehicles:price")) end end end)
  4. Quick question, is there a way that I could turn off the "shoot" ambient in my server? Sometimes shoots can be heared for no reason, and I would like to remove it. Any command? I tried to find a "ambient sound" option with admin panel but I can't find anything. (The default map I'm editing is in Play gamemode)
  5. I put the gsub part above the outputchatbox and now it works thank you both for the help, saludos ??
  6. This is the code, I want to pper the first letter when the player says something, I've tried with the example from MTA Wiki: local function doCapitalizing( substring ) -- Upper the first character and leave the rest as they are return substring:sub( 1, 1 ):upper( ) .. substring:sub( 2 ) end function capitalize( text ) -- Sanity check assert( type( text ) == "string", "Bad argument 1 @ capitalize [String expected, got " .. type( text ) .. "]") -- We don't care about the number of words, so return only the first result string.gsub provides return ( { string.gsub( text, "%a+", doCapitalizing ) } )[1] end Editing the rest, of course, but didn't get a result This is the code without the gsub part: function chatRP (mensaje, tipodeMensaje) local jugadores = getElementsByType ("player") local distanciaDelChat = 10 local x, y, z = getElementPosition (source) local sourceName = getPlayerName (source) if tipodeMensaje == 0 then for i,v in ipairs (jugadores) do local x2, y2, z2 = getElementPosition (v) if getDistanceBetweenPoints3D (x, y, z, x2, y2, z2) <= distanciaDelChat then if getElementDimension (source) == getElementDimension (v) then local clearedName = string.gsub(sourceName, "#%x%x%x%x%x%x", "") outputChatBox ("#FFF1C3[ING] "..clearedName.." dice: #FFFFFF" ..mensaje..".", v, 255, 255, 255, true) end end end cancelEvent ()
  7. It worked, but now I noticed another problem mensaje = mensaje:gsub("^%l", string.upper) This part doesn't execute any command when the resource starts
  8. Hello, It's me again, I'm trying to make a RP chat, I want to change the color of player's name and the text "dice:", but the rest of the message keep it white, should I make this code again? I've tried changing the color with Hex codes but I don't get the result I want. I know I can change the Player Nametag with "setPlayerNametagColor" but I want to include the text "dice:", so that doesn't works for me function chatRP (mensaje, tipoMensaje) local jugadores = getElementsByType ("player") local x, y, z = getElementPosition (source) local sourceName = getPlayerName (source) if tipodeMensaje == 0 then for i,v in ipairs (jugadores) do local x2, y2, z2 = getElementPosition (v) if getDistanceBetweenPoints3D (x, y, z, x2, y2, z2) <= distanciaChat then if getElementDimension (source) == getElementDimension (v) then outputChatBox ("[ING] "..sourceName.." dice: "..mensaje..".", v, 255, 255, 255, true) mensaje = mensaje:gsub("^%l", string.upper) end end end cancelEvent () elseif tipodeMensaje == 1 then
  9. Uh, and what If I want other players hear it?
  10. It worked!! Thank you so much for helping me
  11. I just tested again the first code (x,y,z of the player) and I don't know why, but if I leave the position where the vehicle was before connecting, the playsound doesn't work?
  12. It seems so easy now, thank you for your help Just one more thing, if I want the "x, y, z" to play the sound, is that possible without being inside the car?
  13. Hello Everybody, I need help with this specific function in client-side The main script (/bloquear function) it's in server-side, I know playSound3D must be in Client-Side but I don't know how to connect them, because in server side the script look like this: addCommandHandler("bloquear", function(player,cmd) local acc = player:getAccount() local owner = acc:getName() local vehicle = getNearestVehicle(player,5) or Ped.getOccupiedVehicle(player) if (vehicle:getData("vehicles:owner") == owner) then setPlayerVehicleLocked(player, vehicle) else player:outputChat("", 255, 0, 0) end end) function setPlayerVehicleLocked(player, vehicle) local vehname = vehicle:getName() if (vehicle:getData("vehicles:locked") == 1) then vehicle:setData("vehicles:locked", 0) vehicle:setLocked(false) player:outputChat("> Desbloqueaste tu "..vehname..".", 233, 24, 189) connection:exec("UPDATE vehicles SET locked=? WHERE id=? AND owner=?", 0, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) elseif (vehicle:getData("vehicles:locked") == 0) then vehicle:setData("vehicles:locked", 1) vehicle:setLocked(true) player:outputChat("> Bloqueaste tu "..vehname..".", 233, 24, 189) connection:exec("UPDATE vehicles SET locked=? WHERE id=? AND owner=?", 1, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) end end And in Client side looks like this: local x, y, z = client:getPosition() function sonidoBloq() local bloqueo = playSound3D( "sonidoBloq.mp3", x, y, z, false ) setSoundMaxDistance(bloqueo,10) end addEventHandler(???) When I try to connect them, with "callClientFunction" or any variant of it, the resource stop working and hides every vehicle. It only happens with the playsound, I've tried making another client-side functions and works, but with this simply It doesn't work
  14. Thank you for the help!! gracias a los dos
  15. Here is the code I'm using -------------- addCommandHandler("motor", function(player,cmd) local acc = player:getAccount() local owner = acc:getName() local vehicle = Ped.getOccupiedVehicle(player) if vehicle then if (vehicle:getData("vehicles:owner") == owner) then setPlayerVehicleEngine(player, vehicle) else player:outputChat("No tienes las llaves de este vehículo.", 255, 0, 0) end else player:outputChat("Debes estar en un vehículo para ejecutar este comando.", 255, 0, 0) end end) function setPlayerVehicleEngine(player, vehicle) if (vehicle:getData("vehicles:engine") == 1) then vehicle:setData("vehicles:engine", 0) vehicle:setEngineState(false) player:outputChat("Apagaste el motor.", 214, 37, 37) connection:exec("UPDATE vehicles SET engine=? WHERE id=? AND owner=?", 0, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) elseif (vehicle:getData("vehicles:engine") == 0) then vehicle:setData("vehicles:engine", 1) vehicle:setEngineState(true) player:outputChat("Encendiste el motor.", 141, 229, 22) connection:exec("UPDATE vehicles SET engine=? WHERE id=? AND owner=?", 1, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) end end I want to change the "Ped.getOccupiedVehicle(player)" for "Ped.getPedOccupiedVehicleSeat" and add a condition but when I try, the resource doesn't work
  16. It's me again. I was testing my edited vehicle script and found a error, when the player enters in the vehicle, It's doesnt matter the chair, they can turn on the engine even if they sit down behind the driver position. I was wondering, there is a recourse that could prevent this? I mean, only execute the comand "turn on the vehicle" when player is sitting in the driver's chair
  17. It worked!! thank u so much
  18. Console doesn't send me any error message, but It doesn't work (sorry for my bad English)
  19. Stilll doesn't work, I don't know what I'm missing
  20. I have been editing a vehicle script to make it work in a RP but I have a problem when executing the command to lock the vehicle, it locks perfectly from the outside, nobody can enter unless the owner unlocks the vehicle, but the problem is that if the owner locks inside, you can still go out. I did some research and found that something could be done with cancelEvent and "onClientVehicleStartExit", I've tried everything but nothing seems to work for me with that command, any advice? This is the code: function setPlayerVehicleLocked(player, vehicle) local vehname = vehicle:getName() if (vehicle:getData("vehicles:locked") == 1) then vehicle:setData("vehicles:locked", 0) vehicle:setLocked(false) player:outputChat("Desbloqueaste tu "..vehname..".", 214, 37, 37) connection:exec("UPDATE vehicles SET locked=? WHERE id=? AND owner=?", 0, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) elseif (vehicle:getData("vehicles:locked") == 0) then vehicle:setData("vehicles:locked", 1) vehicle:setLocked(true) player:outputChat("Bloqueaste tu "..vehname..".", 141, 229, 22) connection:exec("UPDATE vehicles SET locked=? WHERE id=? AND owner=?", 1, vehicle:getData("vehicles:id"), vehicle:getData("vehicles:owner")) end end function onclientVehicleStartExit() if (vehicle:getData("vehicles:locked") == 0) then cancelEvent(onVehicleStartExit) end end ("onclientVehicleStartExit", root, onVehicleStartExit)
  21. He estado editando un script de vehiculos para hacerlo funcionar en un RP pero tengo un problema a la hora de ejecutar el comando de cerrar el vehículo, se cierra perfectamente, desde afuera nadie lo puede abrir a menos que el dueño lo abra, pero el tema es que si el dueño cierra por dentro, aún así puedes salir. Investigué un poco y encontré que se podía hacer algo con cancelEvent, he intentado de todo pero nada parece funcionarme con ese comando, algún consejo?
×
×
  • Create New...