Jump to content

Buffalo

Members
  • Posts

    283
  • Joined

  • Last visited

Posts posted by Buffalo

  1. One of my players reported strange bug that happens for them in all the servers.
    The mouse keeps going down when ever starting to aim the weapon.
    Happens only in MTA application.
     

    There's no additional mices or controllers connected.

    Any ideas?

  2. So when you are not using render targets you are drawing to the screen.

    Using a render target is like drawing on canvas, which then can be drawn on screen like any image.

    Steps:

    -create a render target

    -set render target to draw on

    -draw with standart dx functions

    -reset render target to screen

    -draw your target on screen

    Example from wiki:

    addEventHandler("onClientResourceStart", resourceRoot, 
        function() 
            myRenderTarget = dxCreateRenderTarget( 80, 100 )            -- Create a render target texture which is 80 x 100 pixels 
        end 
    ) 
      
    addEventHandler( "onClientRender", root, 
        function() 
            if myRenderTarget then 
                dxSetRenderTarget( myRenderTarget )                     -- Start drawing on myRenderTarget 
                dxDrawText ( "Hello", 10, 20 )                          -- Draw a message 
                dxSetRenderTarget()                                     -- Stop drawing on myRenderTarget 
      
                dxDrawImage( 50,  50,  100, 100, myRenderTarget )       -- Now use myRenderTarget as a material and draw it lots of times 
                dxDrawImage( 150, 350, 150, 100, myRenderTarget ) 
                dxDrawImage( 250, 250, 100, 150, myRenderTarget ) 
                dxDrawImage( 350, 30,  150, 150, myRenderTarget ) 
            end 
        end 
    ) 
    

    Render targets are great for optimizing

    Standart scoreboard resource calls hundreds dx functions per frame decreasing fps

    But with render targets you can draw many times only once per second on the target and render that target with only one dx function saving fps

    Also you can capture screen and draw it later on, see resource speedcams.

  3. You should check out hedit resource.

    Getting specified field in table is table["field"]

    So in this case

    getVehicleHanding(theVehicle)['maxVelocity'] 
      
    

    See wiki getVehicleHandling for all the field.

  4. Hello,

    Did anyone try get user account name who authenticated on web? Theres an example on wiki, but all I get is "undefined" instead of name. Is this even possible?

    <* local accName = getAccountName(user) 
         if not accName then return end 
         httpSetResponseCookie("userName",accName) *> 
    <!DOCTYPE html> 
    <html> 
         <body onLoad="getAcc();"> 
              Your Account Name is: <span id="accnam"></span> 
         <script> 
              //getCookie function from w3schools.com 
              function getCookie(c_name){ 
                   var i,x,y,ARRcookies=document.cookie.split(";"); 
                   for (i=0;i<ARRcookies.length;i++){ 
                        x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); 
                        y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); 
                        x=x.replace(/^\s+|\s+$/g,""); 
                        if (x==c_name) 
                             return unescape(y); 
                   } 
              } 
      
              function getAcc(){ 
                   var acc = document.getElementById("accnam"); 
                   var name = getCookie("userName"); 
                   if(!name || name!="") 
                        acc.innerHTML = name; 
                   else 
                        acc.innerHTML = "Could not get your account name!"; 
              } 
         </script> 
         </body> 
    </html> 
    

    Solved!

    <* httpWrite( "<script> var userName = '"..getAccountName(user).."';</script>" ) *> 
    

  5. Same here! After changing my HDD im now using windows 8 the only difference from windows 7.

    Game runs at 60fps (server fixed fps), everyone is faster than me. Even my char is slow.

    It's the feeling like my handling.cfg would use slow settings. Like I would be playing with 25fps or so.

    Same processor brand, little faster clocked at 3.5.

  6. createWeapon is client side, you must create turret for every client by syncing position using serverside triggering. Store positions in serverside array. Update newly joined clients where turrets are placed and their state.

    Sync turret state among all clients using triggering. You also can sync without triggering but detecting clientside colshape hits when other players enetrs them. Tho target changing might be less tricky doing serverside syncing what turret is targeting.

    You can not send client side elements to server! Instead send what is current turret target.

  7. Use your 1 pixel image and draw it on whole screen

    Example:

      
    local screenX,screenW = guiGetScreenSize() 
    addEventHandler('onClientRender',getRootElement(),function() 
         dxDrawImage( 0,0,screenX,screenW,"my1pximage.png") 
    end) 
    

  8.   
    local player = getLocalPlayer() 
    local counter = 0 
    local starttick 
    local currenttick 
    addEventHandler("onClientRender",root, 
        function() 
            if not starttick then 
                starttick = getTickCount() 
            end 
            counter = counter + 1 
            currenttick = getTickCount() 
            if currenttick - starttick >= 1000 then 
                setElementData(player,"FPS",counter) 
                counter = 0 
                starttick = false 
            end 
        end 
    ) 
    

  9. Root not necessarily means it will happen for all players. Read event wiki to understand whats source element of the event.

    addEventHandler("onClientClick",root,explosion) 
    

    In this case this will be added for the one you trigger "ilovetoburn" event for.

  10. wrong parameters for onPlayerClick

    function onClientPlayerWeaponFireFunc(player) 
    showCursor(player,true,false) 
    addEventHandler("onPlayerClick",player,explosion) 
    end 
    addCommandHandler("ilovetoburn",onClientPlayerWeaponFireFunc) 
      
    function explosion (button,state,element,x,y,z) 
             if (button == "left" and state == "down") then 
                   createExplosion (x,y,z,1) 
                   showCursor(source,false,false) 
            end 
        end 
    

  11. Why would you want that?

    Create an invisible edit box ( guiSetAlpha ) at 0X,0y,50x,50y and make it visible if its clicked with event onClientGUIClicked.

  12. Actually you can do this trick, depending on the purpose you need, it might work (if you only need to detect alphabedic characters):

    addEventHandler('onClientCharacter',getRootElement(),function(key)  
         if string.byte(key) > 40 and string.byte(key) < 91  then -- pressed an alphabedical symbol with CAPS LOCK ON! 
              --do something when character with caps lock on entered 
         elseif if string.byte(key) > 96 and string.byte(key) < 123  then -- pressed a symbol with CAPS LOCK OFF! 
              --do something when character with caps lock off entered 
         end 
    end) 
    

  13. local sound 
    setTimer(function() 
        local vehicle = getPedOccupiedVehicle(localPlayer) 
        if vehicle and getElementModel(vehicle) ~= 476 then 
            local vx,vy,vz = getElementVelocity(vehicle) 
            if vx+vy+vz == 0 then 
                if sound then 
                      setSoundPaused(sound,true) 
                end 
            else 
                if not sound then 
                    sound = playSound("sounds/sound.mp3") 
                    setSoundVolume(sound, 0.1) 
                else 
                    setSoundPaused(sound,false) 
                end 
            end 
        elseif sound then 
            setSoundPaused(sound,true) 
        end 
    end,1000,0) 
      
    --anonymous function attached to you 
    addEventHandler("onClientPlayerWasted", localPlayer, function() 
        if isElement(sound) then 
            setSoundPaused(sound, true) 
        end 
    end) 
    

  14. Wow man, simple rules:

    -Try never use events and functions with same name

    -Use global constants carefully

    This should work for you:

    function vehicleExplodeRented() 
        if getElementData(source,'rented') then 
            destroyElement(source) 
        end 
    end 
    addEventHandler("onVehicleExplode", getRootElement(), vehicleExplodeRented) 
      
    local Cash = 500000 
    function rentVehicle  () 
        if ( getPlayerMoney ( source ) <  Cash ) then 
            outputChatBox("You need 300,000$ to rent this vehicle.", source, 255,0,0) 
        else 
            takePlayerMoney(source, Cash) 
            if (getElementZoneName(source) == "Los Santos International") then 
                local Vehicle = createVehicle(425, 1924.5841064453, -2291.1552734375, 13.5) 
                warpPedIntoVehicle(source, Vehicle) 
                setElementData(Vehicle,'rented',true,false) 
            else 
                local Vehicle = createVehicle (425,1485.49, 1231.93, 10.82,0,0,180) 
                warpPedIntoVehicle(source, Vehicle) 
                setElementData(Vehicle,'rented',true,false) 
            end 
        end 
    end 
    addEvent ("rentV", true) 
    addEventHandler ("rentV", root, rentVehicle) 
    

×
×
  • Create New...