SA-MP Forums Archive
[Tutorial] How to make a bug report command (ZCMD + sscanf + log) - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to make a bug report command (ZCMD + sscanf + log) (/showthread.php?tid=372988)



How to make a bug report command (ZCMD + sscanf + log) - MarkoN - 28.08.2012

Bug reporting + log
Intro
Hi, this is my first tutorial. I'll try to explain how to make a bug report command with zcmd processor and logging

Lets start
Includes neededCommand (explanation)
First we will need to add the zcmd header.
pawn Code:
CMD:reportbug(playerid, params[])
{

return 1;
}
Now that we made the header we will need to add the variables...
pawn Code:
CMD:reportbug(playerid, params[])
{
new text[64], name[MAX_PLAYER_NAME], bugstring[256], Float:x, Float:y, Float:z, File:Bugs;

return 1;
}
Ok lets explain all that : So now we need to make sure that the player typed it correctly and if the type limit exceeded.
pawn Code:
CMD:reportbug(playerid, params[])
{
new text[64], name[MAX_PLAYER_NAME], bugstring[256], Float:x, Float:y, Float:z, File:Bugs;

if(sscanf(params, "s[64]", text)) return SendClientMessage(playerid, COLOR_RED "• Incorrect fomat. Use /reportbug [description]");
if(strlen(text) > 64) return SendClientMessage(playerid, COLOR_RED,"• Description is too long (Max. 64 letters)");

return 1;
}
Explanation : Now, we need to get a players name and his position, so...
pawn Code:
CMD:reportbug(playerid, params[])
{
new text[64], name[MAX_PLAYER_NAME], bugstring[256], Float:x, Float:y, Float:z, File:Bugs;

if(sscanf(params, "s[64]", text)) return SendClientMessage(playerid, COLOR_RED "• Incorrect fomat. Use /reportbug [description]");
if(strlen(text) > 64) return SendClientMessage(playerid, COLOR_RED,"• Description is too long (Max. 64 letters)");
   
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);

return 1;
}
Explanation : Now, we need to format the message thats going to be in the .log file
pawn Code:
CMD:reportbug(playerid, params[])
{
new text[64], name[MAX_PLAYER_NAME], bugstring[256], Float:x, Float:y, Float:z, File:Bugs;

if(sscanf(params, "s[64]", text)) return SendClientMessage(playerid, COLOR_RED "• Incorrect fomat. Use /reportbug [description]");
if(strlen(text) > 64) return SendClientMessage(playerid, COLOR_RED,"• Description is too long (Max. 64 letters)");
   
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);
format(bugstring, sizeof(bugstring), "%s reported a bug. Description : %s, on coordinates : X:%f, Y:%f, Z:%f\r\n", name, text, x, y, z);

return 1;
}
Explanation :
There isnt much to explain, were formatting a string thats going to be in a log...

Ok now we need to open the .log file and write in it... so
pawn Code:
CMD:reportbug(playerid, params[])
{
new text[64], name[MAX_PLAYER_NAME], bugstring[256], Float:x, Float:y, Float:z, File:Bugs;

if(sscanf(params, "s[64]", text)) return SendClientMessage(playerid, COLOR_RED "• Incorrect fomat. Use /reportbug [description]");
if(strlen(text) > 64) return SendClientMessage(playerid, COLOR_RED,"• Description is too long (Max. 64 letters)");
   
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);
format(bugstring, sizeof(bugstring), "%s reported a bug. Description : %s, on coordinates : X:%f, Y:%f, Z:%f\r\n", name, text, x, y, z);

Bugs = fopen("bugs.log", io_append);
fwrite(Bugs, bugstring);
fclose(Bugs);

return 1;
}
Explanation : Thats all... You can add a message that he successfully reported that bug, so :
pawn Code:
CMD:reportbug(playerid, params[])
{
new text[64], name[MAX_PLAYER_NAME], bugstring[256], Float:x, Float:y, Float:z, File:Bugs;

if(sscanf(params, "s[64]", text)) return SendClientMessage(playerid, COLOR_RED "• Incorrect fomat. Use /reportbug [description]");
if(strlen(text) > 64) return SendClientMessage(playerid, COLOR_RED,"• Description is too long (Max. 64 letters)");
   
GetPlayerName(playerid, name, sizeof(name));
GetPlayerPos(playerid, x, y, z);
format(bugstring, sizeof(bugstring), "%s reported a bug. Description : %s, on coordinates : X:%f, Y:%f, Z:%f\r\n", name, text, x, y, z);

Bugs = fopen("bugs.log", io_append);
fwrite(Bugs, bugstring);
fclose(Bugs);

SendClientMessage(playerid, COLOR_YELLOW, "• Thank you. You successfully reported a bug.");

return 1;
}
bugs.log
Code:
Marko repoted a bug. Description : test, on coordinates : X:1958.378295, Y:1343.613891, Z:15.374607
Ending
Sorry if its too easy to make, since this is my first tutorial i didnt want to try adding something advanced since ill surly mess up something.


Re: How to make a bug report command (ZCMD + sscanf + log) - MarkoN - 31.08.2012

any feedback ? something i should remake or fix some grammar mistakes ?


Re: How to make a bug report command (ZCMD + sscanf + log) - JaKe Elite - 01.09.2012

You should remake it.
Remake it on scratch indent it properly.

You know why?

There is some beginners reading this.
And they might get loose indentation warning.
So i recommend you to remake it with proper indentation.

Anyway, 5/10


Re: How to make a bug report command (ZCMD + sscanf + log) - [LB]BlAcK_DeViL - 01.09.2012

Good Tutorial ..


Re: How to make a bug report command (ZCMD + sscanf + log) - MarkoN - 01.09.2012

indentations removed


Re: How to make a bug report command (ZCMD + sscanf + log) - 2KY - 01.09.2012

Quote:
Originally Posted by Romel
View Post
You should remake it.
Remake it on scratch indent it properly.

You know why?

There is some beginners reading this.
And they might get loose indentation warning.
So i recommend you to remake it with proper indentation.

Anyway, 5/10
Why would he completely remake it? The only thing I see wrong indentation wise is his returns, which can be easily tweaked.

OT: Good tutorial, easy, simple and to the point. Here, have some reputation as a gift.


Re: How to make a bug report command (ZCMD + sscanf + log) - [LB]BlAcK_DeViL - 01.09.2012

Wat ??


Re: How to make a bug report command (ZCMD + sscanf + log) - Jeth - 01.09.2012

Good tut


Re: How to make a bug report command (ZCMD + sscanf + log) - MarkoN - 01.09.2012

Quote:
Originally Posted by 2KY
View Post
OT: Good tutorial, easy, simple and to the point. Here, have some reputation as a gift.
thanks

Quote:
Originally Posted by Jeth
View Post
Good tut
ty


Re: How to make a bug report command (ZCMD + sscanf + log) - Akira297 - 01.09.2012

Code:
'Player has reported a bug. Desc. : {Text } , At the Coordinates of :'