Jump to content

[WIP|F+|1.1]awesomeufo 2.4


qaisjp

Recommended Posts

Is it a cat? Is it a dog? NO! It's a UFO! lol

Read till the last post for the progress reports.

Hunt your friends down with this massive, controllable UFO and scare the sh*t out of them!

awesomeufo brings to you the easiest way to control a massive UFO! Set the height, press on the map, set the speed and your UFO will be flying to infinity and beyond!

You can even glue yourself to the UFO! (Glue based on glue by uPrell)

Screenshots! th_mta-screen_2011-09-27_17-17-41.pngth_mta-screen_2011-09-27_17-17-34.pngth_mta-screen_2011-09-27_17-16-53.pngth_mta-screen_2011-09-27_17-16-45.pngth_mta-screen_2011-09-27_17-16-43.pngth_mta-screen_2011-09-27_17-16-11.png

Fun feature = NUKE!

Commands =

1) "gotoufo" - Go to the UFO, (not gtfo lol)

2) "ufo" - Manages UFO

3) "ufoheight" -- Set the height of the UFO (dont try "ufoheight inf" ;) )

Coming soon:

1) More extra features like zap etc.

Known bugs:

If you are glued and someone uses "warp to [place]" , you will be unglued (workaround: simply type /gotoufo and you will glue when you come in contact with it)

When nuking repeatedly the coronas dont disappear. If someone can help me with that i will PM them the code snippet (workaround: wait until one nuke is done before nuking again)

Thanks:

map thanks to frederic

Ransom - Superweapons resource

Latest hourly (like a nightly, but more often. but not when i sleep)

To get the latest script click below, remember this is incomplete!

Outdated:

branches_download.png

Edited by Guest
Link to comment
  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

  • Discord Moderators

there are a few ways

this one checks whether the value is a number, but not a number in a string

function isNumber (n) 
    return (type(n) == 'number') 
end 

you should use this one because it converts a number in a string into a number and still works as above, although you should use tonumber (value) if this one returns true, in case it's a string with a number

function isNumber (n) 
    return tonumber (n) 
end 

Link to comment
there are a few ways

this one checks whether the value is a number, but not a number in a string

function isNumber (n) 
    return (type(n) == 'number') 
end 

you should use this one because it converts a number in a string into a number and still works as above, although you should use tonumber (value) if this one returns true, in case it's a string with a number

function isNumber (n) 
    return tonumber (n) 
end 

Thanks, this will help!

Link to comment

Please scroll down since this post is outdated and contains content from before the remake

NUKE! Yes, it's unexpected, but hey, be imaginative!

Newest features:

Fun -- NUKE!

ACL Access - To give access to the respective commands for certain people add this to the ACL.

resource.afs-ufo.ufoheight

resource.afs-ufo.ufoall

resource.afs-ufo.controlufo

Settings.lua contain's a few options and you should have some basic knowledge about LUA in MTA to use this.

branches_download.png

Enjoy!!!

Edited by Guest
Link to comment
  • 4 weeks later...

I have an idea on fixing it ( the script creates an object then destroys it), and because it is done many times, in the end it cant delete the same thing twice. So there needs to be a table for the object. But i have no idea how to do it.

Any ideas, anyone?

Link to comment
  • 5 months later...

Hi, im using mta 1.1 and u got this script but then realized that when i click the close window button from controlling ufo the mouse pointer is there and i cannot walk. it eventually goes away after a few minutes but the only other way i get out of it is if i restart the script and then the ufo moves back to the position it was a few minutes ago and everyone falls through it. Thanks

Link to comment

I created this resource and won't probably be updated unless I am extremely bored. Oh wait, I am extremely bored :) Time to remake this. What do you mean as a zoomed out cam + bulky handling +karlis?

EDIT: Oh btw I deleted this off the commnity, i will update with new link.

EDIT AGAIN: Updated title, and forum topic and downloads.

Link to comment

Basically freecam style, i love that idea. I don't know how I will manage colliding with sa maps. I don't know what the definition of inertia is but i will google it now. The camera will fit to show the entire ufo on the screen.

