Jump to content

xXGhostXx

Members
  • Posts

    257
  • Joined

  • Last visited

Posts posted by xXGhostXx

  1. 1 minute ago, nikitafloy said:

    Use regulars:

    
    string.match

    For example

    No i want when use this function player name field if several similar names are found, they should be in the table.

  2. Hello, i want find player with similar names and print names in a list !

    My find player function :

    function findPlayer( partofname )
        local player = getPlayerFromName ( tostring(partofname) )
        if player then
            return player
        end
    	for _, player in pairs( getElementsByType 'player' ) do
    		if tonumber(getElementData(player,"id")) == tonumber(partofname) then
    			if getElementData(player, "loggedIn") == true then
    				return player
                end
            end
        end
    		
    	for _, player in pairs( getElementsByType 'player' ) do
    		if string.find ( string.gsub ( getPlayerName ( player ):lower( ), "#%x%x%x%x%x%x", "" ), partofname:lower( ), 1, true ) then
    			if getElementData(player, "loggedIn") == true then
    				return player
    			end
    		end
        end
    end

    Do you have an idea or opinion ?

  3. Hi guys.

    What's problem in my code ?

    local Weapons = {
    	{ 22, 24, 25, 26, 27, 28, 29, 30, 31, 34 },
    }
    
    function getWeaponSlotFromID (Weapon)
    	local slot = 0
    	for i=1,10 do
    		if Weapons[1][i] == Weapon then
    			slot = i
    		end
    	end
    	return slot
    end

    I want to give a weapon id and get the slot in the table .

  4. 4 minutes ago, Ceeser said:

    Please expain a bit more:

    Are you using a db?
    Are you using accountData?
    Are you using elementData?
    Do you wanna use something else?

    Does not count, because i want know.

    for example i use elementData.

    Please answer me.

  5. 10 hours ago, edge said:

    This works just when the files are being downloaded. Try to remove all your cached-files and enter your server. If that doesn't works, we'll check that. I don't think it didn't works, but I'll test it soon.

    I want on player join in my server when data loading play this html page

  6. 1 hour ago, edge said:

    That's quite simple.

    
    local screen = {guiGetScreenSize()}
    local page = "http://mta/local/yourfile.html"
    
    function downloadGUI()
    	browser = guiCreateBrowser(0,0,screen[1],screen[2],true,true,false) --display the Browser
    	bg = guiGetBrowser(browser)
    	addEventHandler("onClientBrowserCreated", bg, function()
    		loadBrowserURL(source, page)		
    	end)
    end
    addEventHandler("onClientRender", root, downloadGUI)
    
    function checkTransfer()    
        if isTransferBoxActive() == true then
            setTimer(checkTransfer,2000,1) -- Check again after 2 seconds
        else 
            removeEventHandler("onClientRender", root, downloadGUI)
        end
    end
    addEventHandler("onClientResourceStart",resourceRoot,checkTransfer)
    

    Also you need to update your download_priority_group field in meta.xml.

    Don't work.

    Meta:

    <meta>
    	<script src="Loading.Lua" type="client" />
    	
    	<file src="index.html" />
    	
    	<download_priority_group>1</download_priority_group>
    </meta>

    Client:

    local screen = {guiGetScreenSize()}
    local page = "http://mta/local/index.html"
    
    function downloadGUI()
    	browser = guiCreateBrowser(0,0,screen[1],screen[2],true,true,false) --display the Browser
    	bg = guiGetBrowser(browser)
    	addEventHandler("onClientBrowserCreated", bg, function()
    		loadBrowserURL(source, page)		
    	end)
    end
    addEventHandler("onClientRender", root, downloadGUI)
    
    function checkTransfer()    
        if isTransferBoxActive() == true then
            setTimer(checkTransfer,2000,1) -- Check again after 2 seconds
        else 
            removeEventHandler("onClientRender", root, downloadGUI)
        end
    end
    addEventHandler("onClientResourceStart",resourceRoot,checkTransfer)

     

  7. Hi guys.

    I try to use string.find with table.

    characters = {
    	["a"] = true, ["b"] = true, ["c"] = true,
    }
    
    function test (username)
    	if string.find(username, characters[username]) then
        else
        	outputChatBox("This is invalid character!",source)
        end
    end

    What is my problem ?

  8. Hi guys.

    Do you have a idea for make Heist system for bank robbery or ...

    like: Player can make party with /party command and /invite 3 players for make robbery group.

    Heist system have 4 number slots with party leader.

    After /invite a player name triggered to gui and set the text.

    After it's done bank robbery for party members and leaders set wanted to 6.

    Please give me a idea and function and method.

    Thanks all. 

  9. 17 hours ago, majqq said:

    Create other table for it, you have an example how you can do it.

    Besides this should look like this:

    
    addCommandHandler("rv", 
    	function(player, cmd)
    		local faction = getElementData(player, "faction")
    		local vehicles = getElementsByType("vehicle")
    		for i = 1, #vehicles do
    			local vehicle = vehicles[i]
    			if vehicle then
    				local vehid = getElementID(vehicle)
    				if facVehsTable[vehid][faction] then
    					respawnVehicle(vehicle)
    				end
    			end
    		end
    	end
    end)
    

     

    Thanks you can give me table for this code ?

  10. 42 minutes ago, majqq said:

    Uncomment this:

    
    --local faction = getElementData(player, "faction") - why do you need this? i commented this because it's never used
    

     

    So it will look like:

    
    local faction = getElementData(player, "faction")
    

    And move it under or above:

    
    local vehicles = getElementsByType("vehicle")
    

    To not necessarily call function x times in loop.

    After that you need to index:

    
    [faction]
    

    On line 10:

    
    if facVehsTable[vehid] then
    

    This will use data from facVehsTable.

    Goodluck.

    Yes i fixed but i want police faction respawn police cars.

    FBI faction respawn fbi cars.

    or ...

    addCommandHandler("rv",
    function (player, command)
    			local vehicles = getElementsByType("vehicle")
    			for i = 1, #vehicles do
    				local vehicle = vehicles[i]
    				if vehicle then
    					local vehid = getElementID(vehicle)
    					local faction = getElementData(player, "faction")
    					if facVehsTable[vehid] and facVehsTable[vehid][faction] then
    							respawnVehicle(vehicle)
    					end
    				end
    			end
    end)

    In this code i want get my faction and find in the table my faction id and get the car and respawn car geted!

  11. 15 hours ago, majqq said:

    Use outputDebugString to check if code actually runs.

    Add it before condition, and inside condition.

    Maybe you didn't set spawn coordinates - not sure.

    https://wiki.multitheftauto.com/wiki/SetVehicleRespawnPosition

    Also use int loop not ipairs, ipairs isn't that effective.

    
    addCommandHandler("rv", 
    	function(player, cmd)
    		local vehicles = getElementsByType("vehicle")
    		for i = 1, #vehicles do
    			local vehicle = vehicles[i]
    			if vehicle then
    				local vehid = getElementID(vehicle)
    				--local faction = getElementData(player, "faction") - why do you need this? i commented this because it's never used
    				if facVehsTable[vehid] then
    					respawnVehicle(vehicle)
    				end
    			end
    		end
    	end
    end)
    

     

    Dear i want if you are police faction you can respawn police cars or if you are medic faction respawn medic cars with /rv command !

    And "local faction = getElementData(player, "faction")" for get my faction for respawn my faction cars

  12. On 09/10/2019 at 22:36, majqq said:

    Try:

    I've also fixed my mistake with elementData.

    
    local facVehsTable = {
    	["Police"] = {
    		[1] = true, -- faction: 1, can enter
    		[3] = true, -- faction: 3, can enter
    		[4] = false, -- faction: 4, can't enter
    	},
    	["Medic"] = {
    		[2] = true, -- faction: 2, can enter
    	},
    }
    
    --
    
    function onVehicleStartEnter(player, seat, jacked, door)
    	if seat == 0 then
    		local vehid = getElementID(source)
    		local faction = getElementData(player, "faction") -- mistake, fixed it
    		if facVehsTable[vehid] then -- if vehid is equal to Police or Medic
    			if not faction or not facVehsTable[vehid][faction] then -- if server can't get faction, or player faction isn't equal to one of in table
    				cancelEvent()
    				outputChatBox("#ff0000This is faction vehicle!", player, 230, 0, 0, true)
    			end
    		end
    	end
    end
    addEventHandler("onVehicleStartEnter", getRootElement(), onVehicleStartEnter)
    

     

    Thanks for your help.

    I have a problem.

    I trying to make respawn faction vehicles.

    For example: i am police officer and i want respawn my faction cars or i am medic and i want respawn my faction cars.

    addCommandHandler("rv",
    function(thePlayer, command)
    	for index, Fac_Cars in ipairs(getElementsByType("vehicle")) do 
    		local vehid = getElementID(Fac_Cars)
    		local faction = getElementData(thePlayer, "faction")
    		if facVehsTable[vehid] then
    			respawnVehicle(Fac_Cars)
    		end
    	end
    end)

    What is problem ?

×
×
  • Create New...