How can I use printf to find errors in the script?
#1

I have heard that you can use printf(); which can find and print errors to the console which can be useful0. But I am wondering how I would go about doing that? Can someone give me an explanation of how I could use printf to find bugs and errors ?
Reply
#2

if something is crashing in my script i will put a print before it does something like
pawn Код:
print("starting text forwarding");
then when its done i do
pawn Код:
print("text forwarded");
and if i don't see the second message i know where the error is
Reply
#3

Just put it on every line of the function / callback that you are receiving errors from. Also, it's better to use print, requires no parameters.
Reply
#4

When you are trying to run a particular function and it doesn't happen, you can always use print/prinf/sendclientmessage to the steps of the function to see which part isn't working.


An Example:
pawn Код:
//some timer:
SetTimer("DoFirstThing", 1000, true);

forward DoFirstThing();
public DoFirstThing()
{
    print("Timer works, started first thing...");
    DoSecondThing();
}

DoSecondThing()
{
    print("second thing done!");
    DoThirdThing(914);
}

DoThirdThing(value)
{
    printf("third thing done! Input Value: %i", value);
}
Reply
#5

Hmm, thanks everyone, seems to make sense now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)