Thanks for the great idea:

Now who is thinking of making a UFO texture+model?

I will definitely start doing that! =) thx for the idea :D

Edited by Guest
Link to comment

Sorry about the bump but:

Here is the current progress, i will update it whenever I feel like doing so.

client

--[[ 
    This resource has been created by qaisjp 
    Find more epic resources at [url=http://www.code.google.com/p/mta-freeroamplus]http://www.code.google.com/p/mta-freeroamplus[/url] 
    Please give me credit! 
]] 
  
local function iif(a,b,c) if a then return b else return c end return nil end 
local me, ufo = getLocalPlayer(), getElementByID("ufo") 
local data = {} 
  
local sW, sH = guiGetScreenSize() 
local mapSize = iif((sH - 100)>=600, 600, sH - 100) 
local mapX = (sW / 2) - (mapSize / 2) 
local mapY = (sH / 2) - (mapSize / 2) 
  
function tse(st,...) 
    local args = {...} 
    triggerServerEvent(st, root, unpack(args)) 
end 
  
function createEvent(str, hand, func) 
    addEvent(str, true) 
    addEventHandler(str, hand, func) 
end 
--[[ 
  
addEventHandler("onClientGUIClick", button_fun, toggleFunWindow, false) opens the fun stuff. we will have a gridlist attch to btn 
addEventHandler("onClientGUIClick", button_map, mapUfoInit, false) warp to map 
  
triggerServerEvent("ufo:dirHeight", root,tonumber(theHeight)) 
addEventHandler("onClientGUIClick", button_quickmap_go,  
function()  
    pointX = tonumber( guiGetText(edit_coord) ) 
    pointY = tonumber( guiGetText(edit_coord_2)) 
    speed = guiGetText(edit_speed) 
    superSpeed = speed * 1000 
    z = "nothing" 
    if speed and pointX then 
        tse("ufo:moveEvent", tonumber(pointX), tonumber(pointY), z, true, tonumber(superSpeed)) 
    end 
end 
, false) 
      bla bla notes here bla bla bla bla  
  
height_up, function() triggerServerEvent("ufoHeight", root, 3) end, false) 
height_down, function() triggerServerEvent("ufoHeight", root, -3) end, false) 
movement_stop, function() triggerServerEvent("ufoStop", root) end, false) 
LS, function() triggerServerEvent("ufo:move2Loc", root, 835.6, -2086, 500) end, false) 
SF, function() triggerServerEvent("ufo:move2Loc", root, -1357.7, 532.4, 500) end, false) 
LV, function() triggerServerEvent("ufo:move2Loc", root, 2415, 507, 500) end, false) 
nw, function() triggerServerEvent("ufo:moveEvent", root, -160, 160, 0) end, false) 
n, function() triggerServerEvent("ufo:moveEvent", root, 0, 160, 0) end, false) 
ne, function() triggerServerEvent("ufo:moveEvent", root, 160, 160, 0) end, false) 
e, function() triggerServerEvent("ufo:moveEvent", root, 160, 0, 0) end, false) 
se, function() triggerServerEvent("ufo:moveEvent", root, 160, -160, 0) end, false) 
s, function() triggerServerEvent("ufo:moveEvent", root, 0, -160, 0) end, false) 
sw, function() triggerServerEvent("ufo:moveEvent", root, -160, -160, 0) end, false) 
w, function() triggerServerEvent("ufo:moveEvent", root, -160, 0, 0) end, false) 
rot_45nw, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, 45) end, false) 
rot_45ne, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, -45) end, false) 
rot_90ne, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, -90) end, false) 
rot_90nw, function() triggerServerEvent("ufo:rotateUfo", root, 0, 0, 90) end, false)]] 
  
local guiContainer  = {} 
  
function getControl(child) 
    return guiContainer[child] 
end 
  
function mouseToggle() 
    showCursor(not isCursorShowing()) 
end 
  
