[Include] Easy Textur - Online View
#9

Sending a request whilst the request queue is not empty might cause unexpected errors. (oIndex should be passed as a parameter to the callback)

Here's an example to understand better what I want to say:
Код:
request #1: SetTextur -> writes oIndex = 1
request #2: SetTextur -> writes oIndex = 2
answer #1: LoadTextur -> reads oIndex = 2
answer #2: LoadTextur -> reads oIndex = 2
You can't pass two integer parameters to the callback, but you can implement an additional data structure (a enum and you pass an address, an index offset or something) or maybe use some clever bit-wise operations (which I highly recommend):
Код:
((objectId & 0xFFFF) << 16) | (material_index & 0xFF)
P.S. You forgot a " at the end of the latest string.

--

Edit:
This is what I had in mind:
pawn Код:
stock SetTextur(objectid, index, id) {
    new url[64];
    format(url, sizeof(url), "textur.apl-rl.de/include.php?id=%d", id);
    HTTP(((objectId & 0xFFFF) << 16) | (index & 0xFF), HTTP_GET, url, "", #LoadTextur);
    return 1;
}

forward LoadTextur(index, response_code, data[]);
public LoadTextur(index, response_code, data[]) {
    if (response_code == 200) {
        new objectId = (index >> 16) & 0xFF, oIndex = index & 0xFF, modelid, TXD[20], textur[20], color;
        sscanf(data, "p<,>is[20]s[20]i", modelid, TXD, textur, color);
        SetObjectMaterial(objectId, oIndex, modelid, TXD, textur, color);
        printf("[debug] Arendium Textur Addon: %d %d %d %s %s %d", objectId, oIndex, modelid, TXD, textur, color);
    } else {
        print("[error] Arendium Textur Addon: Error please send a Private Message to Arendium for help!");    
    }
    return 1;
}
Reply


Messages In This Thread
Easy Textur - Online View - by Arendium - 05.05.2013, 09:20
Re: Easy Textur - Online View - by Niko_boy - 05.05.2013, 10:20
AW: Easy Textur - Online View - by Arendium - 05.05.2013, 16:09
AW: Easy Textur - Online View - by Arendium - 05.05.2013, 17:15
Re: Easy Textur - Online View - by Jochemd - 06.05.2013, 12:19
AW: Easy Textur - Online View - by Arendium - 06.05.2013, 16:41
Re: Easy Textur - Online View - by RajatPawar - 06.05.2013, 16:44
AW: Easy Textur - Online View - by Arendium - 06.05.2013, 16:54
Re: Easy Textur - Online View - by Dan.. - 06.05.2013, 17:56
Re: Easy Textur - Online View - by Pottus - 07.05.2013, 13:01
Re: Easy Textur - Online View - by jdey - 07.05.2013, 15:50
Re: Easy Textur - Online View - by Pottus - 07.05.2013, 16:46

Forum Jump:


Users browsing this thread: 1 Guest(s)