Jump to content

JuAnY

Members
  • Posts

    15
  • Joined

  • Last visited

Details

  • Location
    Argentina

JuAnY's Achievements

Square

Square (6/54)

0

Reputation

  1. Hi guys, I'm trying to learn how to do a resource to hold a ball when the player collides, and then click to shoot it in the current camera direction. Im a little lost , I searched and tried with moveObejct but the result was too badly... Here some portions of code: ball = createObject(1598, 1347.8164, 2127.0234, 10.3, 300, 360, 300, false) attachElements ( ball, player, 0, 0.5, -0.75 ) local rotz = tonumber(getPedRotation(player)) local xt,yt,zt = getElementPosition(player) detachElements(ball, player) xt = xt + (math.cos(math.rad(rotz+90)) * 1.2) yt = yt + (math.sin(math.rad(rotz+90)) * 1.2) moveObject(ball, 2500, xt, yt, zt, math.random(10, 90), math.random(10, 90), math.random(10, 90)) If you can help me with something or give me a hint, I will be grateful!
  2. Sorry, I mean: send MTA resources commands
  3. Thanks @Citizen, your answer was very helpful! So I can make fake chat, but its possible to send a MTA command as a player?
  4. Im looking for a resource, or create my own script, where I can use a command to talk in the player chatbox... For example: /playersay PLAYERNAME TEXT --->(this show in the chat) PLAYERNAME: TEXT /playersay PLAYERNAME COMMAND(/quit) ---> "PLAYERNAME has left the server" Any ideas?
  5. LOL I fixed the error with the upgrades hahahaha, I dont know what did but now its working The script now saves the upgrades but not saves the car colors, I will fix it.. Thnks for help guys! EDIT: ALL FIXED
  6. Doesnt work, and now in debugscript says: ERROR: server.lua:62: bad argument #1 to 'pairs' (table expected, got boolean) WARNING: server.lua:94: Bad argument @ 'getVehicleUpgrades' [Expected vehicle at argument1] Guys this is too hard, I think upgrades never get working
  7. Doesnt work, still the same problem
  8. Someone knows if there is a resource to save our cars? I mean, press a button and spawn the car saved with his upgrades and color. I downloaded and edited a script of the community but saves the car without upgrades and get this error: "server.lua:63: bad argument #1 to 'ipairs' (table expected, got nil)" Here is the code: carShopMarker = createMarker (2133.59,-1149.29, 23.3, "cylinder", 3, 255, 0, 0, 127) carShopMarker2 = createMarker (562, -1270, 16, "cylinder", 2, 255, 0, 0, 127) carShopMarker3 = createMarker (-1954,299,34,"cylinder",2,255,0,0,127) carShopMarker4 = createMarker (-1663,1208,6,"cylinder",2,255,0,0,127) carShopMarker5 = createMarker (1946,2068,10,"cylinder",2,255,0,0,127) createBlipAttachedTo(carShopMarker,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker2,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker3,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker4,55,2,0,255,0,0,0,200) createBlipAttachedTo(carShopMarker5,55,2,0,255,0,0,0,200) addEvent ("viewGUI", true) function markerHit (hitPlayer, matchingDimension) if (source == carShopMarker) or (source == carShopMarker2) or (source == carShopMarker3) or (source == carShopMarker4) or (source == carShopMarker5) then triggerClientEvent ("viewGUI", hitPlayer) end end addEventHandler ("onMarkerHit", getRootElement(), markerHit) addEvent ("carShopCarBuy", true) addEventHandler ("carShopCarBuy", getRootElement(), function(id, cost, name) if (getPlayerMoney (source) >= tonumber(cost)) then outputChatBox ("Compraste un " .. name, source, 0, 255, 0, false) outputChatBox ("ID: " .. id, source, 0, 255, 0, false) outputChatBox ("Costo: " .. cost, source, 0, 255, 0, false) takePlayerMoney (source, tonumber (cost)) setAccountData (getPlayerAccount (source), "funmodev2-car", tonumber(id)) setAccountData (getPlayerAccount (source), "funmodev2-paintjob", 3) setAccountData (getPlayerAccount (source), "funmodev2-carupg", 0) else outputChatBox ("No tienes dinero suficiente!", source, 255, 0, 0, false) end end) addEvent ("carSpawn", true) addEvent ("carDestroy", true) function carSpawn () if not (isGuestAccount (getPlayerAccount (source))) and not (isPedInVehicle(source)) then if (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) and (getElementType(getElementData (source, "hisCar")) == "vehicle") then setElementVelocity (getElementData (source, "hisCar"), 0,0,0) local x,y,z = getElementPosition (source) setVehicleRotation (getElementData (source, "hisCar"), 0, 0, 0) setElementPosition (getElementData (source, "hisCar"), x+2,y,z +1) outputChatBox ("Auto aparecido.", source, 0, 255, 0) elseif not (getElementData (source, "hisCar")) then local accountData = getAccountData (getPlayerAccount (source), "funmodev2-car") if (accountData) then carID = getAccountData (getPlayerAccount (source), "funmodev2-car") x,y,z = getElementPosition (source) vehicle = createVehicle (carID, x +2, y, z +1) setElementID (vehicle, getAccountName (getPlayerAccount(source))) setElementData (source, "hisCar", vehicle) outputChatBox ("Auto aparecido.", source, 0, 255, 0) local upgrades = getAccountData (getPlayerAccount (source), "funmodev2-carupg") if upgrades then local upgrades = nil local upgrades = {} for i,v in ipairs (fromJSON(upgrades)) do addVehicleUpgrade (vehicle, v) end end if (getAccountData (getPlayerAccount(source), "funmodev2-paintjob")) then local paintjob = getAccountData (getPlayerAccount(source), "funmodev2-paintjob") setVehiclePaintjob (vehicle, paintjob) end if (getAccountData (getPlayerAccount(source), "funmodev2-carcolor1")) and (getAccountData (getPlayerAccount(source), "funmodev2-carcolor2")) then local c1 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor1") local c2 = getAccountData (getPlayerAccount(source), "funmodev2-carcolor2") setVehicleColor (vehicle, c1,c2,0,0) end else outputChatBox ("No tienes ningun auto.", source, 255, 0, 0) end else outputChatBox ("Ya estas dentro del auto!", source, 255, 0, 0) end end end addEventHandler ("carSpawn", getRootElement(), carSpawn) function carDestroy () if not (isGuestAccount (getPlayerAccount (source))) then if (isPedInVehicle (source)) then if (getElementID(getPedOccupiedVehicle(source)) == getAccountName (getPlayerAccount(source))) then setElementHealth (getElementData (source, "hisCar"), 0) destroyElement (getPedOccupiedVehicle (source)) removeElementData (source, "hisCar") outputChatBox ("Auto desaparecido.", source, 255, 0, 0) --setAccountData (getPlayerAccount (source), "funmodev2-carupg", toJSON (getVehicleUpgrades(vehicle))) else outputChatBox ("Este no es tu auto!", source, 255, 0, 0) end elseif (not (isPedInVehicle (source))) and (getElementData (source, "hisCar")) and (getElementData (source, "hisCar") ~= nil) then car=getElementData(source, "hisCar") destroyElement(car) outputChatBox ("Auto desaparecido.", source, 255, 0, 0) removeElementData (source, "hisCar") end end end addEventHandler ("carDestroy", getRootElement(), carDestroy) function engineSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if (getVehicleEngineState (veh) == true) then setVehicleEngineState (veh, false) outputChatBox ("Motor apagado", source, 255, 0, 0) elseif (getVehicleEngineState (veh) == false) then setVehicleEngineState (veh, true) outputChatBox ("Motor encendido.", source, 0, 255, 0) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("engenieSwitch",true) addEventHandler("engenieSwitch",getRootElement(),engineSwitch) function lightsSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if (getVehicleOverrideLights(veh) ~= 2) then setVehicleOverrideLights(veh, 2) outputChatBox ("Luces prendidas.", source, 0, 255, 0) elseif (getVehicleOverrideLights(veh) ~= 1) then setVehicleOverrideLights(veh, 1) outputChatBox ("Luces apagadas.", source, 255, 0, 0) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("lightsSwitch",true) addEventHandler("lightsSwitch",getRootElement(),lightsSwitch) function lockSwitch () if (isPedInVehicle (source)) then local veh = getPedOccupiedVehicle (source) if not (isVehicleLocked (veh)) then setVehicleLocked (veh, true) setVehicleDoorsUndamageable (veh, true) setVehicleDoorState (veh, 0, 0) setVehicleDoorState (veh, 1, 0) setVehicleDoorState (veh, 2, 0) setVehicleDoorState (veh, 3, 0) outputChatBox ("Vehiculo bloqueado.", source, 0, 255, 0) elseif (isVehicleLocked (veh)) then setVehicleLocked (veh, false) setVehicleDoorsUndamageable (veh, false) outputChatBox ("Vehiculo desbloqueado.", source, 255, 0, 0) end else outputChatBox ("No estas en un vehiculo!", source, 255, 0, 0) end end addEvent("lockSwitch",true) addEventHandler("lockSwitch",getRootElement(),lockSwitch ) addEventHandler ("onVehicleStartEnter", getRootElement(), function(player, seat, jacked, door) if (isVehicleLocked (source) == true) then local mannetjeNaam = getAccountName (getPlayerAccount (player)) local autoNaam = getElementID (source) if (mannetjeNaam == autoNaam) then setVehicleLocked (source, false) outputChatBox ("Vehiculo desbloqueado.", player, 255, 0, 0, false) end end end) addEventHandler ("onVehicleExplode", getRootElement(), function() local theOwner = getAccountName (getPlayerAccount(getPlayerFromName (getElementID (source)))) if (theOwner) then removeElementData (theOwner, "hisCar") end end) addEventHandler ("onPlayerQuit", getRootElement(), function(quitType, reason, responsibleElement) if (getElementData (source, "hisCar")) then blowVehicle (getElementData (source, "hisCar")) removeElementData (source, "hisCar") end end) addEventHandler( "onResourceStop", getResourceRootElement( getThisResource() ), function () for i,v in ipairs (getElementsByType ("player")) do if (getElementData (v, "hisCar")) then setElementHealth (getElementData (v, "hisCar"), 0) removeElementData (v, "hisCar") end end end ) function destroyOnExplode () setTimer (destroyElement, 2500, 1, source) end addEventHandler ("onVehicleExplode", getRootElement(), destroyOnExplode)
  9. I change the code a little bit, I did appear less bots and was fixed
  10. Im trying with timer but the error continues... When debugscript get: "ERROR: slothbot\sbclient.lua:115: Attempt to compare boolean wth number" Im going crazy, I cant find the solution
  11. No, the script runs well, the 5 bots spawn but that happens...
  12. Hi, I need another help, this time with a simple resource that use slothbot. This generates 5 bots in a random position near the player to attack him with random skin/weapon, but sometimes one or two bots dont die and they keep jumping around me, I dont know if its a problem with my script or is a bug of slothbot. local skins = {102, 103, 104, 108, 109, 110, 114, 115, 116, 121, 122, 123, 173, 174, 175, 124, 105, 106, 107, 19, 21, 22, 28, 29, 67, 15, 20, 165, 73, 179, 287, 280, 282, 283, 284, 285, 286} local armas = {22, 24, 25, 27, 28, 32, 30, 31} local prtabla = {-2, -4, -6, -8, -10, -12, -14, -16, -18, -20, -22, -24, -26, -28, -30, -32, -34, -36, -38, -40, -42, -44, -46, -48, -50, -52, -54, -56, -58, -60, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60} function Spawnbot1 (bot) local x,y,z = getElementPosition (source) local rot=90 local interior=0 local dimension= 0 local team=false local mode= "hunting" local modesubject= source exports[ "slothBot" ]:spawnBot (x+prtabla[ math.random( 1,#prtabla)], y+prtabla[ math.random( 1,#prtabla)], z, rot, skins[ math.random( 1,#skins)], interior, dimension, team, armas[ math.random( 1,#armas)], mode, modesubject) exports[ "slothBot" ]:spawnBot (x+prtabla[ math.random( 1,#prtabla)], y+prtabla[ math.random( 1,#prtabla)], z, rot, skins[ math.random( 1,#skins)], interior, dimension, team, armas[ math.random( 1,#armas)], mode, modesubject) exports[ "slothBot" ]:spawnBot (x+prtabla[ math.random( 1,#prtabla)], y+prtabla[ math.random( 1,#prtabla)], z, rot, skins[ math.random( 1,#skins)], interior, dimension, team, armas[ math.random( 1,#armas)], mode, modesubject) exports[ "slothBot" ]:spawnBot (x+prtabla[ math.random( 1,#prtabla)], y+prtabla[ math.random( 1,#prtabla)], z, rot, skins[ math.random( 1,#skins)], interior, dimension, team, armas[ math.random( 1,#armas)], mode, modesubject) exports[ "slothBot" ]:spawnBot (x+prtabla[ math.random( 1,#prtabla)], y+prtabla[ math.random( 1,#prtabla)], z, rot, skins[ math.random( 1,#skins)], interior, dimension, team, armas[ math.random( 1,#armas)], mode, modesubject) outputChatBox("Mata a todos los enemigos!", root, 255, 0, 255, false ) end addCommandHandler("bot", Spawnbot1)
  13. Now its working. Thank so much man!
  14. Thanks JR10 for the reply. Now I get the message at line 13 but dont change the skin, the player still with the admin skin (188).
  15. Hi, Im trying to do a resource to restrict players put the skin of an admin, is for "freeroam" gamemode, but this dont work: function admskin(thePlayer) local account = getPlayerAccount(thePlayer) local accountName = getAccountName(account) if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then if ( getElementModel ( thePlayer ) == 188 ) then outputChatBox("Skin de admin correcto.",thePlayer,0,255,0) else outputChatBox("ADMIN SIN SKIN.",thePlayer,255,0,0) end else if ( getElementModel ( thePlayer ) == 188 ) then outputChatBox("No puedes usar skin de ADMIN.",thePlayer,255,0,0) setElementModel(thePlayer,14) end end end addEventHandler("onElementModelChange",root,admskin) I need your help please
×
×
  • Create New...