function showMenu() 
    if data.enabled then return end 
    toggleControl("enter_exit", false) 
    bindKey("f", "down", mouseToggle) 
    showCursor(true) 
    local additions = {"stopedit", "showextras", "extragrid", "mapaccess", "pref"} 
    for i,v in ipairs(additions) do 
        local gui = getControl(v) 
        guiSetVisible(gui, true) 
    end 
    data.enabled = true 
end 
  
addCommandHandler("ufo", showMenu) 
  
function hideMenu() 
    data.enabled = false 
    local additions = {"stopedit", "showextras", "extragrid", "mapaccess", "pref"} 
    for i,v in ipairs(additions) do 
        local gui = getControl(v) 
        guiSetVisible(gui, false) 
    end 
    showCursor(false) 
    toggleControl("enter_exit", true) 
    unbindKey("f", "down", mouseToggle) 
end 
------------------- 
--///////////////--: Create the main screen objects 
------------------- 
  
-- Leave movement mode 
guiContainer["stopedit"] = guiCreateButton(0.7825,0.0583,0.205,0.0617,"Stop Editing",true) 
addEventHandler("onClientGUIClick", getControl("stopedit"), hideMenu) 
  
-- Create the extras menu, to do is sliding the extras gridlist up and down to toggle showing, also moving the btns below it. 
guiContainer["showextras"] = guiCreateButton(0.7825,0.135,0.205,0.0617,"Show Extras",true) 
guiSetProperty(getControl("showextras"),"AlwaysOnTop","True") 
  
guiContainer["extragrid"] = guiCreateGridList(0.7837,0.155,0.2025,0.37,true) 
guiGridListSetSelectionMode(getControl("extragrid"),2) 
guiSetProperty(getControl("extragrid"),"ZOrderChangeEnabled","False") 
guiGridListAddColumn(getControl("extragrid"),"",0.1) 
  
  
guiContainer["mapaccess"] = guiCreateButton(0.7825,0.54,0.205,0.0617,"Quick Map",true) 
  
guiContainer["pref"] = guiCreateButton(0.7825,0.6133,0.205,0.0617,"Preferences",true) 
  
for i = 1, 6 do 
    guiGridListAddRow(getControl("extragrid")) 
end 
  
------------------- 
--///////////////-- 
------------------- 
  
for i,v in pairs(guiContainer) do 
    guiSetVisible(v, false) 
end 
  
------------------- 
--///////////////-- 
------------------- 
  
-- This contains content from the freecam resource and has been editied by karlis, so thanks to him. 
  
local zoom=10 --how far is camera target from elem 
rotX, rotY = 0,0 
local mouseFrameDelay = 0 
local ratio = 3 --how many times distance from camera to player is smaller then distance from player to camera target 
local offset = 0.4 --how much the camera goes to the right from the player (negative for the left) 
local mouseSensetivity = 0.25 --ovbious much? 
local width, height = guiGetScreenSize() 
local PI = math.pi 
local hit 
  
--heavily modified freecam resource's core  
function freecamFrame() 
    if not data.enabled then return end 
     
    do 
        local additions = {"stopedit", "showextras", "extragrid", "mapaccess", "pref"} 
        for i,v in ipairs(additions) do 
            local gui, show = getControl(v), isCursorShowing() 
            guiSetAlpha(gui, show and 1 or 0.9) 
            guiSetEnabled(gui, show) 
        end 
    end 
     
    local cameraAngleX = rotX 
    local cameraAngleY = rotY 
    local freeModeAngleZ = math.sin(cameraAngleY) 
    local freeModeAngleY = math.cos(cameraAngleY) * math.cos(cameraAngleX) 
    local freeModeAngleX = math.cos(cameraAngleY) * math.sin(cameraAngleX) 
    local camPosX, camPosY, camPosZ = getElementPosition(ufo) 
    -- calculate a target based on the current position and an offset based on the angle 
    local camTargetX = camPosX + freeModeAngleX * zoom 
    local camTargetY = camPosY + freeModeAngleY * zoom 
    local camTargetZ = camPosZ + freeModeAngleZ * zoom 
    local camPosX = camPosX - ( camTargetX - camPosX ) / ratio 
    local camPosY = camPosY - ( camTargetY - camPosY ) / ratio 
    local camPosZ = camPosZ - ( camTargetZ - camPosZ ) / ratio 
    if not isLineOfSightClear(camPosX,camPosY,camPosZ,camPosX,camPosY,camPosZ,true,true,true,true,false,true,false,me) then 
        _,camPosX,camPosY,camPosZ=processLineOfSight(camTempPosX,camTempPosY,camPosZ,camPosX,camPosY,camPosZ,true,true,true,true,false,true,false,false,localPlayer) 
        camPosX,camPosY,camPosZ=camPosX-(camTempPosX-camPosX)*0.1,camPosY-(camTempPosY-camPosY)*0.1,camPosZ-(camTempPosZ-camPosZ)*0.1 
    end 
    -- Set the new camera position and target 
    setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ ) 
