Jump to content

Andres99907

Members
  • Posts

    44
  • Joined

  • Last visited

Everything posted by Andres99907

  1. it worked , i didn't know the use of local for declaring variables because i alwais did my scripts clientsided, i appreciate it bro, thank you :0
  2. I am making a script to use flares on aircraft, the script works fine until two players use a flare at the same time, the declared variables change and one of the flares is not destroyed. Here is a video of my script: I was checking the creator of the flare with an outpuchatbox at the end of the script, and I saw that the creator changed, which means that the variable was declared again. Flares = {} Chaffs = {} function FlarePhys(x, y, z, distance, gz) player = client index = #Flares + 1 Flares[index] = { ["Vehicles"] = { getPedOccupiedVehicle(player) }, ["Lights"] = { createMarker(x,y,z,"corona", 1, 255,0,0) }, ["Flares"] = { createObject(2060, x,y,z) } } setElementData(Flares[index]["Vehicles"][1], "Dismissile", true) setElementCollisionsEnabled(Flares[index]["Flares"][1], false) attachElements(Flares[index]["Lights"][1], Flares[index]["Flares"][1]) moveObject(Flares[index]["Flares"][1], distance*100, x, y, gz +1.5) setTimer ( function() if isElement(Flares[index]["Vehicles"][1]) then removeElementData(Flares[index]["Vehicles"][1], "Dismissile") else destroyElement(Flares[index]["Flares"][1]) destroyElement(Flares[index]["Lights"][1]) end end, 1000, 1 ) setTimer ( function() outputChatBox(getPlayerName(player)) destroyElement(Flares[index]["Flares"][1]) destroyElement(Flares[index]["Lights"][1]) end, 8000, 1 ) end addEvent("UseFlares", true) addEventHandler("UseFlares", getRootElement(), FlarePhys) I need help because i don't know how to make the function work for every player and not for the player that uses the Flare i will appreciate the help, I think i can do this script clientside triggering it for all players but if i do this serverside i will be happy haha.
  3. I will try to fix it using SetCameraMatrix and check if still happen. I think it will not work but i will keep trying.
  4. Sometimes when i see peds on the screen some bugs occur, I have tested on several computers and the same bug happens, the bug can be reproduced with some popular scripts like npchlc_traffic, slothbot or zombies, and I have never found out that it can be Here is a video of the glitchy screen and a pic I need help, because i can't find any topic about this u_u
  5. That was a lot of work because i don't know much about tables, but i made the table and i made my script work thank you
  6. Im working on a script wich create flames on the Thrusters of a vehicle (Mammoth Thruster of GTA Online), works well if you are the only that has a Thruster, but if someone also has a Thruster and gets out the vehicle, your Thruster will keep the attached elements and will not destroy the flames if you get out of the vehicle: Here is a video of what is happening: https://www.youtube.com/watch?v=Q3z9fdnBG0w and serverside and clientside scripts that are involved Serverside: (Functions for creating the flames) function LightOn(vehicle, x, y, z) if thePlayer ~= localPlayer then return end light = createMarker ( x , y , z, "corona", 0.5, 255, 160, 0, 170 ) attachElements(light, vehicle, 0, -0.3, -0.8) end addEvent("lighton", true) addEventHandler("lighton", getRootElement(), LightOn) function LightOff() if thePlayer ~= localPlayer then return end if light then destroyElement(light) end end addEvent("lightoff", true) addEventHandler("lightoff", getRootElement(), LightOff) function ThrustersOn(vehicle, x, y, z) if thePlayer ~= localPlayer then return end superhitbox = createObject (3471, x , y , z) setElementAlpha(superhitbox, 0) firethrustl = createObject (2031, x , y , z) firethrustr = createObject (2031, x , y , z) attachElements(superhitbox, vehicle, 0, -10, -1) attachElements(firethrustl, vehicle, 0.47, -0.4, -0.2) attachElements(firethrustr, vehicle, -0.47, -0.4, -0.2) setElementCollisionsEnabled(firethrustl, false) setElementCollisionsEnabled(firethrustr, false) end addEvent("thrusterson", true) addEventHandler("thrusterson", getRootElement(), ThrustersOn) function ThrustersOff() if thePlayer ~= localPlayer then return end if not firethrustl then return end destroyElement(firethrustl) destroyElement(firethrustr) end addEvent("thrustersoff", true) addEventHandler("thrustersoff", getRootElement(), ThrustersOff) Clientside: (Functions that triggers serverside events when you are in the Thruster) Thruster = 465 function SitOnThruster(thePlayer) if thePlayer ~= localPlayer then return end local vehicle = getPedOccupiedVehicle(localPlayer) if ( vehicle and getElementModel (vehicle) == Thruster ) then bindKey("vehicle_fire", "down", shootProjectile) triggerServerEvent ( "onthruster", resourceRoot) local x, y, z = getElementPosition(vehicle) local h, m = getTime() triggerServerEvent("thrusterson", getRootElement(), vehicle, x, y, z) if h > 20 then triggerServerEvent("lighton", getRootElement(), vehicle, x, y, z) else return end end end addEventHandler ( "onClientVehicleEnter", root, SitOnThruster ) function Notsit(thePlayer) if thePlayer ~= localPlayer then return end if Thruster then triggerServerEvent("thrustersoff", getRootElement(), vehicle, x, y, z) triggerServerEvent("lightoff", getRootElement(), vehicle, x, y, z) else return end end addEventHandler ( "onClientVehicleExit", root, Notsit ) function killed() if Thruster then if (isPedInVehicle(localPlayer) and Cars[getElementModel(getPedOccupiedVehicle(localPlayer))]) then if getPedOccupiedVehicleSeat ( localPlayer ) == 1 then return end triggerServerEvent("thrustersoff", getRootElement(), vehicle, x, y, z) triggerServerEvent("lightoff", getRootElement(), vehicle, x, y, z) else return end end end addEventHandler ( "onClientPlayerWasted", localPlayer, killed ) function shootProjectile() if not disparado then local vehicle = getPedOccupiedVehicle(localPlayer) if ( vehicle and getElementModel (vehicle) == Thruster ) then if isVehicleOnGround(vehicle) == false then local x, y, z = getElementPosition(vehicle) projectile = createProjectile(vehicle, 15, x, y+4, z-10) disparado = true setTimer ( function() disparado = false end, 1500, 1 ) else local x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 15, x, y, z-3) disparado = true setTimer ( function() disparado = false end, 1500, 1 ) end end end end I'm very confused, i'm trying to make the script only create element for each player.
  7. I created this script: this script makes the helicopter able to fire an invisible minigun, and the script does it very well. The problem... All it's clientside i don't know how to make the miniguns fire serverside Setweaponstate doesn't work serverside and the minigun cannot harm any player clientside except LocalPlayer
  8. function comprarbandito ( thePlayer, command) local playeraccount = getPlayerAccount ( source ) takePlayerMoney ( thePlayer, 500000 ) setAccountData ( playeraccount, "rc.bandito", adquirido ) end addCommandHandler ( "comprarbandito", comprarbandito ) function Banditoadquirido (_, playeraccount ) if ( playeraccount ) then local ban = getAccountData ( playeraccount, "rc.bandito" ) if ( ban ) then Banditocomprado = true end end end addEvent ( "banditobuyed", true ) addEventHandler ( "banditobuyed", getRootElement(), Banditoadquirido ) This function takes 500000 dollars to give a player permission to use a RC Bandito in a gui (Like in GTA Online) but, when i put the command "comprarbandito" Bad argument @ getplayeraccount, got nil, i never used getplayeraccount or setplayeraccount, and i don't know if the other function (Banditoadquirido) will work
  9. I'm using this script to make Thruster fly, only the Player who uses the Thruster will fly, but if other player enters to other Thruster, the script executes one more time the function and the Player in the First Thruster stop flying (because the function is executed again by the other player) I don't know how to make this script not affect the other players here is a video. Video and this the part of the script wich has the Problem: addEventHandler("onClientVehicleEnter", getRootElement(), function() if (isPedInVehicle(localPlayer) and Cars[getElementModel(getPedOccupiedVehicle(localPlayer))]) then if isWorldSpecialPropertyEnabled("aircars") then setWorldSpecialPropertyEnabled ( "aircars", false ) setWorldSpecialPropertyEnabled ( "hovercars", false ) setAircraftMaxVelocity( 2.3 ) setWorldSoundEnabled ( 11, true, true) setWorldSoundEnabled ( 7, true, true) setWorldSoundEnabled ( 8, true, true) setWorldSoundEnabled ( 9, true, true) setWorldSoundEnabled ( 10, true, true) setWorldSoundEnabled ( 12, true, true) setWorldSoundEnabled ( 13, true, true) setWorldSoundEnabled ( 14, true, true) setWorldSoundEnabled ( 15, true, true) setWorldSoundEnabled ( 16, true, true) setWorldSoundEnabled ( 40, true, true) playSound("ThrusterOff.wav") setSoundVolume(sound, 0.3) if isFlying then removeEventHandler("onClientRender", root, checkFlight) end isFlying = false else setWorldSpecialPropertyEnabled ( "aircars", true ) setWorldSpecialPropertyEnabled ( "hovercars", true ) triggerServerEvent ( "onjetpack", resourceRoot) setWorldSoundEnabled ( 11, false, true) setWorldSoundEnabled ( 7, false, true) setWorldSoundEnabled ( 8, false, true) setWorldSoundEnabled ( 9, false, true) setWorldSoundEnabled ( 10, false, true) setWorldSoundEnabled ( 12, false, true) setWorldSoundEnabled ( 13, false, true) setWorldSoundEnabled ( 14, false, true) setWorldSoundEnabled ( 15, false, true) setWorldSoundEnabled ( 16, false, true) setWorldSoundEnabled ( 40, false, true) playSound("ThrusterOn.wav") setAircraftMaxVelocity( 1) setSoundVolume(sound, 0.9) if not isFlying then addEventHandler("onClientRender", root, checkFlight) end isFlying = true end end end) function checkFlight() if (not isPedInVehicle(localPlayer)) or (not Cars[getElementModel(getPedOccupiedVehicle(localPlayer))]) or isPlayerDead(localPlayer) then setWorldSpecialPropertyEnabled ( "aircars", false ) setWorldSpecialPropertyEnabled ( "hovercars", false ) setAircraftMaxVelocity( 2.3 ) setWorldSoundEnabled ( 11, true, true) setWorldSoundEnabled ( 7, true, true) setWorldSoundEnabled ( 8, true, true) setWorldSoundEnabled ( 9, true, true) setWorldSoundEnabled ( 10, true, true) setWorldSoundEnabled ( 12, true, true) setWorldSoundEnabled ( 13, true, true) setWorldSoundEnabled ( 14, true, true) setWorldSoundEnabled ( 15, true, true) setWorldSoundEnabled ( 16, true, true) setWorldSoundEnabled ( 40, true, true) playSound("ThrusterOff.wav") setAircraftMaxVelocity( 2.3 ) setSoundVolume(sound, 0.3) if isFlying then removeEventHandler("onClientRender", root, checkFlight) end isFlying = false end end local ms = 1000
  10. local themes = { "sounds/RADAR.mp3", "sounds/RADAR2.mp3", "sounds/RADAR3.mp3", } local sound = {} function Ruiner2000theme() local allVehicles = getElementsByType("vehicle") for index, veh in ipairs (allVehicles) do local model = getElementModel(veh) if model == 494 then if getVehicleEngineState(veh) then if isElement(sound[veh]) then triggerServerEvent ( "fullyloaded", resourceRoot) else local x, y, z = getElementPosition(veh) sound[veh] = playSound3D( math.random( 1,#themes ), x, y, z, true) attachElements(sound[veh], veh) setSoundMaxDistance(sound[veh], 1000) end else if isElement(sound[veh]) then destroyElement(sound[veh]) end end end end end addEventHandler("onClientPreRender", root, Ruiner2000theme) I have tried to make a script that when I get on the Ruiner 2000 it plays songs randomly, it works if I put the song as "RADAR.mp3", but it doesn't work if I put the mathrandom table, I have added the songs correctly in the meta and I don't know why it does not work
  11. I'm very noob at scripting :' (, but i did this: (It's a script for the Imponte Deluxo of GTA Online) Serverside: function deluxe ( player ) local vehicle = getPedOccupiedVehicle(player) if isElement(vehicle) then if getVehicleDoorOpenRatio(vehicle,5) > 0 then setVehicleDoorOpenRatio(vehicle,5,0,ms) setVehicleDoorOpenRatio(vehicle,4,0,ms) setVehicleDoorOpenRatio(vehicle,0,0,ms) else setVehicleDoorOpenRatio(vehicle,5,1,ms) setVehicleDoorOpenRatio(vehicle,4,1,ms) setVehicleDoorOpenRatio(vehicle,0,1,ms) end end end addEvent( "deluxo", true ) addEventHandler( "deluxo", resourceRoot, deluxe) This function puts the Deluxo on flying mode, works fine if i use addCommandHandler instead addEventHandler... Clientside: triggerServerEvent ( "deluxo", resourceRoot) this is the triggerServerEvent that is activated by BindKey (Shift) but i got at line2 on serverside: Bad Argument @ ´getPedoccupiedvehicle´ [Expected Ped at Argument 1, got nil] I need help
  12. last week I had a login panel that worked with HTML, the panel had a background video and music, but now it appears on white background and without sound, I tried to put another HTML panel and the same thing happens, both use videos in webm format and sound in ogg format, I do not know exactly what happens D :
  13. It worked!! I really appreciate it very much
  14. This is the script: function check ( player, seat, jacked ) if getElementData(source, "privado") then if getElementData(source, "dueño") == getAccountName(getPlayerAccount(player)) then else cancelEvent() outputChatBox("Este vehículo no es tuyo.", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), check ) function adueñar(playerSource, player, cmd, who) local who = getPlayerName(playerSource), playerSource(who) local co = getPedOccupiedVehicle(who) setElementData(co, "privado", true) setElementData(co, "dueño", getPlayerName(who)) outputChatBox("Este auto ahora es de:"..getPlayerName(who), player) end addEventHandler ( "onVehicleEnter", getRootElement(), adueñar ) the script makes that when a player gets into a car it is saved in his account so no other can use it, the script needs to get the player's name, but I think that in a server-type script it is impossible :(, I have tried everything and nothing has worked... Help :C the script works when you change "addEventHandler" to "addCommandHandler" but, i want everything to be automatic.
  15. function check ( player, seat, jacked ) if getElementData(source, "policeman") then if getElementData(source, "owner") == getAccountName(getPlayerAccount(player)) then else cancelEvent() outputChatBox("You need to be a Policeman", player) end end end addEventHandler ( "onVehicleStartEnter", getRootElement(), check ) function setcop(player, cmd, who) local who = getPlayerName(playersource), setcop(who) local co = getPedOccupiedVehicle(who) setElementData(co, "policeman", true) setElementData(co, "owner", getPlayerName(who)) outputChatBox("The Policeman:"..getPlayerName(who), player) end addEventHandler ( "onVehicleEnter", getRootElement(), setcop ) i made a few changes
  16. My script* but i can't change the title
  17. I'm trying to make a resource that obtain the name of a player like this line: local who = getPlayerName(playerSource), playerSource(who) but i got this GetPlayerName [expected element at argument 1, got nil] lua:13: attempt to call global 'playerSource' (a nil value) I need help :'c the script is of the type server
  18. For a long time he tried to make the players of my server have their own cars and another player can not remove them but I do not know how to do it, I made a resource that affects the doors, but it was not useful and failed in a certain thing,: c Help
  19. EspañolInglésItaliano---------------Detectar idiomaAfrikáansAlbanésAlemánAmáricoÁrabeArmenioAzerbaiyanoBengalíBielorrusoBirmanoBosnioBúlgaroCanarésCatalánCebuanoChecoChino (Simplificado)Chino (Tradicional)CingalésCoreanoCorsoCriollo haitianoCroataDanésEslovacoEslovenoEspañolEsperantoEstonioEuskeraFinésFrancésFrisón occidentalGaélico escocésGalésGallegoGeorgianoGriegoGuyaratíHausaHawaianoHebreoHindiHmongHúngaroIgboIndonesioInglésIrlandésIslandésItalianoJaponésJavanésJemerKazajoKirguísKurdoLaoLatínLetónLituanoLuxemburguésMacedonioMalayalamMalayoMalgacheMaltésMaoríMaratíMongolNeerlandésNepalíNoruegoNyanjaPanyabíPastúnPersaPolacoPortuguésRumanoRusoSamoanoSerbioShonaSindhiSomalíSotho meridionalSuajiliSuecoSundanésTagaloTailandésTamilTayikoTeluguTurcoUcranianoUrduUzbekoVietnamitaXhosaYidisYorubaZulúEspañol Thank you! , I really appreciate it C:
  20. I have this: function Salir() if isElement(tableVehicles[source]) then destroyElement(tableVehicles[source]) end end addEventHandler("onPlayerVehicleExit",getRootElement(),Salir) This function destroys the vehicle when the player leaves, I want this to happen after a second and not immediately, i need to use "Set timer", but I do not know how to use it, I tried different ways but none of them
  21. this is the script to lock the doors function lockdoors ( theVehicle, seat ) if ( getElementModel ( theVehicle ) == 601 ) then if isVehicleLocked ( playervehicle ) then setVehicleLocked ( v, true ) else setVehicleLocked ( v, false ) end addEventHandler ( "onPlayerVehicleEnter", getRootElement(), lockdoors )
×
×
  • Create New...