[Include] OnPlayerMarkMap
#1

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
Reply
#2

Well done!

Pastebin Link?
Reply
#3

Thanks

Pastebin added
Reply
#4

Nice
Reply
#5

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

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

Yes, i saw this on few servers. Good job.
Reply
#8

Nice work
Reply
#9

Good job on this .
Reply
#10

Thanks

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

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
Reply
#12

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

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
Reply
#14

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!
Reply
#15

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??.....
Reply
#16

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

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)