SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Thread Tools Display Modes
Old 19/05/2014, 08:50 AM   #1
Big Clucker
Join Date: Mar 2014
Posts: 69
Reputation: 58
Default How to debug.

Hello, I have been looking through threads, and I came to the conclusion that it lacks of people having the actual knowledge to debug their own code.

Q: Why would I debug?
A: Debug is a good way to find whether your variables/strings are correctly.

Q: How do I debug?
A: There are multiple ways of debugging, you can either debug it with SendClientMessage's or print's.

Q: Where does it print?
A: If you use SendClientMessage it prints IG, if you are using print's it's in your samp-server.exe.

Okay, I will be using the printf function(, let's start

How to debug integer's?

new array[3]; // Creating the array to keep the integers
array[0] = 1; // Adding a value to the arrays.
array[1] = 2; // Adding a value to the arrays.
array[2] = 3; // Adding a value to the arrays.
printf("Arr1: %d, Arr2: %i, Arr3: %d" array[0], array[1], array[2]); // Printing the code.
It will print:

Arr1: 1, Arr2: 2, Arr3: 3
So, now we've learned how to debug integers, let's step to strings.

new string[5]; // Creating a new string

string = "Text"; // Assigning a value to the string.
printf("%s", Text); // As you can see we use this time this parameter: %s because we are going to debug a string now, you can find all parameters on the wiki(
It would print: Text.
__________________________________________________ ___________________________________

Okay, this was the most basic stuff, now let's procceed to the more difficult one.
We will we debugging callback's now, we will start off with OnPlayerDeath.

Okay, the parameters for the OnPlayerDeath callback are: (playerid, killerid, reason).
Which means that both playerid and killerid are integer's and reason is a string.

We have learned that strings are %s and integer can either be %i or %d.

printf("OnPlayerDeath: playerid: %d, killerid; %d, reason: %s", playerid, killerid, reason); // Place this under OnPlayerDeath and it will print the data.

This is just a basic tutorial on how to debug, you can find all of the parameters at the wiki, and if you are curious and want to try out your code, use Slice's Pawn Playground(

Did I miss something? Feel free to post it on this thread!

Usefull links:

Printf wiki
Slice's playground(Thanks!)

Thanks for your attention.
My work:

[GameMode]Liberty Roleplay
[Tutorial]How to debug
jihadmeneer is offline   Reply With Quote
Old 21/05/2014, 05:37 PM   #2
Big Clucker
Join Date: Apr 2013
Location: Las Venturas
Posts: 182
Reputation: 21
Default Re: How to debug.

Not Bad, but people might know this already? anyway keep up
superrobot48 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
debug pozitiv4eg Русский/Russian 1 02/12/2013 01:18 PM
Debug Scott Zulkifli Server Support 4 17/03/2013 10:38 AM
DEBUG smuf_albert95 Help Archive 3 11/01/2010 07:44 PM
SA-MP Debug Arnaldo Help Archive 5 23/12/2009 10:44 AM

All times are GMT. The time now is 01:11 PM.

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