end 
addEventHandler("onClientRender", root, freecamFrame) 
  
function freecamMouse(_,_,aX,aY) 
    --ignore mouse movement if the cursor or MTA window is on 
    --and do not resume it until at least 5 frames after it is toggled off 
    --(prevents cursor mousemove data from reaching this handler) 
    if not data.enabled then return end 
    if isCursorShowing() or isMTAWindowActive()  then 
        mouseFrameDelay = 5 
        return 
    elseif mouseFrameDelay > 0 then 
        mouseFrameDelay = mouseFrameDelay - 1 
        return 
    end 
    -- how far have we moved the mouse from the screen center? 
    aX = aX - width / 2 
    aY = aY - height / 2 
    rotX = rotX + aX *  0.01745 * mouseSensetivity 
    rotY = rotY - aY *  0.01745 * mouseSensetivity 
    if rotX > PI then 
        rotX = rotX - 2 * PI 
    elseif rotX < -PI then 
        rotX = rotX + 2 * PI 
    end 
    if rotY > PI then 
        rotY = rotY - 2 * PI 
    elseif rotY < -PI then 
        rotY = rotY + 2 * PI 
    end 
    -- limit the camera to stop it going too far up or down - PI/2 is the limit, but we can't let it quite reach that or it will lock up 
    -- and strafeing will break entirely as the camera loses any concept of what is 'up' 
    if rotY < -PI / 3 then 
       rotY = -PI / 3 
    elseif rotY > PI / 3 then 
        rotY = PI / 3 
    end 
    -- work out an angle in radians based on the number of pixels the cursor has moved (ever) 
end 
addEventHandler("onClientCrsorMove", root, freecamMouse) 

server

allowAll = false 
local ufo = createObject ( 13607, -1326, -67, 55, 0, 0, 0 ) 
createBlipAttachedTo ( ufo, 37 ) 
setElementData(ufo, "vglueable", true, true) 
setElementDoubleSided( ufo, true) 
setElementID(ufo, "ufo") 
  
addCommandHandler("gotoufo",  
    function(thePlayer) 
        if thePlayer then 
            ufoWarpPlayer(thePlayer) 
        end 
    end 
) 
  
addCommandHandler("ufoheight",  
    function(thePlayer, cmd, height) 
        ufoSetHeight(height) 
    end 
) 
  
  
-- Zap thingy 
function zapMeUp() 
    local x,y,z = getElementPosition(ufo) 
    triggerClientEvent ( "ufo:ClientFireN", getRootElement(), x, y, z - 50 ) 
end 
addEvent("zapUFO", true) 
addEventHandler("zapUFO", getRootElement(), zapMeUp) 
  
addEvent("ufo:warp_player_to_ufo", true) 
function ufoWarpPlayer(pl) 
    local x,y,z = getElementPosition(ufo) 
    setElementPosition(pl, x, y, z + 0.5) 
end 
addEventHandler("ufo:warp_player_to_ufo", getRootElement(), ufoWarpPlayer) 
  
function ufoSetHeight(height) 
    if tonumber(height) then 
        local x,y,z = getElementPosition(ufo) 
        setElementPosition(ufo, x, y, tonumber(height)) 
    end 
end 
addEvent("ufo:dirHeight", true) 
addEventHandler("ufo:dirHeight", getRootElement(), ufoSetHeight) 
  
