Sticky: [TUT] How to install shooter script

Show here your self made maps!

Sticky: [TUT] How to install shooter script

Postby Jessie » Fri Nov 08, 2013 7:44 am

Hello,

In this tutorial i will show you how to install a shooter script for your map.

First you need to finish your map before you insert the shooter script.

After you finished the map you need to insert the shooter script.

You need to open a .txt file and copy and past this code in it:
Code: Select all
cLP = getLocalPlayer()
screenWidth, screenHeight = guiGetScreenSize()

function cRStest()
   setTimer(resourcesCheck, 10000, 1)
end
addEventHandler("onClientResourceStart", getRootElement(), cRStest)

function resourcesCheck()
   if check=="done" then return
   else
      setTimer(cbinds, 1000, 1)
      textToggle=0
      check="done"
   end
end

function cRS()
   if check=="done" then return
   else
      setTimer(cbinds, 3333, 1)
      textToggle=0
      check="done"
   end
end
addEventHandler("onClientPlayerSpawn", getLocalPlayer(), cRS)

function markers(player)
   if isPedInVehicle(player) then
      local vehicle = getPedOccupiedVehicle(player)
      fixVehicle(vehicle)
   end
end
addEventHandler("onClientMarkerHit", getResourceRootElement(getThisResource()), markers)

function cbinds()
   local keys1 = getBoundKeys("vehicle_fire")
   local keys2 = getBoundKeys("vehicle_secondary_fire")
   if keys1 then
      for keyName, state in pairs(keys1) do
         bindKey(keyName, "down", cdoshoot)
      end
      bindKey("F", "down", cdoshoot)
      cbindsText = "- Use 'F' or Left mouse click to shoot rockets.\n- You can shoot a rocket every 3 seconds.\n- I hope you enjoy, goodluck and have fun."
   end
   if keys2 then
      for keyName, state in pairs(keys2) do
         bindKey(keyName, "down", cdoshoot)
      end
   end
   if (not keys1) and (not keys2) then
      bindKey("F", "down", cdoshoot)
      bindKey("lctrl", "down", cdoshoot)
      bindKey("rctrl", "down", cdoshoot)
      cbindsText = "- Use 'F' or Left mouse click to shoot rockets.\n- You can shoot a rocket every 3 seconds."
   end
   theVehicle = getPedOccupiedVehicle(cLP)
   allowShoots()
   bindKey("K", "down", toggleText)
   outputChatBox("#660033[MAP]:#ffffff Press #660033'K'#ffffff to show/hide instructions", 255, 255, 255, true)
end

function toggleText()
   if textToggle==0 then
      addEventHandler("onClientRender", getRootElement(), bindsText)
      textToggle=1
   elseif textToggle==1 then
      removeEventHandler("onClientRender", getRootElement(), bindsText)
      textToggle=0
   end
end

function allowShoots()
   bindTrigger = 1
end

function cdoshoot()
   if bindTrigger == 1 then
      if not isPlayerDead(cLP) then
         bindTrigger = 0
         local x,y,z = getElementPosition(theVehicle)
         local rX,rY,rZ = getVehicleRotation(theVehicle)
         local x = x+4*math.cos(math.rad(rZ+90))
         local y = y+4*math.sin(math.rad(rZ+90))
         createProjectile(theVehicle, 19, x, y, z, 1.0, nil)
         setTimer(allowShoots, 3000, 1)
      end
   end
end

function bindsText()
   dxDrawText(cbindsText, screenWidth/15, screenHeight/2.5, screenWidth, screenHeight, tocolor(0, 149, 254, 255), 0.75, "bankgothic")
end


function startMusic()
    setRadioChannel(0)
    song = playSound("sound.mp3",true)

end

function makeRadioStayOff()
    setRadioChannel(0)
    cancelEvent()
end

function toggleSong()
    if not songOff then
       setSoundVolume(song,0)
      songOff = true
      removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
   else
       setSoundVolume(song,1)
      songOff = false
      setRadioChannel(0)
      addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
   end
end

addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic)
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff)
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff)
addCommandHandler("musicmusic",toggleSong)
bindKey("m","down","musicmusic")
             
             
           

And save it as shoot.lua.

Now we have to add a line to the meta.xml for it to work.

You have to add this line:

Code: Select all
<script src="shoot.lua" type="client"></script>


And save the meta.xml, now it should work.

If you have any questions/problems you can post it here.

Good luck and have fun!
Image
Image
User avatar
Jessie
MX Leader
MX Leader
 
Posts: 380
Joined: Sun May 12, 2013 8:28 pm
In-game: Jessye+

Re: Sticky: [TUT] How to install shooter script

Postby ~Speed~ » Fri Nov 08, 2013 4:08 pm

To use music:
Download the music you want (i use http://www.video2mp3.net/). (for mx max 4MB)
Use the script from Jessie.
Rename your music file with "sound.mp3".
At last paste this line into the meta.xml:
Code: Select all
<file src="sound.mp3"></file>

Hope it works.
Image
Image
~Speed~
MX Member
MX Member
 
Posts: 146
Joined: Wed Jul 03, 2013 4:40 pm
In-game: MX-Speed

Re: Sticky: [TUT] How to install shooter script

Postby Jessie » Fri Nov 08, 2013 7:46 pm

~Speed~ wrote:To use music:
Download the music you want (i use http://www.video2mp3.net/). (for mx max 4MB)
Use the script from Jessie.
Rename your music file with "sound.mp3".
At last paste this line into the meta.xml:
Code: Select all
<file src="sound.mp3"></file>

Hope it works.



Euhm... http://mx-palace.com/mx_forum/viewtopic.php?f=18&t=452
Image
Image
User avatar
Jessie
MX Leader
MX Leader
 
Posts: 380
Joined: Sun May 12, 2013 8:28 pm
In-game: Jessye+

Re: Sticky: [TUT] How to install shooter script

Postby ~Speed~ » Sat Nov 09, 2013 9:17 am

:D didn't saw that xd
Image
Image
~Speed~
MX Member
MX Member
 
Posts: 146
Joined: Wed Jul 03, 2013 4:40 pm
In-game: MX-Speed

Re: Sticky: [TUT] How to install shooter script

Postby khalil15832 » Mon Nov 09, 2015 10:39 pm

Gj man +1
Image
User avatar
khalil15832
 
Posts: 7
Joined: Mon Nov 09, 2015 9:47 pm
In-game: SpiRoo


Return to Maps

Who is online

Users browsing this forum: No registered users and 4 guests

cron