SA-MP Forums Archive
[Include] OnPlayerMarkMap - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] OnPlayerMarkMap (/showthread.php?tid=282453)



OnPlayerMarkMap - NaS - 11.09.2011

OnPlayerMarkMap
Hey everyone!

I'll keep it short..

I made a simple script for a system, which will let players mark a position on the map and transmit this to the server ("transmit" ...).

As I was bored, I created an include of this.

I wondered that nobody did (or released) something like this, since it's very very simple and easy to to.





This is the function for setting a player ready to mark:

Код:
SetPlayerMarkingMap(playerid,MarkID);
playerid - Should be clear.
MarkID - A number used later to know, for what the position should be used.

And this is the callback which gets called when a player marked:

Код:
public OnPlayerMarkMap(playerid, MarkID, Float:X, Float:Y, Float:Z)
{
}
playerid - ...
MarkID - This variable is filled with the number given in SetPlayerMarkingMap().
X, Y, Z - The coords of the marked position

How does this work exactly?!

It's is very simple:

First, you get frozen. Then you have to go to the Map (ESC->Map) and right click anywhere.
If you go back to the game, you'll see you get teleported to the selected position and this is the way it works!
The server will notice that your position changed and save the position. Then it will teleport you back to your last position and you'll be able to move again

Then the callback above will be called!

I don't know much uses for this, but I'm sure there are some!

Installation

Very easy, first download it below, then extract the mapmark.inc into your pawno/include directory.

Then put "#include <mapmark>" into your GM/FS.

(Btw, if you want to control "AllowAdminTeleport()" by yourself, then put "#define MAPMARK_ADMINTELEPORT" ABOVE the include line. Note: AllowAdminTeleport must be turned on to make this thing work!)

Copy the callback from above to your GM/FS, and your done using it!

Download

Megaupload - Click HERE
Pastebin - Click HERE

EXAMPLE for a GPS system.

Type /gps and then select a position at the map!

Pastebin - http://pastebin.com/8e3sWpYJ


I hope you'll find it useful!



Regards,
NaS


Re: OnPlayerMarkMap - Generation-X - 11.09.2011

Well done!

Pastebin Link?


AW: OnPlayerMarkMap - NaS - 11.09.2011

Thanks

Pastebin added


Re: OnPlayerMarkMap - PotH3Ad - 11.09.2011

Nice


Re: OnPlayerMarkMap - wups - 11.09.2011

