Jump to content

.:HyPeX:.

Members
  • Posts

    1,255
  • Joined

  • Last visited

Posts posted by .:HyPeX:.

  1. Hello Forum, first of all, I'm from Argentina so sorry for my bad English. Well, I 'm scripting is a command which lets you listen to music from youtube. Already finished but I would like to know if there is any way to get the name of the video.

    Please help.

    Regards, Enz0Z

    Depends on the method, for the most part, youtube links all have the video name in the web page name.

    This is mine (Kinda old, but still works):

    Server

      
    addCommandHandler('ls',function(player,cmd,url) 
    local url = url:gsub("www.", "") 
    local url = url:gsub("https://", "") 
    local url = url:gsub("http://", "") 
    if string.find(url:lower(), "youtube.com") then 
        local url = url:gsub('youtube.com','') 
        local url = url:gsub('/watch%?v%=','') 
        if string.find(url,'%&list%=') then 
        outputChatBox('#ff0000youtube playlists are not allowed!',player,255,255,255,true) 
        return 
        end 
        outputChatBox('sending '..url) 
        triggerClientEvent(root,'LoadClientSong',resourceRoot,getPlayerName(player), url) 
    else 
    outputChatBox('#ff0000Please use a youtube song!',player,255,255,255,true) 
    end 
    end) 
      
    

    Client

      
    local x,y = guiGetScreenSize() 
    local browser = createBrowser(x,y,false,false) 
    local currentSong = '' 
    local Player = '' 
    local newTitle = '' 
      
    local text = 'Random Crappy Text' 
    local g_Font = dxCreateFont('hvrom.otf',15,false,"antialiased") 
    local scale = 10 
    local maxW = x*0.1 
      
    local w = dxGetTextWidth(text,scale,g_Font) 
    while w > maxW do 
    scale = scale - 0.01 
    local w = dxGetTextWidth(text, scale, g_Font) 
        if w < maxW then     
        break end 
    end 
      
      
    addEvent('LoadClientSong',true) 
    addEventHandler('LoadClientSong',root,function(player,url) 
       if browser then   
       Player = player 
       local newURL = 'https://youtube.com/embed/'..url..'?autoplay=1' 
       loadBrowserURL(browser,newURL) 
       outputChatBox('loading '..newURL) 
       currentSong = newURL 
       end 
    end) 
      
    addEventHandler('onClientBrowserNavigate',root,function(url) 
        if source == browser then 
            if url ~= currentSong then 
            outputChatBox('unallowed!') 
            cancelEvent() 
            end 
        end 
    end) 
      
    local start = getTickCount() 
      
    addEventHandler('onClientRender',root,function() 
    dxDrawImageSection(x*0.5,y*0.75 + (y*0.2)*0.15,x*0.2,(y*0.2)*0.85,0,y*0.05,x,y*0.85,browser) 
    local title = getBrowserTitle(browser) 
    if title ~= newTitle then 
    newTitle = title 
      
        local width = dxGetTextWidth(title.."  ",1*scale,g_Font) 
        target = nil 
        target = dxCreateRenderTarget(width, dxGetFontHeight(1*scale,g_Font),true) 
        targetX,targetY = width,dxGetFontHeight(1*scale,g_Font) 
        outputChatBox(targetX*10) 
        start = getTickCount() 
        end 
    if title then 
        if target then 
        dxSetRenderTarget(target) 
        dxSetBlendMode('modulate_add') 
        dxDrawRectangle(0,0,targetX,targetY,tocolor(0,0,0,255)) 
        dxDrawText(' ' ..title,0,0,targetX,targetY,tocolor(255,255,255,255),1*scale,g_Font)  
        dxSetRenderTarget() 
        dxSetBlendMode('add') 
        local now = getTickCount() 
        local p = (now-start)/(targetX*100) 
        if p >= 1 and p < 2 then 
        p = 0 
        elseif p >= 2 then 
        start = getTickCount() 
        end 
        local calx = p*targetX 
        local calx2 = x*0.2 
        if calx >= targetX - x*0.2 then 
        calx2 = targetX - calx 
        end 
        dxDrawRectangle(x*0.5,y*0.95,x*0.2,y*0.05,tocolor(0,0,0,255)) 
        dxDrawImageSection(x*0.5,y*0.95,calx2,targetY,calx,0,calx2,targetY,target) 
        dxSetBlendMode('blend') 
        end 
        if Player and Player ~= '' then 
        dxDrawText(' Player: '..Player:gsub('#%x%x%x%x%x%x',''),x*0.5,y*0.965,x,y,tocolor(255,255,255,255),1*scale,g_Font) 
        end 
    end 
    end) 
    

  2. I'm working out an IA which will control a helicopter, and mostly will just keep its rotation within the angles specified.

    So far said IA does fine when rotation is applied and height, keeping the helicopter suprisingly quiet. However, whenever i add any angle to the X or Y axis.. it works fine for the first.. 3 seconds? then the rotation axis of Y kicks in and it goes to whatever number and the maths no longer check out. (When the Y axis is flipped the X axis is affected aswell) so i'd like to know how can i properly keep them stable in a 0-360 basis.. and not have them flipping arround whenever another axis alternates (Why is this even a thing?!)

    Greetz.

  3. function collision (projectile) 
        local time = projectile.counter / 10 
        local velocity = projectile.velocity 
        velocity = velocity * time 
        -- 
        local position = projectile.position + velocity 
        local sight, x, y, z = processLineOfSight( 
            projectile.position, 
            position, 
            true, 
            true, 
            true, 
            true, 
            true, 
            true, 
            true, 
            false, 
            nil, 
            true     
        ) 
        position = (sight and Vector3(x, y, z)) or position 
        -- 
        Marker( 
            position, 
            'corona', 
            3 
        ) 
    end 
      
    addEventHandler( 
        'onClientProjectileCreation', 
        root, 
        function() 
            collision(source) 
        end 
    ) 
      
    

    While it probably works, it doesnt apply to my case. It checks if anything is in the missile path, but if an object is moving and enters the path after it was fired, it wouldnt work. I.e. It doesnt take into consideration the target's movement.

  4. @Codyl , What's this ???? you need to added the function name not a table.

    f19af561db.png

    I think id need to run tests, but i belive this should work due to how lua works.

  5. TL;DR, this script calculates two objects and their trajectory and checks if they intersect in any given point, however, it just works sometimes... and sometimes it doesnt.

    As you can see, the code DOES work, since it creates a marker where it is expected to hit the target (Where the collision warning was triggered), however, i'm able sometimes to just hit the target with my missiles flawlessly and the warning wont trigger.

    http://i.imgur.com/ha7hS6r.jpg

    EDIT: Some more images here and here .

    Script:

      
      
    local pos = localPlayer.position 
    local veh = createVehicle(411, pos.x + 10, pos.y, pos.z) 
    setElementFrozen(veh,true) 
    function calculateTrajectory(Object1,Object2,time) 
    local p = {} 
    p[1] = Vector3(Object1.position) 
    p[2] = Vector3(Object2.position) 
      
    local v = {} 
    v[1] = (Vector3(Object1.velocity) * 50) 
    v[2] = (Vector3(Object2.velocity) * 50) 
      
    for i=1, math.floor(time/50) do 
    local time = time +  i * 50 
    local nP = {} 
    nP[1] = p[1] + ((v[1]) * (time/1000)) 
    nP[2] = p[2] + ((v[2]) * (time/1000)) 
      
    d = nP[1] - nP[2] 
    if (math.abs(d.x) > 20) or (math.abs(d.y) > 20) or (math.abs(d.z) > 20) then 
    else 
    outputChatBox(math.abs(d.x) .. " " .. math.abs(d.y).. " "..math.abs(d.z)) 
    end 
        if math.abs(d.x) < 5 and math.abs(d.y) < 5 and math.abs(d.z) < 5 then 
        outputChatBox("Collision warning!") 
        createMarker(nP[1],"corona",4,255,0,0) 
        return 
        end 
    end 
    end 
      
    addEventHandler("onClientProjectileCreation",root,function() 
    calculateTrajectory(source,veh,getProjectileCounter(source)) 
    outputChatBox('projectile',255,0,0) 
    end) 
      
    

    PD: i know there should be a correct formula for calculating this, bear with my lazyness to make it with a loop.

  6. r,g,b = r/255,g/255,b/255 
    dxSetShaderValue(Shaders[i],"r",{r,g,b,1}) 
    dxSetShaderValue(Shaders[i],"g",{0,0,0,1}) 
    dxSetShaderValue(Shaders[i],"b",{0,0,0,1}) 
    dxSetShaderValue(Shaders[i],"a",{0,0,0,1}) 
    

    Values are correctly set, so far discovered its some sort of shader issue, 255,0,0 RGB will be red, 255,75,75 will turn blank :?

  7. Well, for some reason my shaders wont have the colors assigned..

    script:

      
    dY = -5.3499999046326 
    dX = -4.4745998382568 
      
    Colors = { 
    {255,75,75}, 
    {75,255,75}, 
    {75,75,255}, 
    {255,255,255}, 
    {0,0,0}, 
    {255,255,75}, 
    {255,75,255} 
    } 
      
    Shaders = {} 
      
    for i=1,#Colors do 
    Shaders[i] = dxCreateShader("colorShader.fx") 
    local r,g,b = unpack(Colors[i]) 
    --local r,g,b = tostring(r),tostring(g),tostring(b) 
    dxSetShaderValue(Shaders[i],"r",r,g,b,1) 
    dxSetShaderValue(Shaders[i],"g",r,g,b,1) 
    dxSetShaderValue(Shaders[i],"b",r,g,b,1) 
    dxSetShaderValue(Shaders[i],"a",r,g,b,1) 
    end 
      
    function test() 
    local x,y,z = getElementPosition(localPlayer) 
    local x,y,z = x,y+5,z-1 
        for i=1, #Colors do 
            local obj = createObject(1697,x + dX*(i-1),y,z,32,0,0) 
            engineApplyShaderToWorldTexture ( Shaders[i], "solar_panel_1", obj ) 
        end 
    end 
    addEventHandler('onClientResourceStart',resourceRoot,function() 
    test() 
    end) 
      
    

    Shader:

      
    // 
    // tex_names.fx 
    // 
      
    float Time : TIME; 
    float4 r; 
    float4 g; 
    float4 b; 
    float4 a; 
      
      
    //----------------------------------------------------------------------------- 
    // Techniques 
    //----------------------------------------------------------------------------- 
    technique tec0 
    { 
        pass P0 
        { 
            MaterialAmbient = r; 
            MaterialDiffuse = g; 
            MaterialEmissive = b; 
            MaterialSpecular = a; 
             
            AmbientMaterialSource = Material; 
            DiffuseMaterialSource = Material; 
            EmissiveMaterialSource = Material; 
            SpecularMaterialSource = Material; 
      
            ColorOp[0] = SELECTARG1; 
            ColorArg1[0] = Diffuse; 
      
            AlphaOp[0] = SELECTARG1; 
            AlphaArg1[0] = Diffuse; 
      
            Lighting = true; 
        } 
    } 
      
    

    Result: (Even there's a cyan shader, but there is no cyan color made? wtf?

    http://imgur.com/sR3JyEx.png

    sR3JyEx.jpg

  8. Well ive struggled with text quality for a while now and ive found something weird: Shaders increase text quality.

    Now, what i want to know is how big the performance impact is. And for those wondering, do a simple try, draw a text into a render target and then place the render target as a texture of the simple shader example. Then proceed to draw both the render and the shader, and the shader will have better quality. (In fact increasing the shader sub pixel increases the quality even a bit more, tho is barely noticeable).

    So anyone has an idea of how bad the performance impact is of doing this?

  9. Another solution could be pre-creating textures and then drawing them. It would cause a short lag when the resource starts, but at least drawing should be completely smooth as it's already in GPU memory.

    Good idea, i'll try that!

  10. Okay, so i got this working, but for some reason i get very big FPS drops on the first 1-4 loops (starting over), and this affects me becouse i just wanna draw one loop of out if, any idea on this?

    PD: Just checked, this thingie makes the GTA process go from 800mb to 1800mb RAM usage :shock:

  11. I am not talking about, how you've called it, patters images or a shader file.

    I am talking about vehicle model files (I'll remind you which extensions does they have: txd, dff, col) I made long time ago in 3DS Max only for EPG.

    And i'm telling you i'm not using them.

  12. You have absolutely no rights to use any of my vehicle model files I made for European Pro Gamers.

    I'm not, i looked at them and asked a friend to make something similar, EPG's files are meant to use patters wich i do not want to. But, yeah becouse someone is using a similar shader name tag they're using your files, right?

  13. So i tried, and apparently the shader @hite affects this, but i think this is rather a bug, becouse @hite is not the specified shader, i mean, before i managed to make it work using the 'map' texture, but not it does not work anymore and i dont know why.

    Probably the vehicle dff and txd corrupted?

  14. Well, the custom texture i'm wanting to replace is visible when i use the function to get the model textures, however, when i use the engineApplyshaderToWorldTexture the texture is not replaced. Even more funny, if i use the "?*" to apply shaders, the texture i want to replace is replaced..

    I tried going to the middle of nowhere with the vehicle (freeze + setelementposition) and these were the "visible" texture names:

      
      
    @hite 
    bfori 
    cloudhigh 
    cloudmasked 
    collisionsmoke 
    coronastar 
    custom_car_plate 
    fist 
    font1 
    font2 
    plateback3 
    radar_centre 
    radar_north 
    radardisc 
    seabd32 
    shad_car 
    unnamed 
    vehicledash32 
    vehiclegeneric256 
    vehiclelights128 
    vehiclesteering128 
    vehicletyres128 
    waterclear256 
    

  15. Actually, the other thing is also a proper theme - click on the caret-down icon, and '> Edit HTML and CSS' should be in the dropdown.

    Oh yeah, just noticed that :lol: anyways, now i've no idea how to get my database info into this place here, how could i do so? Tried using the

  16. You're clearly showing two themes on the screenshot - ‘Default’ and ‘Elite Masters Players - Christmas.’ Try editing Elite Masters Players theme since it's set as the default one (i.e. the main theme, used when no other theme is set by the end-user)

    Thats why im saying its a only one theme, the christmas one is just a palette wich changes forums colors and doesnt have any possibility to edit code itself.

  17. I tried to add

    <li class='ipsResponsive_hidePhone ipsType_break'> 
      Server Monitor 2.0 
    </li> 
    

    But after clicking on save and reloading a topic page, there isnt any change visible, do i need to reload from somewhere else to see changes?

×
×
  • Create New...