Jump to content

WhoAmI

Members
  • Posts

    1,248
  • Joined

  • Last visited

Everything posted by WhoAmI

  1. http://pastebin.com/hV9vgpgQ
  2. client addEventHandler ( "onClientVehicleDamage", root, function ( attackerElement ) if ( getElementModel ( source ) ~= 432 ) then return; end cancelEvent ( ); if ( attackerElement and getElementType ( attackerElement ) == "projectile" ) then outputChatBox ( "It's projectile!" ); if ( getProjectileType ( attackerElement ) == 21 ) then triggerServerEvent ( "destroy", localPlayer, source ); end end end ); server addEvent ( "destroy", true ); addEventHandler ( "destroy", root, function ( vehicle ) setElementHealth ( vehicle, getElementHealth ( vehicle ) - 250 ); end ); Tell me if 'It's projectile!' appears on chatbox if you shot rhino.
  3. You sure that projectile ID is 21? Because 21 is "Air Bomb".
  4. client.lua --------------------------- --(c) by MazzMan/Maxim --------------------------- canDriverUseGun = true ammo = {} ammo.small = false ammo.middle = false ammo.big = true ammo.smallShots = 50 ammo.middleShots = 6 ammo.smallCanShoot = true ammo.middleCanShoot = true ammo.smallReloading = false ammo.middleReloading = false ammo.bigReloading = false setElementData(getLocalPlayer(), "ac130KeysBound", false) addEventHandler("onClientVehicleEnter", getRootElement(), function(thePlayer, seat) if(getLocalPlayer() == thePlayer and getElementModel(source) == 592 and getElementData(source, "ac130"))then if(canDriverUseGun)then bindKey("space", "down", setBinds) elseif(seat == 1)then bindKey("space", "down", setBinds) end end end) function removeAllGunControls() unbindKey("space", "down", setBinds) setCameraGoggleEffect("normal") setElementData(getLocalPlayer(), "ac130KeysBound", false) removeEventHandler("onClientRender", getRootElement(), keepCamAtAc130) removeEventHandler("onClientCursorMove", getRootElement(), cammera) unbindKey("mouse1", "down", shoot) setCameraTarget(getLocalPlayer()) unbindKey("mouse_wheel_up", "down", changeAmmo) unbindKey("mouse_wheel_down", "down", changeAmmo) unbindKey("v", "down", setVisionMode) end addEventHandler("onClientVehicleExit", getRootElement(), removeAllGunControls) addEventHandler("onClientResourceStop", getRootElement(), removeAllGunControls) addEventHandler("onClientPlayerWasted", getRootElement(), function() if(source == getLocalPlayer())then removeAllGunControls() end end) local windowX, windowY = guiGetScreenSize() function cammera(screenX, screenY, absoluteX, absoluteY, vx,vy,vz) local x,y,z = getElementPosition(getPedOccupiedVehicle(getLocalPlayer())) local rx, ry, rz = getElementRotation(getPedOccupiedVehicle(getLocalPlayer())) rz = rz +180 local cx = x + math.cos(math.rad(rz)) * 3 local cy = y + math.sin(math.rad(rz)) * 3 setCameraMatrix ( cx, cy, z, vx, vy, vz ) drawHud() end function keepCamAtAc130() local x,y,z = getElementPosition(getPedOccupiedVehicle(getLocalPlayer())) local rx, ry, rz = getElementRotation(getPedOccupiedVehicle(getLocalPlayer())) rz = rz +180 local cx = x + math.cos(math.rad(rz)) * 3 local cy = y + math.sin(math.rad(rz)) * 3 setCameraMatrix(cx, cy, z) end function setBinds() if(getElementData(getLocalPlayer(), "ac130KeysBound") == false)then setElementData(getLocalPlayer(), "ac130KeysBound", true) keepCamAtAc130 ( ) addEventHandler("onClientCursorMove", getRootElement(), cammera) addEventHandler ( "onClientRender", root, drawHud ) bindKey("mouse1", "down", shoot) bindKey("mouse_wheel_up", "down", changeAmmo) bindKey("mouse_wheel_down", "down", changeAmmo) bindKey("v", "down", setVisionMode) else setElementData(getLocalPlayer(), "ac130KeysBound", false) removeEventHandler("onClientCursorMove", getRootElement(), cammera) removeEventHandler ( "onClientRender", root, drawHud ) unbindKey("mouse1", "down", shoot) setCameraTarget(getLocalPlayer()) unbindKey("mouse_wheel_up", "down", changeAmmo) unbindKey("mouse_wheel_down", "down", changeAmmo) unbindKey("v", "down", setVisionMode) setCameraGoggleEffect("normal") end end function shoot() local cx, cy, cz = getCameraMatrix() local wX,wY,wZ = getWorldFromScreenPosition(windowX/2, windowY/2, 2000) local hit, x, y, z = processLineOfSight(cx, cy, cz, wX,wY,wZ) if(hit)then local distance = getDistanceBetweenPoints3D(x, y, z, cx, cy, cz) local time = distance/0.5 local ammoType if(ammo.small)then if(time >= 50)then if(ammo.smallCanShoot and ammo.smallReloading == false)then --im using a timer, becaus a while loop will cause to crash the game shootTimer = setTimer(function() if(getKeyState("mouse1"))then cx, cy, cz = getCameraMatrix() wX,wY,wZ = getWorldFromScreenPosition(windowX/2, windowY/2, 2000) hit, x, y, z = processLineOfSight(cx, cy, cz, wX,wY,wZ) if(hit)then playSound("sounds/shot_small.wav") ammoType = "small" ammo.smallShots = ammo.smallShots - 1 if(ammo.smallShots == 0)then setReloading("small") killTimer(shootTimer) end ammo.smallCanShoot = false setTimer(function() ammo.smallCanShoot = true end, 200, 1) triggerServerEvent("onAc130Shoot", getRootElement(),cx, cy, cz, x, y, z, time, ammoType) end else killTimer(shootTimer) end end, 50, 0) else return false end else return false end elseif(ammo.middle)then if(time >= 50)then if(ammo.middleCanShoot and ammo.middleReloading == false)then ammoType = "middle" ammo.middleShots = ammo.middleShots - 1 if(ammo.middleShots == 0)then setReloading("middle") end ammo.middleCanShoot = false playSound("sounds/shot_middle.wav") setTimer(function() ammo.middleCanShoot = true end, 500, 1) else return false end else return false end elseif(ammo.big)then if(ammo.bigReloading == false)then if(time >= 50)then ammoType = "big" playSound("sounds/shot_middle.wav") setReloading("big") else return false end else return false end end triggerServerEvent("onAc130Shoot", getRootElement(),cx, cy, cz, x, y, z, time, ammoType) end end function changeAmmo(key) if(key == "mouse_wheel_up")then if(ammo.small)then ammo.small = false ammo.big = true elseif(ammo.middle)then ammo.middle = false ammo.small = true elseif(ammo.big)then ammo.big = false ammo.middle = true end else if(ammo.small)then ammo.small = false ammo.middle = true elseif(ammo.middle)then ammo.middle = false ammo.big = true elseif(ammo.big)then ammo.big = false ammo.small = true end end end function setReloading(ammoType) if(ammoType == "small")then ammo.smallReloading = true setTimer(function() ammo.smallReloading = false ammo.smallShots = 50 end, 3000, 1) elseif(ammoType == "middle")then ammo.middleReloading = true setTimer(function() ammo.middleReloading = false ammo.middleShots = 6 end, 3000, 1) elseif(ammoType == "big")then ammo.bigReloading = true setTimer(function() ammo.bigReloading = false end, 3000, 1) end end function setVisionMode() if(getCameraGoggleEffect() == "normal")then setCameraGoggleEffect("nightvision") elseif(getCameraGoggleEffect() == "nightvision")then setCameraGoggleEffect("thermalvision") elseif(getCameraGoggleEffect() == "thermalvision")then setCameraGoggleEffect("normal") end end addEvent("onClientCreateEffect", true) addEventHandler("onClientCreateEffect", getRootElement(), function(x,y,z, lx, ly, lz, type, time) if(type ~= "small")then --playSound3D("sounds/shot_middle.wav", x,y,z) --local num = math.random(1, 3) --local projectileSound = playSound3D("sounds/projectile_"..num..".wav", lx, ly, lz)
  5. Errors debugscript?
  6. massRotateObjects = function(player,cmd,rotZ) local elementTypes = {"object", "vehicle", "pickup", "marker", "racepickup", "spawnpoint", "checkpoint", "blip", "controlpoint", "track"} local rotated = 0 for _,elemType in ipairs(elementTypes) do for i,elem in ipairs(getElementsByType(elemType)) do local rx,ry,rz = getElementRotation(elem) setElementRotation(elem, rx, ry, rz + rotZ) setElementData(elem, "rotZ", rz + rotZ) rotated = rotated + 1 end end end addCommandHandler("rotz", massRotateObjects)
  7. addEvent ( "destroy", true ); -- adding custom event addEventHandler ( "destroy", root, -- attaching it function ( ) -- to this function setElementHealth ( source, getElementHealth ( source ) - 250 ); end );
  8. Show your current code and use [lua ] [ /lua] highlighting.
  9. client.lua addEventHandler ( "onClientVehicleDamage", root, -- creating an event function ( attackerElement ) -- attaching funciton to it if ( getElementModel ( source ) ~= 432 ) then -- checking if vehicle is rhino return; -- if not canceling function end local attackerElementType = getElementType ( attackerElement ); -- getting type of attacker element if ( attackerElementType == "projectile" ) then -- checking if it is projectile local projectileType = getProjectileType ( attackerElement ); -- getting type of projectile if ( projectileType == 21 ) then -- checking if projectile has 21 id triggerServerEvent ( "destroy", source ); -- triggering serverside event which will destroy rhino end end end ); server.lua addEvent ( "destroy", true ); -- adding custom event addEventHandler ( "destroy", root, -- attaching it function ( ) -- to this function destroyElement ( source ); -- destroying rhino end ); meta.xml > ="client.lua" type="client" /> ="server.lua" type="server" />>
  10. change function(rotZ) to function(Player,cmd,rotZ)
  11. onVehicleDamage getElementType getProjectileType destroyElement
  12. WhoAmI

    givePlayerMoney

    1.function mysterymoney () 2.local money = getPlayerMoney() 3.if (money < 8000) then 4. outputChatBox ("NO TIENES SUFICIENTE DINERO") 5.return 6.else 7.triggerServerEvent ("quitardinero",localPlayer) 8.end 9.end 10. If doesn't work check debugscript.
  13. WhoAmI

    givePlayerMoney

    function mysterymoney (thePlayer) local money = getPlayerMoney(thePlayer) if (money < 8000) then outputChatBox ("NO TIENES SUFICIENTE DINERO") return else triggerServerEvent ("quitardinero",thePlayer) end end
  14. WhoAmI

    givePlayerMoney

    Also add 'root' to event s-side, because as far as I can see you've forgotten about it.
  15. WhoAmI

    givePlayerMoney

    Remove player from function's argument and use source instead.
  16. WhoAmI

    help dxText

    #RooTs, leave this forum, pls. ;-;
  17. Tell me how you call the function. What are you giving in 2nd argument.
  18. function move_at_gate(hitPlayer, matchingDimension) if not ( getElementType ( hitPlayer ) == "player" or matchingDimension ) then return; end local gangName = getElementData(hitPlayer, "gang") if gangName == "Alpha Team" then moveObject(at_gate, 2000, -2862.0068359375, 468.7, 11.2, 0, 0, 0) end end addEventHandler("onMarkerHit", at_marker, move_at_gate)
  19. WhoAmI

    givePlayerMoney

    You have to set money serverside. Client side won't work. Like that setPlayerMoney ( player, getPlayerMoney ( player ) - amount )
  20. WhoAmI

    help dxText

    Check if variables 'a' and 'e' are returning correct values.
  21. Errors in debug? Are you putting them s-side?
  22. function saveWeapons ( ) local account = getPlayerAccount ( source ); if ( isGuestAccount ( account ) ) then return; end local t = { } for slot = 0, 12 do local weapon = getPedWeapon ( source, slot ); if ( weapon > 0 ) then local ammo = getPedTotalAmmo ( source, slot ); if ( ammo > 0 ) then t [ weapon ] = ammo; end end end setAccountData ( account, "weapons", t ); end function loadWeapons ( _, account ) if ( isGuestAccount ( account ) ) then return; end local t = getAccountData ( account, "weapons" ); if ( t ) then for weapon, ammo in pairs ( t ) do giveWeapon ( source, tonumber ( weapon ), tonumber ( ammo ) ); end end end addEventHandler ( "onPlayerQuit", root, saveWeapons ); addEventHandler ( "onPlayerLogout", root, saveWeapons ); addEventHandler ( "onPlayerLogin", root, loadWeapons );
  23. viewtopic.php?f=106&t=58533
  24. function cars () c1 = createVehicle ( 520, -2891.84765625, 460.4560546875, 4.9140625, 0, 0, 90 ) end addEventHandler ( "onResourceStart", resourceRoot, cars ) function onEnter(thePlayer) if getElementModel(thePlayer) == 520 and getElementData(thePlayer, "class") ~= "Admin" then outputChatBox("This Vehicle Is Locked for the Class:Admin", thePlayer, 0, 255, 0) cancelEvent() end end addEventHandler("onVehicleStartEnter", root, onEnter)
  25. Use callRemote to connect MTA with website.
×
×
  • Create New...