function stopMove() 
    stopObject(ufo) 
end 
addEvent("ufoStop", true) 
addEventHandler("ufoStop", getRootElement(), stopMove) 
  
  
-- ufo raise/lower/reset 
function ufoHeight(theValue) 
    local x, y, z = getElementPosition(ufo) 
    if (theValue == 5.5) then 
        moveObject(ufo, 0, x, y, 5.5) 
    else 
        moveObject(ufo, 5000, x, y, z + theValue) 
    end 
end 
addEvent("ufoHeight", true) 
addEventHandler("ufoHeight", getRootElement(), ufoHeight) 
  
-- ufo warper 
function ufoWarper(x, y, z) 
    moveObject(ufo, 0, x, y, z) 
end 
addEvent("ufo:move2Loc", true) 
addEventHandler("ufo:move2Loc", getRootElement(), ufoWarper) 
  
-- Directional movement controls 
function ufoMove(, yD, zD, direct,speed) 
    local x,y,z = getElementPosition(ufo) 
    if not direct then 
        moveObject(ufo, 20000, x + , y + yD, z + zD) 
    elseif direct then 
        moveObject(ufo, speed, ,yD,z) 
    end 
end 
addEvent("ufo:moveEvent", true) 
addEventHandler("ufo:moveEvent", getRootElement(), ufoMove) 
  
-- Rotational movement controls 
function rotateUfoFunc(rX, rY, rZ) 
    local x,y,z = getElementPosition(ufo) 
    moveObject(ufo, 5000, x, y, z, rX, rY, rZ) 
end 
addEvent("ufo:rotateUfo", true) 
addEventHandler("ufo:rotateUfo", getRootElement(), rotateUfoFunc) 
  
  
  
-- **************************************** 
-- * Super weapons - Ion Nuke - By Ransom * 
-- **************************************** 
  
function NukeFinished () 
    N_Active = false     
end 
addEvent("ufo:serverNukeFinished", true)  
addEventHandler("ufo:serverNukeFinished", root, NukeFinished) 
  
function KillNukedPlayer () 
    killPed( source ) 
    outputChatBox ( "#ff0000*UFO: #ffff00You got attacked by the UFO!", source, 105, 252, 55, true )     
end 
addEvent("ufo:serverKillNukedPlayer", true)  
addEventHandler("ufo:serverKillNukedPlayer", root, KillNukedPlayer) 
  

code is verry messy atm.but if you test it ingame, type /ufo and press f to toggle.

@Karlis, the camera fails.

Link to comment

That explain's why the camera doesn't move :P

Sorry about last night, i fell asleep :cry:

karlis, i don't think I will use your edit, probably just a part of it. Since I wouldn't have to recreate the moving.

I think, that rotating the screen look-at should rotate the UFO.

You should only be allowed to move FORWARD, and to turn around you have to rotate the ufo. If someone modelled a new ufo for me, then it would also be moving from the front of the ufo.

To get the latest script click below, remember this is incomplete!

Link to comment

Lol, I will be learning vectors and matrices in a few months, and atm i don't know what they are. So...how do I get the rotation of the cam vect and apply it to the obj? (getCameraMatrix?)

UPDATE!! http://pastebin.com/W46QjvR1

The ufo moves using camera (only by W [accel], i disabled strafing and backward)

In the code I want the ufo view to be like how is was in the code karlis gave me (uncomment that bigblock and comment below it).. but I'm not sure how..

Link to comment

Well, just moves on a X and Y axis depending on where the camera is showing at. Z will be added later via scroll.

edit: NEW UPDATE!

To get the latest script click below, remember this is incomplete!

Implemented Z movement via scrolling mouse wheel.

Implemented extras menu.

Color codes:

RED/GREEN = Boolean.

Yellow = window

lightblu/cyan = action

Only one of them are added atm. That is the option to toggle scrolling :)

Again, i request someone to model a new ufo (preferably with an interior :) ) and I need someone to edit the end of the script (freecam part ONLY) to make sure the camera shows the entire ufo :D Please.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...