Category: pawn
DJson 1.6.2 released
Today I have an important little bugfix release for djson available.
The issue was, that reading a value after an invalid set, breaks the reading. Thus, if you did a djInt on a value, which does not exist, any later dj call does not work. Thanks to Raphinity for reporting the issue.
Zamaroht reported a strange issue, when setting a value between two append-operations. This was due to a problem with the caching algorithm and has been resolved! Thanks Zamaroht for the report!
Another problem occurred, when you tried to write a string containing " (quotation marks). Those are escaped now properly, too.
These issue are of course fixed with the latest version djson 1.6.2 download.
amx/amxfile.c, fails in fputs_cell:
When trying to run my pawn script on a new linux server, I received the following error:
2
Assertion `fp!=((void *)0)' failed.
This was actually caused by a missing scriptfiles directory (or the directory was not writeable).
So take care in your scripts if an fopen really gives you a vaild file pointer and handle the situation if it does not!
DJson 1.6 released
Today I want to announce a new release of DJson. The 1.6 is now using a different method to create the cache-file, which allows running multiple djson-scripts (like filterscripts) at the same time.
Also it features a method to define own DJSON_MAX_STRING (before include of djson), if you need really big content.
The internal djson cache allows a maximum of ~ 70 characters (255-filenamelength-keylength-170) for a value, if DJSON_MAX_STRING is set to just 255.
Head over to the official DJson page or directly to the djson 1.6 download.
urlencode in Pawn
When creating new REST-ful API for GTAT (based upon my pwncurl and a lua backend) I had to implement the method urlencode in pawn.
So I took a look at the specification in RFC 1738 to get information about what characters need to be encoded.
RFC 1738: Only alphanumerics, the special characters "$-_.+!*'(),", and reserved characters used for their reserved purposes may be used unencoded within a URL.
Since I really want to be sure that all is encoded properly and %xx encoding is
Renaming a file in Pawn
If you are using pawn (for instance in san andreas multiplayer) and want to rename a file, you'll not find a method like frename.
You can either use my dutils (pawn only solution) or a plugin (like Yless' YSF) to add frename to your functions.
If you want to make a plain pawn solution, and don't want to use dutils, here is how I made it.
There are two steps.
First you'll need fcopy (copies the file):
2
3
4
5
6
7
8
9
nhnd=fopen(newname,io_write);
new buf2[1];
new i;
for (i=flength(ohnd);i>0;i--) {
fputchar(nhnd, fgetchar(ohnd, buf2[0],false),false);
}
fclose(ohnd);
fclose(nhnd);
And then you'll need to remove the old file.
Remember, that on linux those methods will not work (since fputchar is bugged on linux). You need to use the pawnonly frenametextfile and fcopytextfile from dutils for that.
Toggle Map-Icon Visibility for a Player
If you want to hide a specific player on the map, you can set the alpha value to 0x00. If you want to make him visible again, you just have to set it to 0xFF.
Since this is not always simple, to store the current color of the player in a invisible and a visible way, you can use bitwise or to do that task for you.
This is my togglePlayerMapIconVisibility function, which keeps the color of the player and toggles the player to visible or invisible on the map.
2
3
SetPlayerColor(playerid, (GetPlayerColor(playerid) | 0xFF) - (visible ? 0x00 : 0xFF));
}


