[Tutorial] Admin /mark and /gotomark Command
#1

Hello guys, I was just making this little function for my script and thought of sharing it, As many people out there may find it useful, Tell me if you like it, And Rep only if you think it's worth your time.

For this you'll need zcmd.
pawn Код:
#include <zcmd> //including the inc file.
assign these variables on top.
pawn Код:
new Float:PosX[MAX_PLAYERS], Float:PosY[MAX_PLAYERS], Float:PosZ[MAX_PLAYERS];
new AInterior[MAX_PLAYERS];
new Marked[MAX_PLAYERS];
Marking Position
pawn Код:
CMD:mark(playerid, params[]) // the actual command.
    {
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "[You are not an admin]"); // return false if the player is not an admin - change it with your own variable.
        new Float:X, Float:Y, Float:Z; //variable to find player's X Y Z position.
        GetPlayerPos(playerid, X, Y, Z); // Getting the player's X Y Z position.
        PosX[playerid] = X; //assigning the players position we got to a different player variable.
        PosY[playerid] = Y; //assigning the players position we got to a different player variable.
        PosZ[playerid] = Z; //assigning the players position we got to a different player variable.
        AInterior[playerid] = GetPlayerInterior(playerid); //Assigning players current interior to the variable.
        Marked[playerid] = 1; //The Player Has marked his position. [0 = false, 1 = true]
        SendClientMessage(playerid, -1, "You've marked your position here."); //send him the confirmation message
        return 1;
        }
Going to the mark
pawn Код:
CMD:gotomark(playerid, params[]) //the actual command
    {
        if(PlayerInfo[playerid][pAdmin] <1) return SendClientMessage(playerid, -1, "[You are not an admin]"); // return to false if not an admin
        if(Marked[playerid] == 0) return SendClientMessage(playerid, -1, "You haven't marked the position."); // if marked value is 0[false] return false with the message that he hasn't marked the position yet to avoid teleporting to an invalid position
        SetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]); //set the players position co-ordinates to those we collected from /mark and assigned to player position variables.
        SetPlayerInterior(playerid, AInterior[playerid]); //set the players interior to where he marked
        SetPlayerVirtualWorld(playerid, 0); //set the virtual world to 0
        SendClientMessage(playerid, -1, "Teleported to marked position."); // send the confirmation message
        return 1;
        }
Thank you.
Reply
#2

Good!
Here's a little tip to make it a bit more efficient:

This is what you currently have:
pawn Код:
new Float:X, Float:Y, Float:Z; //variable to find player's X Y Z position.
GetPlayerPos(playerid, X, Y, Z); // Getting the player's X Y Z position.
PosX[playerid] = X; //assigning the players position we got to a different player variable.
PosY[playerid] = Y; //assigning the players position we got to a different player variable.
PosZ[playerid] = Z; //assigning the players position we got to a different player variable.
But you don't need to create all these extra variables because you can store them in the players' variables right away:
pawn Код:
GetPlayerPos(playerid, PosX[playerid], PosY[playerid], PosZ[playerid]);
Reply
#3

Thanks for the tip, Do you want me to change it?
Reply
#4

Lil' And Nice Tutorial.. I Like it
Reply
#5

Quote:
Originally Posted by TheRaGeLord
Посмотреть сообщение
Lil' And Nice Tutorial.. I Like it
Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)