Jump to content

Strike27208

Members
  • Posts

    85
  • Joined

  • Last visited

Posts posted by Strike27208

  1. 2 minutes ago, LoPollo said:

    You make the function end if there's any player at seat 1-2-3, but i guess that's not what you want

    You are checking if the drivers exists. That's also not what you are looking for. You want to know if the driver is the localPlayer

    
    if localPlayer.vehicleSeat == 0 then
    

     

    attempt to index a global "localPlayer" a userdata value , hmmmm ? 

  2. 21 minutes ago, LoPollo said:

    to check if localPlayer is the driver use getPedOccupiedVehicleSeat. If it does return 0, then localPlayer is the driver

    I used this and didn't work : 

    local driver = getVehicleOccupant(veh, 0)
    local p1 = getVehicleOccupant(veh, 1)
    local p2 = getVehicleOccupant(veh, 2)
    local p3 = getVehicleOccupant(veh, 3) 
    if fuel <=5 then
    if p1 or p2 or p3 then return false end
    if driver then 
    	sound = playSound("sound/beep.mp3" , true)	
    	setSoundVolume(sound, 0.1)
    	setSoundSpeed ( sound, 0.9 )
        outputChatBox ( "#FF0000Alarm ! #FFFFFFLow fuel ! Press ' Z ' to stop the alarm.", 255, 255, 255, true )
    	bindKey ( "Z", "down", stopMySoundB )
    	addEventHandler ( "onClientVehicleExit", root, stopMySoundV ) 
    	killTimer(aMyTimer)
    	end
    	end
    	end

     

  3. Hey , how i can to play sound for driver only ? this is my code , i tried to make but i failed and i need some help : 

    function helicopter ()
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end
    local vehicle = getPedOccupiedVehicle(getLocalPlayer())
    if vehicle then 
        if ( policeVehicles[getElementModel ( vehicle )] ) then 
        local maxfuel = tonumber(getElementData(vehicle, "maxfuel")) or 0;
        local fuels = math.floor(tonumber(getElementData(getElementData(vehicle, "parent"), "fuel"))) or 0;
            if fuels <=5 then
        sound = playSound("sound/beep.mp3" , true)	
    	setSoundVolume(sound, 0.1)
    	setSoundSpeed ( sound, 0.9 )
        outputChatBox ( "#FF0000Alarm ! #FFFFFFLow fuel ! Press ' Z ' to stop the alarm.", 255, 255, 255, true )
    	bindKey ( "Z", "down", stopMySoundB )
    	addEventHandler ( "onClientVehicleExit", root, stopMySoundV ) 
    	killTimer(aMyTimer) 
    end
    end
    end
    end
    aMyTimer = setTimer( helicopter, 5000,0)

     

  4. Hey , i come back here because i find a new bug :)) , if i'm with other player in vehicle the alarm won't start , this is my code : 

    local driver = getVehicleOccupant(veh, 0)
    local p1 = getVehicleOccupant(veh, 1)
    local p2 = getVehicleOccupant(veh, 2)
    local p3 = getVehicleOccupant(veh, 3) 
    if fuel <=5 then
    if p1 or p2 or p3 then return false end
    if driver then 
    	sound = playSound("sound/beep.mp3" , true)	
    	setSoundVolume(sound, 0.1)
    	setSoundSpeed ( sound, 0.9 )
        outputChatBox ( "#FF0000Alarm ! #FFFFFFLow fuel ! Press ' Z ' to stop the alarm.", 255, 255, 255, true )
    	bindKey ( "Z", "down", stopMySoundB )
    	addEventHandler ( "onClientVehicleExit", root, stopMySoundV ) 
    	killTimer(aMyTimer)
    	end
    	end
    	end

     

  5. I use to activate my function 

    if driver then 
        sound = playSound("sound/beep.mp3" , true)    
        setSoundVolume(sound, 0.2)
        outputChatBox ( "#FF0000Alarm ! #FFFFFFLow fuel ! Press ' Z ' to stop the alarm.", 255, 255, 255, true )
        bindKey ( "Z", "down", stopMySoundB )
        addEventHandler ( "onClientVehicleExit", root, stopMySoundV ) 
        killTimer(aMyTimer)
        end

     

  6. Nope , i don't use local , still not working , but thanks for help man , i appreciate. No warrnings or erros in debugscript.

    I used this to play sound only for driver seat and it's working , when i tried to use for that function he give that warrning , can you tell me why ? 

    local driver = getVehicleOccupant(veh, 0)
    local p1 = getVehicleOccupant(veh, 1)
    local p2 = getVehicleOccupant(veh, 2)
    local p3 = getVehicleOccupant(veh, 3)
    if fuel1 <= 6 then 
    if p1 or p2 or p3 then return false end
    if driver then 
    	sound = playSound("sound/beep.mp3" , true)	
    	setSoundVolume(sound, 0.2)

     

  7. Hmm i tried but still not work 

    function stopMySoundV()
    local veh = getPedOccupiedVehicle(getLocalPlayer())
    if veh then
    local driver = getVehicleController(veh , getLocalPlayer()) 
    if driver then 
    local drivers = getVehicleOccupant(veh, 0)
    local p1 = getVehicleOccupant(veh, 1)
    local p2 = getVehicleOccupant(veh, 2)
    local p3 = getVehicleOccupant(veh, 3) 
    if p1 or p2 or p3 then return false end
    if drivers then 
    stopSound (sound)
    unbindKey ( "Z", "down", stopMySoundB )
    removeEventHandler( "onClientVehicleExit", root, stopMySoundV )
    if not isTimer (  aMyTimer ) then
        aMyTimer = setTimer( helicopter, 5000,0)
    end
    end
    end
    end
    end

    Tell  me if i am wrong. 

  8. Thanks man it's work , now i made a sistem like only driver to hear the sound , this work but when i want  exit from vehicle the sound are not stopping and i get an warnging in debugscript like this : 

    Ue50AFg.png 

    My code : 

    function stopMySoundV()
    local veh = getPedOccupiedVehicle(getLocalPlayer())
    local driver = getVehicleOccupant(veh, 0)
    local p1 = getVehicleOccupant(veh, 1)
    local p2 = getVehicleOccupant(veh, 2)
    local p3 = getVehicleOccupant(veh, 3) 
    if p1 or p2 or p3 then return false end
    if driver then 
    stopSound (sound)
    unbindKey ( "Z", "down", stopMySoundB )
    removeEventHandler( "onClientVehicleExit", root, stopMySoundV )
    if not isTimer (  Check  ) then
        Check = setTimer( helicopter, 5000,0)
    end
    end
    end

     

  9. Hey i make this script when you have low fuel to start a sound alarm but i don't know how to make to check this when you are in helicopter : 

    function helicopter () 
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end
    	---------------------------Parts-----------------------
    	local veh = getPedOccupiedVehicle(getLocalPlayer());
    	local maxfuel = ---myStuff--;
    	local fuel = ---myStuff----------;
    	if (isElement(veh) and getElementModel(veh) == 487 or 497 or 417 or 563 ) then 
    	if fuel <= 5 then 
        sound = playSound("sound/beep.mp3" , true)	
    	setSoundVolume(sound, 0.2)
        outputChatBox ( "#FF0000Alarm ! #FFFFFFLow fuel ! Press ' Z ' to stop the alarm.", 255, 255, 255, true )
    	bindKey ( "Z", "down", stopMySoundV )
    	addEventHandler ( "onClientVehicleExit", root, stopMySound )
    	killTimer(tm)
    	end
    	end
    	end
    tm = setTimer (helicopter , 5000 , 0)
    addEventHandler ( "onClientResourceStart", root, helicopter )	 
    
    function stopMySound()
    stopSound ( sound )
    unbindKey ( "Z", "down", stopMySoundV )
    end
    
    function stopMySoundV()
        stopSound ( sound )
    	removeEventHandler( "onClientVehicleExit", root, stopMySound )
    end

    This all work , but when he kill the timer i can't use ' resetTimer ' because he killed it , so how to make to reset that timer when he leave the vehicle ? this work first time , but when i enter again in vehicle he wont verify again. 

  10. Use this man :) 

    toggleControl ( thePlayer, "aim_weapon", false ) -- disable their fire key
    toggleControl ( thePlayer, "fire", false ) -- disable their fire key
    ---------------------------------------------------------------------
    toggleControl ( thePlayer, "aim_weapon", true ) -- enable their fire key
    toggleControl ( thePlayer, "fire", true ) -- enable their fire key

     

  11. On 11/7/2016 at 2:42 PM, Dealman said:

    Use triggerLatentClientEvent to transfer data(see fileOpen, fileRead, fileWrite, fileClose), since this is a latent event handler - it will not pause other traffic. Use getLatentEventStatus to get the progress, and then use dxDrawText and/or dxDrawRectangle as you please.

    You can probably find some already made on the community, but I sincerely doubt you'll learn much if you try and salvage those for code. Start simple, go from there.

    Thansk Man ! 

  12. How i can create a new download bar becasue the original one are not triggered if i use "downloadFile " . I have this code for convert size : i need some help , what i need to use to make a download bar.

    function sizeFormat(size)
    	local size = tostring(size)
    	if size:len() >= 4 then		
    		if size:len() >= 7 then
    			if size:len() >= 9 then
    				local returning = size:sub(1, size:len()-9)
    				if returning:len() <= 1 then
    					returning = returning.."."..size:sub(2, size:len()-7)
    				end
    				return returning.." GB";
    			else				
    				local returning = size:sub(1, size:len()-6)
    				if returning:len() <= 1 then
    					returning = returning.."."..size:sub(2, size:len()-4)
    				end
    				return returning.." MB";
    			end
    		else		
    			local returning = size:sub(1, size:len()-3)
    			if returning:len() <= 1 then
    				returning = returning.."."..size:sub(2, size:len()-1)
    			end
    			return returning.." KB";
    		end
    	else
    		return size.." B";
    	end
    end

     

  13. Thanks MIKI785 , now if i get nil from xml , that  mean he dont find that shortcut , i have this : 

     xmlNodeSetAttribute(settings, "car", "true") -- nil argunment 1 , argument 1 is "settings" . 

    He don't find xml , i tried to put 

    local currentFile = xmlLoadFile ("savedsettings.xml")

    No more warrnings but he don't change in savedsettings.xml nothing , all are false . , 

  14. It's start like this : 

    function createXML()
      local exists = fileExists ( "savedsettings.xml" )
    		if not exists then 
            settings = xmlCreateFile("savedsettings.xml","settings")
    	    if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then
                xmlNodeSetAttribute(settings, "car", "true")
    	    else
    	        xmlNodeSetAttribute(settings, "car", "false")
    	    end	
      end
    addEventHandler("onClientPlayerJoin", getRootElement(), createXML)
      
    ----Gui
      vehPanel.checkbox[1] = guiCreateCheckBox(0.03, 0.02, 0.05, 0.07, "", false, true, vehPanel.tab[1])
      vehPanel.button[1] = guiCreateButton(0.71, 0.80, 0.24, 0.15, "Save", true, vehPanel.tab[1])
      
      ---Here save my checkbox 
      addEventHandler ( "onClientGUIClick", getRootElement(),
    function()
    	if source == vehPanel.button[1] then
    	    xmlSaveFile(settings)
    		xmlUnloadFile(settings)
    		guiSetVisible( vehPanel.window[1], false )
    	end
    end
    )
     ----------Function 
      
      function veh1(file, success)
            local exists = fileExists ( "vehicles/car.txd" and "vehicles/car.dff"  )
    		if not exists then 
    		exports.notification:outputTopBar("[ERROR] You don't have this car .", 255, 0, 0)
    		guiCheckBoxSetSelected(vehPanel.checkbox[1],false)
    		currentTrack = playSound ( "error.wav" )
    end
    	if guiCheckBoxGetSelected( vehPanel.checkbox[1] ) == true then
    	    xmlNodeSetAttribute(settings, "car", "true")
    		local exists = fileExists ( "vehicles/car.txd" and "vehicles/car.dff" )
    		if exists then 
    		exports.notification:outputTopBar("Car mod enabled", 0, 255, 0)
    		local changeTXD = engineLoadTXD ("vehicles/car.txd")
    		local changeDFF = engineLoadDFF ("vehicles/car.dff")
    		engineImportTXD ( changeTXD, 568 )
    		engineReplaceModel (changeDFF, 568)
    		guiLabelSetColor ( vehPanel.label[1], 0, 255, 0 )
    end
    	else
    	    xmlNodeSetAttribute(settings, "car", "false")
    		local exists = fileExists ( "vehicles/bandito.txd" and "vehicles/bandito.dff" )
    		if exists then 
    		exports.notification:outputTopBar("Car mod disabled", 255, 0, 0)
    		engineRestoreModel ( 568 )
    		guiLabelSetColor ( vehPanel.label[1], 219, 219, 219 )
    end
    end
    end
    addEventHandler ( "onClientGUIClick", vehPanel.checkbox[1], veh1, false)
      
      ---------End
      function load()
        local currentFile = xmlLoadFile ("savedsettings.xml")
        if xmlNodeGetAttribute(currentFile, "car") == "true" then
    	    guiCheckBoxSetSelected(vehPanel.checkbox[1], true)
    	    veh1()
        end
      end
    load()
      
     

    This is it.

  15. 26 minutes ago, Dealman said:

    You might wanna save the file first. Use xmlSaveFile. Also, you're not properly closing an if statement in example 1 and 3.

    Thanks i used with this : 

    function createXML()
      local exists = fileExists ( "savedsettings.xml" )
    		if not exists then 
            settings = xmlCreateFile("savedsettings.xml","settings")
    	    if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then
                xmlNodeSetAttribute(settings, "car", "true")
    	    else
    	        xmlNodeSetAttribute(settings, "car", "false")
    	    end	
      end
    addEventHandler("onClientPlayerJoin", getRootElement(), createXML)

    And this work but i find i have a big problem with xml , if you know how to work with xml please help me  , 

    http://imgur.com/WVVhsb9

    Line :  

    if guiCheckBoxGetSelected( vehPanel.checkbox[1] ) == true then
    	    xmlNodeSetAttribute(settings, "bandito", "true")
           --------My Stuff 
    end

    Why i get that error ? this part is in another function , i don't know if matter or not . 

  16. Hey , this is my code , He don't create the XML file and i tried this   : ( Only Client )

    function createXML()
    if source == vehPanel.button[1] then
            settings = xmlCreateFile("savedsettings.xml","settings")
    	    if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then
                xmlNodeSetAttribute(settings, "car", "true")
    	    else
    	        xmlNodeSetAttribute(settings, "car", "false")
    	    end	
      end
    addEventHandler("onClientGUIClick", getRootElement(), createXML)

    And this  :

    function createXML()
            settings = xmlCreateFile("savedsettings.xml","settings")
    	    if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then
                xmlNodeSetAttribute(settings, "car", "true")
    	    else
    	        xmlNodeSetAttribute(settings, "car", "false")
    	    end	
      end
    addEventHandler("onClientResourceStart", getRootElement(), createXML)

    And this : 

    function createXML()
      local exists = fileExists ( "savedsettings.xml" )
    		if not exists then
            settings = xmlCreateFile("savedsettings.xml","settings")
    	    if guiCheckBoxGetSelected(vehPanel.checkbox[1]) then
                xmlNodeSetAttribute(settings, "car", "true")
    	    else
    	        xmlNodeSetAttribute(settings, "car", "false")
    	    end	
      end
    addEventHandler("onClientResourceStart", getRootElement(), createXML)

    And no one create xml  , i need some help please , this is the end code : 

    function load()
        local currentFile = xmlLoadFile ("savedsettings.xml")
        if xmlNodeGetAttribute(currentFile, "car") == "true" then
    	    guiCheckBoxSetSelected(vehPanel.checkbox[1], true)
    	    veh1()
        end
      end
    load()

     

  17. Posteaza partea in care dupa ce te-ai logat script-ul distruge gui/dx si te spawneaza. sau posteaza client-ul .

    Sau poti incerca asta , tine mine este parte de server. 

    function onPlayerSpawn ( theSpawnpoint, theTeam )
        playSoundFrontEnd ( source, 16 )
    end
    addEventHandler ( "onPlayerSpawn", root, onPlayerSpawn )

    In schimb in loc de 16 (16 este un sunet din gta:sa) poti pune sunetul dorit ex :

    playSoundFrontEnd ( source, "music.mp3" )
    

    Daca dupa ce s-a logat playerul nu se spawneaza si trebuie sa-si aleaga vreun skin sau altceva atunci te rog sa faci ce ti-am zis mai sus.

×
×
  • Create New...