Xwad Posted February 3, 2015 Share Posted February 3, 2015 Hi! If I want to make a script that allows to shot with s.w.a.t. vehicle like a rhino then I need to use the CreateProjectile function??Thanks! Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 Can you write here an example possibly please? Link to comment
xeon17 Posted February 3, 2015 Share Posted February 3, 2015 The example on wiki is just awesome , everything good explained. Check! https://wiki.multitheftauto.com/wiki/CreateProjectile Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 do you mean this? becaouse this makes only possible to shoot rockets with minigun -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if weapon == 38 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc) Link to comment
xeon17 Posted February 3, 2015 Share Posted February 3, 2015 Yes , but it's a good example how the createProjectile function work. Also you'll need to use bindKey to create the projectile , when the player hit a key. Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 i have convert the example. is it now good or i goind the bad way? -- This function gets triggered everytime player shoots. function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) if vehicle == 601 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end -- Don't forget to add the onClientPlayerWeaponFireFunc function as a handler for onClientPlayerWeaponFire. addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFireFunc) Link to comment
xeon17 Posted February 3, 2015 Share Posted February 3, 2015 Where is vehicle definied? and , you're using the wrong event Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 Is the event now good? And what do you mean by defined? addEventHandler("onClientVehicleWeaponFire", getLocalVehicle(), onClientVehicleWeaponFireFunc) Link to comment
LaCosTa Posted February 3, 2015 Share Posted February 3, 2015 he meant the vehicle is defined above ?? , it should be like this function onClientPlayerWeaponFireFunc(weapon,ammo,ammoInClip,hitX,hitY,hitZ,hitElement) local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle == 601 then -- if source is a local player and he uses minigun... x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(),19,x,y,z,200) then -- then we either create a projectile... outputChatBox ( "Rocket minigun overheated! Give it a rest pal!", source ) -- or if projectile limit is reached we output player a chat message end end end Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 not working:/ but thanks:( Link to comment
undefined Posted February 3, 2015 Share Posted February 3, 2015 function onSwatFire(key, keyState, vehicleFireType) local vehicle = getPedOccupiedVehicle(localPlayer) local vehModel = getElementModel(vehicle) if vehModel == 601 then if vehicleFireType == "primary" or vehicleFireType == "secondary" then -- your choice local _,_,_,shootX, shootY, shootZ = getCameraMatrix() local ped = createPed(0, shootX, shootY, shootZ) local x,y,z = getElementPosition(vehicle) createProjectile(vehicle--[[vehicle or localPlayer - Your choice]],19,x,y,z+1,200,ped) if isElement(ped) then destroyElement(ped) end end end end bindKey("vehicle_fire", "down", onSwatFire, "primary") bindKey("vehicle_secondary_fire", "down", onSwatFire, "secondary") Try it. (I do not test.) Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 ok thanks i test it! Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 Not working Maybe i have do something wrong....-.- But is the example client or server side? And need i change something in the example? Link to comment
undefined Posted February 3, 2015 Share Posted February 3, 2015 Any errors in the debugscript? Client-side Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 no error i just start the script but the swat tank dosent shoot like a rhino:( need i change something in the example that you write down? Link to comment
undefined Posted February 3, 2015 Share Posted February 3, 2015 You can use https://wiki.multitheftauto.com/wiki/CreateExplosion for original tank shoot. Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 there is no example for what i want. Or need i convert it? Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 can you make me an example pls? Link to comment
xeon17 Posted February 3, 2015 Share Posted February 3, 2015 What do you mean there aren't examples? there are 5 great exmples,or you want someone make the script finished for you? (as always) Link to comment
Xwad Posted February 3, 2015 Author Share Posted February 3, 2015 no i will make it becaouse i will learn it. You sad : dont be lazy i will going to do it. And yeah there are 5 examples but there's no example that makes possible to shoot with the swat vehicle like a rhino. Link to comment
-.Paradox.- Posted February 3, 2015 Share Posted February 3, 2015 Why are you searching for examples here in forum meanwhile there is a site called Multi Theft Auto: Wiki full with hundred of fuctions and thousands of examples. Click here to get redirected to the site: https://wiki.multitheftauto.com/wiki/Main_Page Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now