SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Plugin Development

Thread Tools Display Modes
Old 09/08/2019, 12:56 PM   #21
Huge Clucker
IllidanS4's Avatar
Join Date: Feb 2013
Posts: 339
Reputation: 256
Default Re: PawnPlus

PawnPlus v1.1 released!

  • A new type of collection providing support for efficient storage of data using reusable integer indices.
  • When an element is added to a pool, it gets assigned an index which is then used to refer to the element.
  • Pools come in two versions with the same API ordered (new indices are assigned in a specific order), and unordered. Ordered pools will always assign the lowest unused index to a newly added element.
  • A pool can grow to any size if there are no unused slots for new elements.

  • Dynamic run-time representations of operations.
  • Can be constructed from components in a tree-like manner, or parsed from string with expr_parse.
  • The parser supports all standard Pawn operators and some PawnPlus-specific ones. It can also find and use non-public Pawn variables (via the debug API).
  • Expressions can be used in collections and new types of iterators to easily perform queries on multiple elements.

  • async pseudo-attribute for functions using the async pattern (together with return async).
  • The await macro has an alternative definition supporting multiline expression, but requires additional configuration for all tags (enabled via PP_MULTILINE_AWAIT).
  • await_arr and await_var added.

  • The API is now more unified, so all collections have roughly the same functions with the same semantics.
  • The capacity of the underlying container can be obtained.

  • If {} is used in str_format and it doesn't correspond to a color code or a parameter selector, it is parsed and executed as a piece of code.
  • %f in str_format accepts a width parameter.
  • str_append_format added.

Pawn and AMX
  • pawn_create_callback can be used to create a new callback/public function and attach it to the current script. The function consists of an expression that is executed every time the public function is called.
  • Declarational initializers and finalizers added. Any public function whose name starts with _pp@on_init@ will be called first before every other function, when the script is loaded. Any function whose name starts with _pp@on_exit@ will be called last after all other functions, when the script is unloaded. Macros pawn_on_init and pawn_on_exit can be used for easy creation of these functions.
  • AMX guards introduced. While a Pawn guard protects the object for the duration of the current context (analogous to a local variable), an AMX guard protects it for the duration of the script (analogous to a global/static local variable).
  • Handling public function index incompatibility with SAMPGDK can be resolved by pp_public_min_index or pp_use_funcidx. Callback handlers can be registered for negative indices.
  • Captured arguments (in pawn_register_callback or pawn_add_hook) now accept v, h, and x as new types of values. v corresponds to a Variant: argument which is copied to the closure and loaded when it is restored, h corresponds to a Handle: argument which is prolonged by the closure (so the underlying object is not destroyed) and whose value is loaded when the closure is restored, and x corresponds to an Expression: argument containing an expression which is executed every time the argument is restored.

Error handling
  • Dynamically called external natives that raise a system error/signal do not crash the server, but are handled and reported via PawnPlus errors.

  • Support for errors and serialization.

Error handling
  • pp_on_error is only called for a native called directly by the script. Errors in internally called natives are handled or propagated by the code that called them. pawn_try_call_native never invokes pp_on_error.

  • Iterators are invalidated on addition only when necessary (when the underlying buffer needs to be reallocated).

  • Calling operations on variables that are incompatible (different tags or sizes) now produces an error (used to return null).

  • Dynamically called operations on signed: and unsigned: values can raise an error.

Pawn and AMX
  • Incorrect public function index caused by SAMPGDK is detected and warned about.

  • collect operation is now correctly called in some places.

  • When a context is stored after a call to an asynchronous function, reset_stk and reset_hea are now used to correctly restore the original values of stk and hea, fixing a memory leak that happened when a public function with parameters was stored (because the parameters were not taken into account when stk was restored).

  • signed: and unsigned: subtraction fixed.

Error handling
  • Allocation of more data than the script supports is prevented.

Pawn and AMX
  • Removing a hook handler when it is running will not crash the server.

Format expressions
pawn Code:
new val1 = 5, val2 = 10;
print_s(str_format("the sum of {val1} and {val2} is {val1 + val2}"));

pawn Code:
new Map:m = map_new();
map_add(m, 1, 10);
map_add(m, 2, 21);
map_add(m, 3, 30);
map_add(m, 4, 41);
map_add(m, 5, 50);
map_remove_if(m, expr_parse("10*$key != $value")); //removes 2 and 4

Caching expressions
pawn Code:
static Expression:expr;
    expr = expr_parse("$value*$value");

Declarational callback handler
pawn Code:
    new id = pawn_create_callback("OnPlayerConnect", expr_const(0));
    pawn_register_callback(amx_encode_public(id), "MyOnPlayerConnect");
Yet Another Lua Plugin
Long Function Names running Cinematic Mode
IllidanS4 is offline   Reply With Quote
Old 13/08/2019, 04:03 PM   #22
Join Date: May 2018
Posts: 628
Reputation: 96
Default Re: PawnPlus

Great plugin!

I converted all const-arrays to dynamic strings but I am confused with arrays by reference. What I am trying to do is to get string value from mysql as dynamic.
pawn Code:
native cache_get_value_index_s(row_idx, column_idx, AmxStringBuffer: destination, max_len) = cache_get_value_index;
Based on your GetPlayerNameStr example:
pawn Code:
new String: name = str_new_buf(MAX_PLAYER_NAME);

cache_get_value_index_s(0, 0, name, MAX_PLAYER_NAME);
str_resize(name, str_len(name) + 1);

when trying to `print_s` it, it is just empty. Is it different from native GetPlayerName as that one works.

Last edited by Calisthenics; 15/08/2019 at 04:22 PM.
Calisthenics is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Plugin] PawnPlus IS4 Plugin Development 34 26/09/2018 09:02 PM
[Help] PawnPlus IDE Manda21 Scripting Help 4 29/10/2016 01:41 PM
[Tool/Web/Other] [0.1] PawnPlus IDE - PAWNO alternative WopsS Tools and Files 62 13/04/2016 10:32 PM
[Tool/Web/Other] PawnPlus IDE - PAWNO alternative WopsS Tools and Files 94 14/01/2016 09:32 PM

All times are GMT. The time now is 12:44 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.