PHP код:
#include <a_samp>
const PL_NAME_SIZE = MAX_PLAYER_NAME + 1;
const PL_PASS_HASH_SIZE = 64 + 1;
enum e_PLAYER_INFO
{
plName[PL_NAME_SIZE],
plPassHash[PL_PASS_HASH_SIZE],
bool:plLoginStatus,
plLevel,
plMoney,
plAdminLevel,
Float:plX, Float:plY, Float:plZ
};
new player_info[MAX_PLAYERS][e_PLAYER_INFO];
GetPlayerField(playerid, e_PLAYER_INFO:field, &{_, Float, bool}:value)
{
value = player_info[playerid][field];
}
SetPlayerField(playerid, e_PLAYER_INFO:field, {_, Float, bool}:value)
{
player_info[playerid][field] = value;
}
GetPlayerFieldString(playerid,e_PLAYER_INFO:field, buf[],buf_size = sizeof(buf))
{
buf[0] = '\0', strcat(buf, player_info[playerid][field], buf_size);
}
SetPlayerFieldString(playerid, e_PLAYER_INFO:field, const value[], field_size)
{
strmid(player_info[playerid][field], value, 0, strlen(value), field_size);
}
PrintPlayerInfo(playerid)
{
new int_value, float_value, bool_value;
new array_value[128];
static const bool_strs[2][] = {{"false"}, {"true"}};
GetPlayerFieldString(playerid, plName, array_value);
printf("Name: %s", array_value);
GetPlayerFieldString(playerid, plPassHash, array_value);
printf("PassHash: %s", array_value);
GetPlayerField(playerid, plLoginStatus, bool_value);
printf("LoginStatus: %s", bool_strs[!!bool_value]);
GetPlayerField(playerid, plLevel, int_value);
printf("Level: %d", int_value);
GetPlayerField(playerid, plMoney, int_value);
printf("Money: %d", int_value);
GetPlayerField(playerid, plAdminLevel, int_value);
printf("AdminLevel: %d", int_value);
GetPlayerField(playerid, plX, float_value);
printf("X: %f", float_value);
GetPlayerField(playerid, plY, float_value);
printf("Y: %f", float_value);
GetPlayerField(playerid, plZ, float_value);
printf("Z: %f", float_value);
}
main()
{
SetPlayerFieldString(0, plName, "Daniel_Cortez", PL_NAME_SIZE);
new hash[PL_PASS_HASH_SIZE];
format(hash, sizeof(hash), "%x", 0xDC);
SetPlayerFieldString(0, plPassHash, hash, PL_NAME_SIZE);
SetPlayerField(0, plLoginStatus, true);
SetPlayerField(0, plLevel, 20);
SetPlayerField(0, plMoney, false);
SetPlayerField(0, plAdminLevel, 9001);
SetPlayerField(0, plX, 2000.0);
SetPlayerField(0, plY, 30.0);
SetPlayerField(0, plZ, 100);
PrintPlayerInfo(0);
}
В Pawn нельзя сделать функцию, которая может вернуть значение нескольких типов, поэтому пришлось сделать возврат по ссылке.