How can I use printf to find errors in the script? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How can I use printf to find errors in the script? (
/showthread.php?tid=271594)
How can I use printf to find errors in the script? -
grand.Theft.Otto - 25.07.2011
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 ?
Re: How can I use printf to find errors in the script? -
dowster - 25.07.2011
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
and if i don't see the second message i know where the error is
Re: How can I use printf to find errors in the script? -
[HiC]TheKiller - 25.07.2011
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.
Re: How can I use printf to find errors in the script? -
iPLEOMAX - 25.07.2011
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);
}
Re: How can I use printf to find errors in the script? -
grand.Theft.Otto - 25.07.2011
Hmm, thanks everyone, seems to make sense now