[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


Messages In This Thread
Admin /mark and /gotomark Command - by Sid_Alexander - 06.01.2015, 17:49
Re: Admin /mark and /gotomark Command - by Schneider - 06.01.2015, 18:14
Re: Admin /mark and /gotomark Command - by Sid_Alexander - 06.01.2015, 18:17
Re: Admin /mark and /gotomark Command - by TheRaGeLord - 08.01.2015, 14:03
Re: Admin /mark and /gotomark Command - by Sid_Alexander - 09.01.2015, 10:28

Forum Jump:


Users browsing this thread: 3 Guest(s)