Help with map teleporting
#1

Can somone please try to help me with this, I started it and cant figure it out...

Код:
#include <zcmd>

new Float: teleportCoordinates[MAX_PLAYERS][3], hasSetTeleport[MAX_PLAYERS];
{


    	hasSetTeleport[playerid] = 0;

    return 1;

}

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(IsPlayerAdmin(playerid))
    {
        teleportCoordinates[playerid][0] = fX, teleportCoordinates[playerid][1] = fY, teleportCoordinates[playerid][2] = fZ;
        hasSetTeleport[playerid] = 1;
    }
    return 1;
}

COMMAND:maptp(playerid, params[])
{
    if(!IsPlayerAdmin(playerid) || !hasSetTeleport[playerid]) return 1;
    SetPlayerPos(playerid, teleportCoordinates[playerid][0], teleportCoordinates[playerid][1], teleportCoordinates[playerid][2]);
    return 1;
}
Reply
#2

pawn Код:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>
#include <zcmd>

// DEFINES:

// FUNCTIONS:

#define function%0(%1) forward%0(%1); public%0(%1)

// PER-PLAYER VARIABLES:

// GENERAL:

new Float:pMapTeleport[MAX_PLAYERS][3];

// PLAYER STATES:

new bool:sMapTeleport[MAX_PLAYERS];

// MAIN:

main()
{
    print("Development Mode: map_teleport.amx");
}

// CALLBACKS:

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(IsPlayerAdmin(playerid))
    {
        if(!ClickedOnMap(playerid))
        {
            pMapTeleport[playerid][0] = fX;
            pMapTeleport[playerid][1] = fY;
            pMapTeleport[playerid][2] = fZ;
            sMapTeleport[playerid] = true;
        }
        else
        {
            pMapTeleport[playerid][0] = 0.0;
            pMapTeleport[playerid][1] = 0.0;
            pMapTeleport[playerid][2] = 0.0;
            sMapTeleport[playerid] = false;
        }
    }
    return 1;
}

// COMMANDS:

CMD:maptp(playerid, params[])
{
    if(!ClickedOnMap(playerid)) return SendClientMessage(playerid, -1, "You haven't marked a position on the map yet.");

    SetPlayerPos(playerid, pMapTeleport[playerid][0], pMapTeleport[playerid][1], pMapTeleport[playerid][2]);
    SetCameraBehindPlayer(playerid);
    return 1;
}

// FUNCTIONS:

function bool:ClickedOnMap(playerid) return sMapTeleport[playerid];
Reply
#3

error 021: symbol already defined: "main"
error 021: symbol already defined: "zcmd_OnGameModeInit"
error 021: symbol already defined: "OnGameModeExit"
error 021: symbol already defined: "OnPlayerClickMap"
Reply
#4

Quote:
Originally Posted by ChromeMenu
Посмотреть сообщение
error 021: symbol already defined: "main"
error 021: symbol already defined: "zcmd_OnGameModeInit"
error 021: symbol already defined: "OnGameModeExit"
error 021: symbol already defined: "OnPlayerClickMap"
It isn't a copy/paste script. It's a fully working gamemode, don't just add it to your gamemode. Either way, those errors are self-explanatory.
Reply
#5

It just says you havent marked a position on the map yet. doesnt teleport me
Reply
#6

Quote:
Originally Posted by ChromeMenu
Посмотреть сообщение
It just says you havent marked a position on the map yet. doesnt teleport me
You are suppose to log into RCON.

Anyway, otherwise:

pawn Код:
// [ DEVELOPMENT GAMEMODE ]

// INCLUDES:

#include <a_samp>
#include <zcmd>

// DEFINES:

// FUNCTIONS:

#define function%0(%1) forward%0(%1); public%0(%1)

// PER-PLAYER VARIABLES:

// GENERAL:

new Float:pMapTeleport[MAX_PLAYERS][3];

// PLAYER STATES:

new bool:sMapTeleport[MAX_PLAYERS];

// MAIN:

main()
{
    print("Development Mode: map_teleport.amx");
}

// CALLBACKS:

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    if(!ClickedOnMap(playerid)) sMapTeleport[playerid] = true;

    pMapTeleport[playerid][0] = fX;
    pMapTeleport[playerid][1] = fY;
    pMapTeleport[playerid][2] = fZ;
    return 1;
}

// COMMANDS:

CMD:maptp(playerid, params[])
{
    if(!ClickedOnMap(playerid)) return SendClientMessage(playerid, -1, "You haven't marked a position on the map yet.");

    SetPlayerPos(playerid, pMapTeleport[playerid][0], pMapTeleport[playerid][1], pMapTeleport[playerid][2]);
    SetCameraBehindPlayer(playerid);
    return 1;
}

// FUNCTIONS:

function bool:ClickedOnMap(playerid) return sMapTeleport[playerid];
Reply
#7

I think you'd love this, way easier..
pawn Код:
public OnPlayerClickMap(playerid, Float:fX, Float:fY, Float:fZ)
{
    //if(IsPlayerAdmin(playerid)) /*Remove the "//"s if you wanna restrict it to rcon admins*/
    SetPlayerPosFindZ(playerid, fX, fY, fZ);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)