Jump to content

When i compile script it doesnt work


xTravax

Recommended Posts

Delete =  
    { 
    "client.lua",    
    } 
     
    for k,v in ipairs ( Delete ) do 
        fileDelete(v) 
    end 
     
        local create = fileCreate("drift.lua") 
            if (create) then  
                fileWrite(create, "This is a test file!") 
                fileClose(create) 
            end 
  
  

not tested but should work .

Link to comment

Part of that code makes totally no sense and I already said million times that the deleting files way has a workaround.

My way - Server side:

function loadFile( player, szFile, nID ) 
    if ( szFile ) then 
        local pFile = fileOpen( szFile, true );  
        if ( pFile ) then 
            while not fileIsEOF( pFile ) do 
                triggerClientEvent( player, "download:sendContent", player, fileRead( pFile, 65000 ), nID ); 
            end 
            triggerClientEvent( player, "download:loadContent", player, nID ); 
        end 
    end 
    return false; 
end 

Client-side:

addEvent( "download:sendContent", true ); 
addEvent( "download:loadContent", true ); 
local content = {}; 
  
addEventHandler( "download:sendContent", root, 
    function( buffer, id ) 
        if ( not content[id] ) then 
            content[id] = ""; 
        end 
  
        content[id] = content[id] + buffer; 
    end 
) 
  
addEventHandler( "download:loadContent", root, 
    function( id ) 
        loadstring( content[id] )(); 
        content[id] = nil; 
    end 
) 

Example of use:

loadFile( playerElement, "myClientFile.lua", "AWESOME_CAR_MODS" ); -- server side 

P.S. The code wasn't tested ( but the way works for sure ) and there's an easier & better way to do this but this was just a simple and fast way of explaining you.

Edited by Guest
Link to comment
Part of that code makes totally no sense and I already said million times that the deleting files way has a workaround.

My way - Server side:

function loadFile( player, szFile, id ) 
    if ( szFile ) then 
        local pFile = fileOpen( szFile, true );  
        if ( pFile ) then 
            while not fileIsEOL( pFile ) do 
                triggerClientEvent( player, "download:sendContent", player, fileRead( pFile, 65000 ), id ); 
            end 
            triggerClientEvent( player, "download:loadContent", player, id ); 
        end 
    end 
    return false; 
end 

Client-side:

addEvent( "download:sendContent", true ); 
addEvent( "download:loadContent", true ); 
local content = {}; 
  
addEventHandler( "download:sendContent", root, 
    function( buffer, id ) 
        if ( not content[id] ) then 
            content[id] = ""; 
        end 
  
        content[id] = content[id] + buffer; 
    end 
) 
  
addEventHandler( "download:loadContent", root, 
    function( id ) 
        loadstring( content[id] )(); 
    end 
) 

Example of use:

loadFile( playerElement, "myClientFile.lua", "AWESOME_CAR_MODS" ); -- server side 

P.S. The code wasn't tested ( but the way works for sure ) and there's an easier & better way to do this but this was just a simple and fast way of explaining you.

What is this? :shock::?

Link to comment
This is my way of loading client files without actually downloading them, it's not hard to understand the code.

That code may also be able to be used for loading DFF/TXD models without downloading them, with some changes.

yeah good idea my script up ^ when you still download resource,s the resource will be download into mta files / :(

Link to comment
This is my way of loading client files without actually downloading them, it's not hard to understand the code.

That code may also be able to be used for loading DFF/TXD models without downloading them, with some changes.

So i use your code on 1 script to make all things what people download in my server not seenable,deleted

so i make folder and name it filedeleter and add client.lua and server.lua of your protection scripts anderl and make meta for it and it will protect all scripts what people download from my server or i have to add this 2 scripts to every script i want to protect?

Link to comment
You don't need to delete any file.

You just need to use my code and call the function "loadFile" with player element, the file path as a string ( well, there would not be any other way to pass it ) and an ID of the download.

Man i ask when i want to protect some scripts if i want to protect them all do i need to put that your script in only 1 script to make protection for others too or i need to add your script to all scripts folders what i want to protect?

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...