cmd:createfix [HELP] [REP+]
#1

Hello,

so i have this cmd :-
Код:
CMD:createfix(playerid, params[])
{
   new str[256],icon, iconid;
   new Float:X, Float:Y, Float:Z;
   if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "[ERROR]Only RCON admin can used this command");
   if(sscanf(params,"i",icon)) return SendClientMessage(playerid,COLOR_RED,"[ERROR]Use: /createfix [ModelID]");
   if(icon < 1 || icon > 63) return  SendClientMessage(playerid, COLOR_RED, "[ERROR]Invalid Icon ID");
   GetPlayerPos(playerid, X, Y, Z);
   new File:Dom = fopen("Fix.txt", io_append);
   format(str, 256, "SetPlayerMapIcon(playerid, iconid, %f, %f, %f, %s, 0, MAPICON_LOCAL);//%s\r\n", X, Y, Z, params);
   fwrite(Dom, str);
   fclose(Dom);
   SetPlayerMapIcon(playerid, iconid, X, Y, Z, icon, 0, MAPICON_LOCAL);
   return 1;
}
Can anyone tell me that how can i load it on Player Connect?
Reply
#2

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.
Reply
#3

Cant understand it.
i just want OnPlayerConnect to load file :- Fix.txt
Nothing else.

Help?
Reply
#4

Make a function to open it and use the function in OnPlayerConnect, something like this:
pawn Код:
public OnPlayerConnect(playerid)
{
    file(playerid);
    return 1;
}

file(playerid)
{
    new File:Dom = fopen("Fix.txt", io_append);
}
Reply
#5

2 warnings :-
Код:
C:\DOCUME~1\User\Desktop\Server\GAMEMO~1\aviator.pwn(120) : warning 235: public function lacks forward declaration (symbol "mapfile")
C:\DOCUME~1\User\Desktop\Server\GAMEMO~1\aviator.pwn(122) : warning 204: symbol is assigned a value that is never used: "Dom"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Line 120 & 122 :-
Код:
public mapfile(playerid)
{
    new File:Dom = fopen("Fix.txt", io_append);
}
Reply
#6

You must forward the function before using it.
pawn Код:
forward mapfile(playerid)
Reply
#7

1 warning :-
Код:
C:\DOCUME~1\User\Desktop\Server\GAMEMO~1\aviator.pwn(123) : warning 204: symbol is assigned a value that is never used: "Dom"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
Line 123 :-
Код:
new File:Dom = fopen("Fix.txt", io_append);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)