/goto playerid
#1

Hello!
is it possible to a command /goto playerid ,in that normal players can do this cmd .First /enablegoto id then only a player can teleport to other player.Is it possible? if yes then plz help me
Thank you..
Reply
#2

You mean player can only teleport to another player that do /enablegoto?
Reply
#3

yes it is
Reply
#4

You need a true or false value for each player. This can be done by the following array:
pawn Код:
new GoToEnabled[MAX_PLAYERS];
This basically is disabling it for all players, because its default value is 0.

Next you need a allow-goto command that would set that to 1. I suggest you do a toggle for 1 command.. meaning, if its 1, set it to 0 (disabling it) or if its 0, set it to 1. be sure to use an If Else statement for that, otherwise it might falsely set it back to 0, or 1 depending on the order you choose.

Lastly, you need a teleport command that checks if the target players GoToEnabled value is 1, and if they are spawned using GetPlayerState. if so, teleport them, if not, display a message how that person has not enabled their allow-goto ability.

Now be sure that OnPlayerConnect or OnPlayerDisconnect you set their value back to 0, so the new player can decide on their own if they want to or not.

Hope this helps, it contains all the mechanics. By default, every player will be disabled unless you set all 500 slots of that array to 1.
Reply
#5

can you give me the full code ?
Reply
#6

PHP код:
new GoToEnabled[MAX_PLAYERS];
GoToEnabled[playerid] = 0// OnPlayerConnect
YCMD:enablegoto(playerido[], help)
{
    
#pragma unused help
    #pragma unused o
    
if(GoToEnabled[playerid] == 0)
    {
        
GoToEnabled[playerid] = 1;
        
SendClientMessage(playerid, -1,"You have enabled the goto command");
    }
    else
    {
        
GoToEnabled[playerid] = 0;
        
SendClientMessage(playerid, -1,"You have disabled the goto command");
    }
    return 
1;
}
YCMD:goto(playerido[], help)
{
    
#pragma unused help
    
new pID;
    if(
sscanf(o,"u"pID)) return SendClientMessage(playerid, -1,"Syntax error.Correct usage: /goto [PlayerID/Name]");
    if(
pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1,"That player is not connected");
    if(
GoToEnabled[pID] == 0) return SendClientMessage(playerid, -1,"That player has disabled the goto command");
    new 
Float:xFloat:yFloat:z;
    
GetPlayerPos(pIDxyz);
    
SetPlayerPos(playeridx+1y+1z);
    return 
1;

Reply
#7

pawn Код:
new bool:TP[MAX_PLAYERS];

CMD:enablegoto(playerid,params[])
{
    TP[playerid] = true;
    return 1;
}

CMD:goto(playerid,params[])
{
    if(!IsPlayerConnected(strval(params))) return 0;
    if(!TP[strval(params)]) return 0;
    new Float:Pos[3];
    GetPlayerPos(strval(params),Pos[0],Pos[1],Pos[2]);
    SetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
    return 1;
}
Reply
#8

ok guys ty
Reply
#9

Quote:
Originally Posted by Millionaire
Посмотреть сообщение
ok guys ty
I like varthshenons, however, if they enable it at class select menu, you will be able to teleport to them while they choose their skin.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)