[Plugin] CrashDetect (pronadjite gresku u skripti)

Započeo Harryâ„¢, Mart 30, 2016, 19:41:18 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 1 gost pregledaju ovu temu.

Ime plugina: CrashDetect
Ime autora: JernejL
Opis: Ovaj plugin nam pomaze odnosno omogucuje da pronadjemo gresku u gamemodeu zbog cega nam ne moze pokrenuti srw, zasto se gasi i tako nesto slicno
Funkcije:

Znaci pokrecete mod!
[pawn]
#include <a_samp>

main() {
    function1();
}

function1() {
    function2();
}

function2() {
    new buf[10];
    fread(File:123, buf);
}
[/pawn]


U defaultu kada doÄ'e do funkcije "function2",vaÅ¡ server će se odmah ugasiti,a ukoliko koristite windows server samo će napisati neki text u crashinfo.txt.

Ali sa CrashDetectom,vi će te vidjeti sljedeče:



[05:26:38] [debug] Server crashed while executing crash.amx
[05:26:38] [debug] Backtrace (most recent call first):
[05:26:38] [debug] #0  native fread () from samp-server.exe
[05:26:38] [debug] #1  00000090 in ?? () from crash.amx
[05:26:38] [debug] #2  00000038 in ?? () from crash.amx
[05:26:38] [debug] #3  0000001c in main () from crash.amx
which is more informative. You can also get more information like line numbers, function names, parameter values, etc if compile that script in debug mode to make compiler put extra information about all that stuff into the output .amx (see here for how):



[05:27:11] [debug] Server crashed while executing crash.amx
[05:27:11] [debug] Backtrace (most recent call first):
[05:27:11] [debug] #0  native fread () from samp-server.exe
[05:27:11] [debug] #1  000000b8 in function2 () at crash.pwn:13
[05:27:11] [debug] #2  00000048 in function1 () at crash.pwn:8
[05:27:11] [debug] #3  00000024 in main () at crash.pwn:4
Runtime error


Run time erori su najčešće napisani u ovom obliku "Run time error <error_code>:"Error details here" poruka". Nažalost ova poruka je rijetko prikazana jer ju server ne traži uvijek.

[pawn]public OnGameModeInit() {
    new bla[5];

    new fffuuuu = 0;

    fffuuuu = 100;
    bla[fffuuuu] = 100;

    return bla[fffuuuu];
}[/pawn]


Ukoliko kompilate ovaj kod u debug modu i pokrenete server:

[05:32:16] [debug] Run time error 4: "Array index out of bounds"
[05:32:16] [debug]   Accessing element at index 100 past array upper bound 4
[05:32:16] [debug] Backtrace (most recent call first):
[05:32:16] [debug] #0  00000084 in public OnGameModeInit () at bounds.pwn:11


Ukoliko želite napraviti da se vaš server ugasi na prvom "runtime" eroru, namjestite "die_on_error" u vašem server.cfg na 1.

npr: die_on_error 1



Download:


Source code: https://github.com/Zeex/samp-plugin-crashdetect
Pre-built binaries for Linux and Windows: https://github.com/Zeex/samp-plugin-crashdetect/tree/downloads



Jako korisno :)
Srecu cine male stvari i veliko pivo!
x3M-Gaming USKORO!