CLEO Help Opcode 0C65 caching problem (download_url to file)

CLEO related
Status
Not open for further replies.

Dalrae

Member
Joined
Sep 25, 2017
Messages
7
Reaction score
0
Hi, I've been encountering a very odd problem.
I'm downloading a file from my server which changes every few seconds, but the problem is that the cleo script retrieves the same file every time, even though the file is different.
The url is the same though.

Is there any way to clear the cache for this opcode? I've searched and searched but can't find any solutions.
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
Check this out:
http://www.cplusplus.com/forum/windows/107840/#msg585474

Especially this part:
C++:
    // invalidate cache, so file is always downloaded from web site
    // (if not called, the file will be retieved from the cache if
    // it's already been downloaded.)
    DeleteUrlCacheEntry(url);

But there's no opcode to call that function I think, you'd have to do something like this to call it:
http://ugbase.eu/index.php?threads/tutorial-using-functions-from-windows-libraries.16774/

Edit:
There are some examples online, like this one:
https://blast.hk/threads/13410/page-1127

Idk why but I tested these and it doesn't work for me. It keeps writing the cached file instead of downloading new one, unless I reopen Gta (despite using "DeleteUrlCacheEntryA" function).


Edit2:
On stackoverflow someone suggested adding some random parameter as a workaround. That's not great solution but may work, here's example I tested and got working:

Code:
{$CLEO}
0000:

while true
wait 0
   if 0ADC:   test_cheat "x"
   then
      0AB1: call_scm_func @HTTP_GET 0
   end
end

:HTTP_GET
0AC8: 31@ = allocate_memory_size 260   
0209: 26@ = random_int_in_ranges -2147483646 2147483646
0AD3: 31@ = format "https:%c/website.com?cacheBuster=%d" 47 26@

/* It didn't work (tested on Windows 10)
if 0AA2: 30@ = load_library "wininet.dll" // IF and SET
then
    if 0AA4: 29@ = get_proc_address "DeleteUrlCacheEntryA" library 30@ // IF and SET
    then
        0AA7: call_function 29@ num_params 1 pop 0 szUrl 31@ _returned 27@
        0AD1: show_formatted_text_highpriority "DeleteUrlCacheEntryA ret = %d" time 10000 27@
        wait 5000
    end
0AA3: free_library 30@
end */

if 0AA2: 30@ = load_library "urlmon.dll" // IF and SET
then 
    if 0AA4: 29@ = get_proc_address "URLDownloadToFileA" library 30@ // IF and SET
    then   
        0AA7: call_function 29@ num_params 5 pop 0 lpfnCB 0 dwReserved 0 szFileName "cleo/response.txt" szUrl 31@ caller 0 _returned 28@
        0AD1: show_formatted_text_highpriority "LSGC response = %d" time 10000 28@
    end
0AA3: free_library 30@
end
0AC9: free_allocated_memory 31@
0AB2: ret 0



Edit2:
This is better solution I think:
http://ugbase.eu/index.php?threads/http-requests-without-sampfuncs.21152/
 
Last edited:
Status
Not open for further replies.
Top