PawnPlus v0.11.1
Pre-release
Pre-release
Error handling
- By default, any error caused by a native function will be reported via a raised AMX native error, in addition to a message to the log. This happens when a function is expected to produce a result based on its description, but fails to do so (because of invalid arguments, invalid state of the object etc.), and the error can be prevented. Do not expect that native functions return 0 or some other error code; instead, make sure the errorneous call never happens in the first place.
pp_error_level
can set a script-wide error level that is sufficient for raising an AMX error. Usable values areerror_logic
,error_formal
, anderror_none
. The first level is set by default, the last can be used to disable AMX errors altogether. Logic errors occur when you work with invalid data in your code (references to nonexistent objects, invalid indices etc.); these can be fixed by making sure you properly initialise your variables or check for exceptional values. Formal errors occurs when you call a function in a certain form that is not expected, like a mismatch in the number of arguments forpawn_call_public
or an invalid function name (these errors were already reported prior to this version); these errors are usually fixed by fixing the native call itself.- When an error occurs in the script, public
pp_on_error
can be used to handle it before an AMX error is raised. The source, message, and level is provided to the callback, which can specify the value returned from the erroring function. Returning true from the callback will suppress the error.
Containers
- Maps can be switched to ordered mode via
map_set_ordered
. When this is used, all pairings in the map will be ordered based on the key, and all newly added values will conform to this ordering. All iterators to the map are also invalidated. - Instead of the
hash
operation, ordered maps use thelt
operation (less than) to compare keys. Therefore, values with different tags are always comparable (although the result is only determined by their tags, not by their values), and arrays are compared lexicographically via their cells. Thus string keys can are also comparable. var_get_arr
will, when the offsets are specified, copy the whole range of cells starting at the offsets instead of just the first cell.
Tasks
task_set_result
will return the value returned (or yielded) from the last handler that was executed in response to the task.
AMX
amx_end_fork
renamed toamx_fork_end
.amx_parallel_begin
andamx_parallel_end
(used in the macroamx_parallel
). This function sets the debug handler for the AMX that, when called (via theBREAK
instruction), pauses the execution of the AMX and schedules it to be resumed on the next tick. The number ofBREAK
instructions that must be used to pause the machine can be also specified. With the sufficient debug level, they will be emitted after every statement (or you can use#emit break
). This makes long loops appear to run in parallel with the server and the script (but they will be less efficient than true threaded code).