Yshmeel
Дебютант
Всем ку пользователи P-I.
Суть данной системы заключается в созданий GPS меток из игры
Приступим:
Ко всем #define:Суть данной системы заключается в созданий GPS меток из игры
Приступим:
PHP:
#define MAX_GPS 500 // максимальное кол-во GPS
#define DIALOGGPS 0 // диалог GPS, заменить 0 на свободный id диалога
PHP:
enum GPSInfo
{
Float:gCoords[3],
gName
};
new GData[MAX_GPS][GPSInfo], GPSLOAD;
PHP:
mysql_function_query(mysql_connect_id,"SELECT * FROM gpslist",true,"GPSList","");
DC_CMD
PHP:
CMD:gps(playerid)
{
DisablePlayerCheckpoint(playerid);
new mes[1000];
for(new i = 0; i < GPSLOAD;i++)
{
format(mes, sizeof(mes), "{ffffff}%s{ffa500}Имя GPS метки: {ffffff}%s\n", mes,GData[i+1][gName]);
}
return ShowPlayerDialog(playerid, DIALOGGPS, DIALOG_STYLE_LIST, "GPS", mes, "Выбрать", "Отмена');
}
CMD:creategps(playerid, params[])
{
if(sscanf(params, "s[32]", params[0])) return SendClientMessage(playerid, -1, "/creategps [Название gps]");
new Float:coords[3];
GetPlayerPos(playerid, coords[0], coords[1], coords[2]);
mysql_format(mysql_connect_id,squery,700,"INSERT INTO `gpslist` (`x`, `y`, `z`, `name`) VALUES ('%f', '%f', '%f', '%s')", x,y,z,params[0]);
mysql_function_query(mysql_connect_id,squery,false,"","");
GPSLOAD++;
GData[GPSLOAD][gCoords][0] = coords[0];
GData[GPSLOAD][gCoords][1] = coords[1];
GData[GPSLOAD][gCoords][2] = coords[2];
GData[GPSLOAD][gName][0] = EOS;
strins(GData[GPSLOAD][gName], params[0], 0);
SendClientMessage(playerid, -1, "Success");
return true;
}
PHP:
case DIALOGGPS:
{
if(!response) return false;
SetPlayerCheckpoint(playerid, GData[listitem+1][gCoords][0], GData[listitem+1][gCoords][1],GData[listitem+1][gCoords][2],3.0);// чекпоинт
SetPVarInt(playerid, "GPS", 1);
SendClientMessage(playerid, -1, "Чекпоинт установлен!");
return true;
}
PHP:
if(GetPVarInt(playerid, "GPS") == 1)
{
DisablePlayerCheckpoint(playerid);
SendClientMessage(playerid, -1, "Вы приехали на место назначения!");
DeletePVar(playerid, "GPS");
return true;
}
PHP:
forward GPSList();
public GPSList()
{
new rows,fields;
cache_get_data(rows, fields);
if(rows)
{
for(new i = 0; i < rows; i++)
{
GPSLOAD++;
GData[GPSLOAD][gCoords][0] = cache_get_field_content_float(i, "x", handle);
GData[GPSLOAD][gCoords][1] = cache_get_field_content_float(i, "y", handle);
GData[GPSLOAD][gCoords][2] = cache_get_field_content_float(i, "z", handle);
cache_get_field_content(idx, "name", GData[GPSLOAD][gName], handle, strlen(GData[GPSLOAD][gName]));
}
}
return true;
}
P.S - handle заменяйте на свое!
Ах да запрос в БД:
PHP:
CREATE TABLE gpslist
(
x float,
y float,
z float,
name varchar(32)
);