This is unfinished. You should do:
pawn Код:
#define IsPlayerEsc(%0) (PlayerTick[%0]+600 < GetTickCount())
public OnPlayerUpdate(playerid)
{
    PlayerTick[playerid]=GetTickCount();
    return 1;
}
public SomeCheck() // every 200ms or so.
{
    foreach(Player, i)
    {
        if(IsPlayerEsc(i)
        {
            if(mapWaiting[playerid] == -1)
            {
                SetPlayerMarkingMap(playerid,MarkID);
            }
        }
        else
        {
            if(mapWaiting[playerid] != -1)
            {
                mapWaiting[playerid] == -1;
            }
        }
    }
}
I didn't understand why MarkID is needed.


AW: OnPlayerMarkMap - NaS - 11.09.2011

Okay let's say, you have 2 situations you need to get a poistion marked on the map..
In one situation you set MarkID to 1, and in the other to 2 or something.

Then in OnPlayerMarkMap you can check if it's 1 or 2, then do something different for 1 as for 2.

Example:

MarkID 1 is an admin command for setting someones position to a position marked on the map.

And MarkID 2 is for creating a MapIcon, like in my SA-MP Ingame Editor.


Re: OnPlayerMarkMap - TheArcher - 11.09.2011

Yes, i saw this on few servers. Good job.


Re: OnPlayerMarkMap - =WoR=G4M3Ov3r - 11.09.2011

Nice work


Re : OnPlayerMarkMap - Naruto_Emilio - 11.09.2011

Good job on this .


AW: OnPlayerMarkMap - NaS - 11.09.2011

Thanks

I didn't see it anywhere before
But I thought this could be useful, as in my Ingame Editor.


Re: OnPlayerMarkMap - Kaperstone - 11.09.2011

nice
can you make :
pawn Код:
native GetPlayerMarkedPlace(playerid,Float:X,Float:Y);
native SetPlayerMarkPlace(playerid,Float:X,FloatY); // would be good as GPS or somthing like that :)
native SetMarkColour(markid); // i dont know if its possible xD
will be good


AW: OnPlayerMarkMap - NaS - 11.09.2011

This makes no sense for this, since it not a real system to detect where the player marked the map, just a little trick for it..

For the GPS thing you could do (I will do a complete example for it tomorrow):

Код:
//Top of the script:

new GPSx[MAX_PLAYERS];
new GPSy[MAX_PLAYERS];
new GPSz[MAX_PLAYERS];
new bool:GPSon[MAX_PLAYERS];

//command /gps:

SetPlayerMarkingMap(playerid,1);

// In the callback:

if(MarkID == 1)
{
GPSx[playerid] = X;
GPSy[playerid] = Y;
GPSz[playerid] = Z; // Not really needed...
GPSon[playerid] = true;
}

// Then create a timer which checks the distance etc.... and turns off if the destination is reached
I think you didn't really understand the sense for this...

GetPlayerMarkedPlace could be done, but isn't really needed because of the callback.


Re: AW: OnPlayerMarkMap - Kaperstone - 11.09.2011

Quote:
Originally Posted by NaS
Посмотреть сообщение
This makes no sense for this, since it not a real system to detect where the player marked the map, just a little trick for it..

For the GPS thing you could do:

Код:
//Top of the script:

new GPSx[MAX_PLAYERS];
new GPSy[MAX_PLAYERS];
new GPSz[MAX_PLAYERS];
new bool:GPSon[MAX_PLAYERS];

//command /gps:

SetPlayerMarkingMap(playerid,1);

// In the callback:

if(MarkID == 1)
{
GPSx[playerid] = X;
GPSy[playerid] = Y;
GPSz[playerid] = Z; // Not really needed...
GPSon[playerid] = true;
}

// Then create a timer which checks the distance etc.... and turns off if the destination is reached
I think you didn't really understand the sense for this...

GetPlayerMarkedPlace could be done, but isn't really needed because of the callback.
for what your using GPSz? GPSz is useless because it showing only on the map,and not in-game.
and ok,thanks


AW: OnPlayerMarkMap - NaS - 11.09.2011

This why I put the comment behind

No problem, I'm currently making an example for a few uses..

EDIT: Added an example for the GPS system!


Re: OnPlayerMarkMap - Kar - 11.09.2011

No Offense, but what the fuck is this?

if(GDBP(mapLastX[playerid], mapLastY[playerid], mapLastZ[playerid],X,Y,Z) > 5)

that doesn't mean a player marked on the map??.....


Re: OnPlayerMarkMap - wups - 11.09.2011

Quote:
Originally Posted by Kar
Посмотреть сообщение
No Offense, but what the fuck is this?

if(GDBP(mapLastX[playerid], mapLastY[playerid], mapLastZ[playerid],X,Y,Z) > 5)

that doesn't mean a player marked on the map??.....
This is getdistancebetweenpoints. I don't know why is he using this, because theres IsPlayerInRangeOfPoint native.
And do my suggestion, since now you can only check for teleproting WHEN the script KNOWS that.


AW: OnPlayerMarkMap - zaq.selfown - 12.09.2011

and this is the sense lol
The player should not be allowed to teleport all the time


AW: OnPlayerMarkMap - NaS - 12.09.2011

wups, the sense of this IS that the script knows that, otherwise there is no need for "SetPlayerMarkingMap" ...

Sure, the native would be better.. But you can edit this yourself..