Jump to content

Elmatus

Members
  • Posts

    47
  • Joined

  • Last visited

Details

  • Gang
    cPz

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Elmatus's Achievements

Rat

Rat (9/54)

2

Reputation

  1. Yeah, you said you already had it so I didn't post it! I'm glad its working now.
  2. Spawning a weapon doesn't make it fire. You can use the function setWeaponState (theWeapon, "firing") to make it fire (i.e when you press the left mouse button)
  3. function shootProjectile() local vehicle = getPedOccupiedVehicle(localPlayer) -- Check if the player is in a vehicle if(vehicle)then --Check if its a rustler if getElementModel(vehicle) == 476 then --Get the current position of the vehicle and fire a rocket (No rotation is passed to createProjectile function because it automaticaly gets the vehicle rotation) local x, y, z = getElementPosition(vehicle) createProjectile(vehicle, 19, x, y, z) end end end bindKey("mouse1", "down", shootProjectile) I think I understand you. Give a try to this.
  4. Thanks in advantage for any help The problem is kind of simple, yet I haven't figured it out yet. I want that the barrels created actually move and fall. It only happens when a player touches it. The wiki says that to implement physics in an object just set velocity to 0, but it doesn't work A snippet of the code: function .... if.... for i,spot in ipairs (spots) do local pos = split(spot,",") if objectType == "object" then local theObject = createObject (object,pos[1],pos[2],pos[3]) setElementVelocity(theObject,0,0,0) elseif objectType == "vehicle" then local theVehicle = createVehicle(object,pos[1],pos[2],pos[3],math.random(0,120),math.random(0,120),math.random(0,120)) addSpeed(theVehicle) end end end end
  5. Didn't know aswell That worked just perfect, thanks!
  6. Thanks in advantage for everyone who is willing to help Ok, so I have a problem regarding to fileWrite It works just fine in a normal resource. But when I try it in a zipped script it doesn't have effect. Is this a common thing? How can I fix this problem?
  7. Tried that to pcall (loadstring(luaCode)) But nothing
  8. Ok, thanks in advantage for whoever takes time to answer. I'm trying to make a a script that loads a txt when it starts up. The script is serverside. I have a very weird problem. If I just put the lua code like normal it works just fine. But if Put it in a .txt or event a .lua outside meta, it doesnt work! The purpose of what I want is that admin of the sv can change the file without having to have the FTP of the server. Here is a snippet of my code: (server-side) function loadTheCode() file = fileOpen ("editable.lua") size = fileGetSize(file) luaCode = fileRead(file,size) loadstring (luaCode) fileClose(file) end addEventHandler("onResourceStart",root,loadTheCode) The code im trying to load includes some callRemote, getAccountSerialand other stuff. The thing I dont get is why it works inside the in-meta lua but not with loadstring. The console doesn't outputs errores nor the debugscript. The event does get triggered. I verified luaCode's length and it matches the lua code in it. Any solutions?
  9. I didn't realize that, thanks! I have another question, too small for making it a post. Can you get a return in server-side, by a client-side? Or vice versa
  10. Hi, thanks everyone beforehand I'm making a script o attach a m4 in a migun base and that a player can enter it and shoot. When I tested it with a friend in the server, he doesn't see the bullets coming out. I made it shootable everywhere (me far from the minigun bae) and I stepped in front of it, and I do get killed. I think the problem has to be with being client-side. But createWeapon is only a client-side function. Here is the function that fires the weapon: Client-side customWeapon = createWeapon ("m4",0,0,0) setElementAlpha(customWeapon,0) setElementCollisionsEnabled(customWeapon,false) -- For field of view bug attachElements (customWeapon,minigun,0.5,0,1.1,0,0,0) setWeaponClipAmmo(customWeapon, 99999) setWeaponFlags (customWeapon, "disable_model",true) -- Hides it setWeaponFiringRate(customWeapon,50) function startFiring (_, state) if state == "down" then setWeaponState(customWeapon, "firing") else setWeaponState(customWeapon, "ready") end end bindKey ("mouse1","both",startFiring)
  11. Yes it outputs. And no I already tried debugscript and no error is displayed. Like I said is only when I add other argument
  12. Oh sorry! I didn't paste it here, I already have it!
  13. The event is triggered if I only send one argument, "theShooter". I added the argument "object", ensuring is not nil. But the server event is not triggered after that Any help is aprecciated Client (Relevant: line 34-40) function ObjectShot ( theShooter, weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement ) shooterX, shooterY, shooterZ = getElementPosition (theShooter) targetDistance = getDistanceBetweenPoints3D ( shooterX, shooterY, shooterZ, hitX, hitY, hitZ ) local startX, startY, startZ = getPointInFrontOfPlayer(theShooter, 1.5 ) local rx,ry,rz = math.random(360), math.random(360), math.random(360) startZ = startZ - 0.5 if isPedInVehicle(theShooter) == true or isBadWeapon(weapon) == true then else -- does object exist destroy if it did if shells.object.obj[shells.object.shotCount] ~= nil then if isElement(shells.object.obj[shells.object.shotCount]) then destroyElement(shells.object.obj[shells.object.shotCount]) end shells.object.obj[shells.object.shotCount] = nil end shells.object.obj[shells.object.shotCount] = createObject(321, startX, startY, startZ) setObjectScale ( shells.object.obj[shells.object.shotCount], 5) moveObject ( shells.object.obj[shells.object.shotCount], targetDistance*10, hitX, hitY, hitZ, rx, ry, rz ) outputChatBox ("Count: shells.object.obj" .. tostring(shells.object.shotCount) .. " objects") if (shells.object.obj[shells.object.shotCount]) then triggerServerEvent( "onSpecialEvent", resourceRoot, theShooter, shells.object.obj[shells.object.shotCount] ) outputChatBox ("Sending to server-side") else outputChatBox ("Object does not exist") end end end Server: addEvent ( "onSpecialEvent",true) function objectExplosion (theShooter, object) outputChatBox ( "Player " .. getPlayerName(theShooter) .. " triggered object shoot " ) if ( (targetDistance*10) < 50) then createExplosion ( hitX, hitY, hitZ, 2, theShooter) destroyElement (object) else setTimer ( function() createExplosion ( hitX, hitY, hitZ, 2, theShooter ) destroyElement(object) end, targetDistance*10, 1 ) end end addEventHandler ( "onSpecialEvent", getRootElement(), objectExplosion )
  14. Ok that would work, I'll use it. Just for doubt, how I make it to have a natural movement (gravity, etc) Do I have to mess with the velocity and not the moveObject?
  15. Hi, I have a simple question I was looking in the wiki, but I didn't find how to move a vehicle like you move an object. For example like how gravity gun does. I tried the normal moveObject, but it didn't work
×
×
  • Create New...