samp.directory
← Skrypty i biblioteki

Mergevos/samp-async-objects

Await task response of object edition.

Biblioteka★ 2zaktualizowano lis 2020MITPawnsampctl
Otwórz na GitHubie

Zainstaluj za pomocą sampctl

sampctl package install Mergevos/samp-async-objects

Uruchom to w folderze swojego projektu. sampctl pobiera pakiet i to, od czego zależy.

Wypróbuj w kompilatorze Pawn →

Dodaje jej pliki include, razem z bibliotekami, od których zależy, do kompilatora Pawn w twojej przeglądarce, gotowe do dołączenia w skrypcie.

Zależy od 2 pakietów

README.md

samp-async-objects

Installation

Simply install to your project:

sampctl package install Mergevos/samp-async-objects

Include in your code and begin using the library:

#include <async-objects>

Usage

Let's look at the following example:

YCMD:test(playerid, params[], help)
{ 
    if(help) {
        return 0;
    }
    SelectObject(playerid);

    return 1;
}

public OnPlayerSelectObject(playerid, type, objectid, modelid, Float:fX, Float:fY, Float:fZ)
{
    new obj_res[e_OBJECT_INFO];
    await_arr(obj_res) AsyncObject_Edit(playerid, objectid);
    print("Response awaited");
    if(obj_res[E_OBJECT_Response] == EDIT_RESPONSE_FINAL) {
        print("Response final, player clicked on save icon.");
    } else if(obj_res[E_OBJECT_Response] == EDIT_RESPONSE_CANCEL) {
        print("Canceled");
    }
    return 1;
}

The /test command executes the SelectObject function which allows you to select an object you would like to edit. When you select the object it calls OnPlayerSelectObject, GUI is going to show up and allows you to edit, move, rotate and save the object changes. If you hit a cancel or the save button, it awaits task response and when it finishes, it returns task results in an array, thus, you can check, save and modify the object. In the code above, that array way obj_res, which is abbreviation of object_response, also, we've checked if player hit save button, a.k.a EDIT_RESPONSE_FINAL or cancel button with obviously EDIT_RESPONSE_FINAL and then we simply output a message. If, for some reason, messages didn't get output, then there's most likely a problem.

The functions you're going to use are:

Task: AsyncObject_Edit(playerid, objectid)

The params are obvious, the function also has a wrapper. By defining ASYNC_OBJECT_SYNTAX_EDIT you allow yourself to use it:

Task: EditObjectAsync(playerid, objectid)

Note: You've to put OnPlayerEditObject callback in your script.

Testing

To test, simply run the package, connect to a server and then execute /test:

sampctl package run

Ta strona jest zbudowana z tego, co GitHub publikuje o repozytorium. samp.directory nie hostuje kodu. Zgłoś problem z tym wpisem

Mergevos/samp-async-objects: Biblioteka SA-MP | samp.directory