Add this above your gamemode:
Код:
enum dmpInfo
{
dmpMapIconID,
Float: dmpPosX,
Float: dmpPosY,
Float: dmpPosZ,
dmpMarkerType,
dmpColor,
dmpVW,
dmpInt,
}
new DMPInfo[MAX_DMAPICONS][dmpInfo];
Код:
LoadDynamicMapIcons()
{
new arrCoords[7][64];
new strFromFile2[256];
new File: file = fopen("dynamicmapicons.cfg", io_read);
if (file)
{
new idx;
while (idx < sizeof(DMPInfo))
{
fread(file, strFromFile2);
splits(strFromFile2, arrCoords, '|');
DMPInfo[idx][dmpMarkerType] = strval(arrCoords[0]);
DMPInfo[idx][dmpColor] = strval(arrCoords[1]);
DMPInfo[idx][dmpVW] = strval(arrCoords[2]);
DMPInfo[idx][dmpInt] = strval(arrCoords[3]);
DMPInfo[idx][dmpPosX] = floatstr(arrCoords[4]);
DMPInfo[idx][dmpPosY] = floatstr(arrCoords[5]);
DMPInfo[idx][dmpPosZ] = floatstr(arrCoords[6]);
if(DMPInfo[idx][dmpMarkerType] != 0)
{
DMPInfo[idx][dmpMapIconID] = CreateDynamicMapIcon(DMPInfo[idx][dmpPosX], DMPInfo[idx][dmpPosY], DMPInfo[idx][dmpPosZ], DMPInfo[idx][dmpMarkerType], DMPInfo[idx][dmpColor], DMPInfo[idx][dmpVW], DMPInfo[idx][dmpInt], -1, 500.0);
}
idx++;
}
fclose(file);
}
return 1;
}
Код:
SaveDynamicMapIcons() {
new
szFileStr[326],
File: fHandle = fopen("dynamicmapicons.cfg", io_write);
for(new iIndex; iIndex < MAX_DMAPICONS; iIndex++) {
format(szFileStr, sizeof(szFileStr), "%d|%d|%d|%d|%f|%f|%f\r\n",
DMPInfo[iIndex][dmpMarkerType],
DMPInfo[iIndex][dmpColor],
DMPInfo[iIndex][dmpVW],
DMPInfo[iIndex][dmpInt],
DMPInfo[iIndex][dmpPosX],
DMPInfo[iIndex][dmpPosY],
DMPInfo[iIndex][dmpPosZ]
);
fwrite(fHandle, szFileStr);
}
return fclose(fHandle);
}
Checks which map icon is ready for use:
Код:
CMD:dmpnext(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
SendClientMessageEx(playerid, COLOR_RED, "* Listing next available map icon...");
for(new x;x<MAX_DMAPICONS;x++)
{
if(DMPInfo[x][dmpMarkerType] != 0)
{
new string[128];
format(string, sizeof(string), "%d is available to use.", x);
SendClientMessageEx(playerid, COLOR_WHITE, string);
break;
}
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
return 1;
}
return 1;
}
And here you can see the map icons id that near your location:
Код:
CMD:dmpnear(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4)
{
SendClientMessageEx(playerid, COLOR_RED, "* Listing all map icons within 30 meters of you");
new Float:X, Float:Y, Float:Z;
GetPlayerPos(playerid, X, Y, Z);
for(new i;i<MAX_DMAPICONS;i++)
{
if(IsPlayerInRangeOfPoint(playerid, 30, DMPInfo[i][dmpPosX], DMPInfo[i][dmpPosY], DMPInfo[i][dmpPosZ]))
{
if(DMPInfo[i][dmpMarkerType] != 0)
{
new string[128];
format(string, sizeof(string), "MapIcon ID %d | %f from you", i, GetDistance(DMPInfo[i][dmpPosX], DMPInfo[i][dmpPosY], DMPInfo[i][dmpPosZ], X, Y, Z));
SendClientMessageEx(playerid, COLOR_WHITE, string);
}
}
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
}
return 1;
}
And here you can place map icon and edit it:
Код:
CMD:dmpedit(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command!");
return 1;
}
new string[128], choice[32], mapiconid, amount;
if(sscanf(params, "s[32]dD", choice, mapiconid, amount))
{
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /dmpedit [name] [mapiconid] [(Optional)amount]");
SendClientMessageEx(playerid, COLOR_GREY, "Available names: Position, MarkerType, Color, Delete");
return 1;
}
if(mapiconid < 0 || mapiconid >= MAX_DMAPICONS)
{
SendClientMessageEx( playerid, COLOR_WHITE, "Invalid Map Icon ID!");
}
if(strcmp(choice, "position", true) == 0)
{
GetPlayerPos(playerid, DMPInfo[mapiconid][dmpPosX], DMPInfo[mapiconid][dmpPosY], DMPInfo[mapiconid][dmpPosZ]);
DMPInfo[mapiconid][dmpInt] = GetPlayerInterior(playerid);
DMPInfo[mapiconid][dmpVW] = GetPlayerVirtualWorld(playerid);
SendClientMessageEx(playerid, COLOR_WHITE, "You have changed the position!");
if(IsValidDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID])) DestroyDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID]);
DMPInfo[mapiconid][dmpMapIconID] = CreateDynamicMapIcon(DMPInfo[mapiconid][dmpPosX], DMPInfo[mapiconid][dmpPosY], DMPInfo[mapiconid][dmpPosZ], DMPInfo[mapiconid][dmpMarkerType], DMPInfo[mapiconid][dmpColor], DMPInfo[mapiconid][dmpVW], DMPInfo[mapiconid][dmpInt], -1, 500.0);
SaveDynamicMapIcons();
format(string, sizeof(string), "%s has edited MapIconID %d's Position.", GetPlayerNameEx(playerid), mapiconid);
Log("logs/dmpedit.log", string);
return 1;
}
else if(strcmp(choice, "delete", true) == 0)
{
SendClientMessageEx(playerid, COLOR_WHITE, "You have deleted the map icon!");
DMPInfo[mapiconid][dmpPosX] = 0.0;
DMPInfo[mapiconid][dmpPosY] = 0.0;
DMPInfo[mapiconid][dmpPosZ] = 0.0;
DMPInfo[mapiconid][dmpVW] = 0;
DMPInfo[mapiconid][dmpInt] = 0;
DMPInfo[mapiconid][dmpMarkerType] = 0;
DMPInfo[mapiconid][dmpColor] = 0;
SaveDynamicMapIcons();
if(IsValidDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID])) DestroyDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID]);
format(string, sizeof(string), "%s has deleted MapIconID %d.", GetPlayerNameEx(playerid), mapiconid);
Log("logs/dmpedit.log", string);
return 1;
}
else if(strcmp(choice, "markertype", true) == 0)
{
DMPInfo[mapiconid][dmpMarkerType] = amount;
format(string, sizeof(string), "You have set the marker type to %d.", amount);
SendClientMessageEx(playerid, COLOR_WHITE, string);
if(IsValidDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID])) DestroyDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID]);
DMPInfo[mapiconid][dmpMapIconID] = CreateDynamicMapIcon(DMPInfo[mapiconid][dmpPosX], DMPInfo[mapiconid][dmpPosY], DMPInfo[mapiconid][dmpPosZ], DMPInfo[mapiconid][dmpMarkerType], DMPInfo[mapiconid][dmpColor], DMPInfo[mapiconid][dmpVW], DMPInfo[mapiconid][dmpInt], -1, 500.0);
format(string, sizeof(string), "%s has edited MapIconID %d's Marker Type to %d.", GetPlayerNameEx(playerid), mapiconid, amount);
Log("logs/dmpedit.log", string);
}
else if(strcmp(choice, "color", true) == 0)
{
DMPInfo[mapiconid][dmpColor] = amount;
format(string, sizeof(string), "You have set the color to %d.", amount);
SendClientMessageEx(playerid, COLOR_WHITE, string);
if(IsValidDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID])) DestroyDynamicMapIcon(DMPInfo[mapiconid][dmpMapIconID]);
DMPInfo[mapiconid][dmpMapIconID] = CreateDynamicMapIcon(DMPInfo[mapiconid][dmpPosX], DMPInfo[mapiconid][dmpPosY], DMPInfo[mapiconid][dmpPosZ], DMPInfo[mapiconid][dmpMarkerType], DMPInfo[mapiconid][dmpColor], DMPInfo[mapiconid][dmpVW], DMPInfo[mapiconid][dmpInt], -1, 500.0);
format(string, sizeof(string), "%s has edited MapIconID %d's Color to %d.", GetPlayerNameEx(playerid), mapiconid, amount);
Log("logs/dmpedit.log", string);
}
SaveDynamicMapIcons();
return 1;
}
this one TP you to a map icon:
Код:
CMD:gotomapicon(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command!");
return 1;
}
new mapiconid;
if(sscanf(params, "d", mapiconid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gotomapicon [mapiconid]");
if(mapiconid >= MAX_DMAPICONS || mapiconid < 0)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "USAGE: /gotomapicon [mapiconid]");
return 1;
}
SetPlayerPos(playerid, DMPInfo[mapiconid][dmpPosX], DMPInfo[mapiconid][dmpPosY], DMPInfo[mapiconid][dmpPosZ]);
SetPlayerVirtualWorld(playerid, DMPInfo[mapiconid][dmpVW]);
SetPlayerInterior(playerid, DMPInfo[mapiconid][dmpInt]);
return 1;
}
i hope i helped.