how to add teleports
#1

how can i add teleports in my server
Reply
#2

omg.

a simple teleport command is like that
under OnPlayerCommandText
pawn Код:
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        SetPlayerPos(playerid, //PUT HERE THE PLAYER POSITION);
        SendClientMessage (playerid, //COLOR , "//MESSAGE");
        return 1;
    }


    }
    return 0;
}
https://sampforum.blast.hk/showthread.php?tid=97349
SEARCH BEFORE POSTING
Reply
#3

Here is a basic teleport command from player to player.

pawn Код:
CMD:tp(playerid,params[])
{
    new pid,id,Float:x,Float:y,Float:z,name[MAX_PLAYER_NAME],pname[MAX_PLAYER_NAME];
    if(sscanf(params,"uu",pid,id)) return SendClientMessage(playerid,-1,"USAGE: /tp [playerid] [playerid]");
    GetPlayerPos(id,x,y,z);
    SetPlayerPos(pid,x,y,z);
    GetPlayerName(pid,name,sizeof(name));
    GetPlayerName(id,pname,sizeof(pname));
    format(string,sizeof(string),"You've teleported %s to %s",name,pname);
    SendClientMessage(playerid,0xFF0000AA,string);
}
Reply
#4

i have to get save position to debug or my samp server
Reply
#5

type /save in game to save your position
Reply
#6

ok thanks r u muslim i am muslim
Reply
#7

Yes.
Reply
#8

if you want teleport to place:
Quote:

CMD:goto(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= /*put here admin level*/) // this if you want it only admins can teleport..
{
{
SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
return 1;
}
if(isnull(params))
{
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goto [location]");
SendClientMessage(playerid, COLOR_GRAD1, "Locations: location1 , location2");
return 1;
}
if(strcmp(params,"put here after /goto [text/location name you want]",true) == 0)
{
if(GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, // put here the positian that you want to go to [this because if you driving vehicle. to teleport with you]);
LinkVehicleToInterior(tmpcar, TeleportDestInt2[playerid]);
}
else
{
SetPlayerPos(playerid, // put here the positian that you want to go to);
}
SetPlayerInterior(playerid,TeleportDestInt2[playerid]);
PlayerInfo[playerid][pInt] = TeleportDestInt2[playerid];
SendClientMessage(playerid, COLOR_WHITE, "Your message after teleport.");
}
else if(strcmp(params,"put here after /goto [text/location name you want]",true) == 0)
{
if(GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, // put here the positian that you want to go to [this because if you driving vehicle. to teleport with you]);
LinkVehicleToInterior(tmpcar, 0);
SetVehicleVirtualWorld(tmpcar, 0);
TelePos[playerid][0] = 0.0;TelePos[playerid][0] = 0.0;
fVehSpeed[playerid] = 0.0;
}
else
{
SetPlayerPos(playerid, // put here the positian that you want to go to);
}
SendClientMessage(playerid, COLOR_WHITE, "// your messge after teleport.");
SetPlayerInterior(playerid,0);
PlayerInfo[playerid][pInt] = 0;
SetPlayerVirtualWorld(playerid, 0);
PlayerInfo[playerid][pVW] = 0;
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
}
return 1;
}

and this to teleport to player/id:
Quote:

CMD:gotoid(playerid, params[])
{
new giveplayerid;

if(sscanf(params, "u", giveplayerid))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /gotoid [playerid/partofname]");

new Floatlocx,Floatlocy,Floatlocz;
if(IsPlayerConnected(giveplayerid))
{
if(PlayerInfo[playerid][pAdmin] >= 2) //if you want admins only teleport to any player
{
return 1;
}
if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
{
SendClientMessage(playerid, COLOR_GRAD2, "That player is spectating someone.");
return 1;
}
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
{
SendClientMessage(playerid, COLOR_GRAD2, "You can't do this while spectating.");
return 1;
}
GetPlayerPos(giveplayerid, plocx, plocy, plocz);
Streamer_UpdateEx(playerid, plocx, plocy, plocz);

if(GetPlayerState(playerid) == 2)
{
new tmpcar = GetPlayerVehicleID(playerid);
SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
fVehSpeed[playerid] = 0.0;
}
else
{
SetPlayerPos(playerid,plocx,plocy+2, plocz);
}

SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
new giveplayeridvw = GetPlayerVirtualWorld(giveplayerid);
new giveplayerint = GetPlayerInterior(giveplayerid);
PlayerInfo[playerid][pVW] = giveplayeridvw;
PlayerInfo[playerid][pInt] = giveplayerint;

SendClientMessage(playerid, COLOR_WHITE, "You have been teleported!");
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
}

}
else SendClientMessage(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

and this to teleport and player/id to you:
Quote:

CMD:gethere(playerid, params[])
{
new giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gethere [playerid]");

new Floatlocx,Floatlocy,Floatlocz;
if (IsPlayerConnected(giveplayerid))
if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin])
{
SendClientMessageEx(playerid, COLOR_WHITE, "You can't perform this action on an equal or higher level administrator.");
return 1;
}
if (PlayerInfo[playerid][pAdmin] >= 2) // if you want it admins only can use it
{
if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
{
SendClientMessageEx(playerid, COLOR_GRAD2, "That player is spectating someone.");
return 1;
}
GetPlayerPos(playerid, plocx, plocy, plocz);
Streamer_UpdateEx(giveplayerid, plocx, plocy, plocz);
SetPVarInt(playerid, "BeingTeleported", 1);
SetPlayerVirtualWorld(giveplayerid, PlayerInfo[playerid][pVW]);

PlayerInfo[giveplayerid][pLocal] = PlayerInfo[playerid][pLocal];

if (GetPlayerState(giveplayerid) == 2)
{
TelePos[giveplayerid][0] = 0.0;
TelePos[giveplayerid][1] = 0.0;
new tmpcar = GetPlayerVehicleID(giveplayerid);
SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
LinkVehicleToInterior(GetPlayerVehicleID(giveplaye rid), GetPlayerInterior(playerid));
SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
SetVehicleVirtualWorld(GetPlayerVehicleID(giveplay erid), GetPlayerVirtualWorld(playerid));
SetPlayerVirtualWorld(giveplayerid, GetPlayerVirtualWorld(playerid));
}
else
{
SetPlayerPos(giveplayerid,plocx,plocy+2, plocz);
SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
SetPlayerVirtualWorld(giveplayerid, GetPlayerVirtualWorld(playerid));
}
GameTextForPlayer(playerid, "~w~Teleporting", 5000, 1);
SendClientMessageEx(giveplayerid, COLOR_GRAD1, " You have been teleported to the admin!");
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
}

}
else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
return 1;
}

if it helped you please +Rep me. thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)