Need a /goto command...
#1

Hi, I need a /goto [playerid] command for my gamemode, complete with everything. Can get one?
Reply
#2

pawn Код:
YCMD:goto(playerid, o[], 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");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(pID, x, y, z);
    SetPlayerPos(playerid, x+1, y+1, z);
    return 1;
}
Notice: this is using YCMD and sscanf2
Reply
#3

Next time, you can use the search function ...
Reply
#4

Search.
There are lots of threads like this.
Not to mention the admin systems which contain the command you want.
Reply
#5

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
pawn Код:
YCMD:goto(playerid, o[], 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");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(pID, x, y, z);
    SetPlayerPos(playerid, x+1, y+1, z);
    return 1;
}
Notice: this is using YCMD and sscanf2
You can't just assume people are using/have the ZCMD/YCMD/DCMD and sscanf includes ...
Reply
#6

sorry i tryed, get me error the pawno, can make one with normal string if (strcmp("/mycommand", cmdtext, true, 10) == 0)?
this the error:
Код:
C:\Users\User\Desktop\ServerMacros\gamemodes\MacrosGM.pwn(1832) : error 020: invalid symbol name ""
C:\Users\User\Desktop\ServerMacros\gamemodes\MacrosGM.pwn(1832) : warning 215: expression has no effect
C:\Users\User\Desktop\ServerMacros\gamemodes\MacrosGM.pwn(1832) : error 017: undefined symbol "o"
C:\Users\User\Desktop\ServerMacros\gamemodes\MacrosGM.pwn(1832) : error 029: invalid expression, assumed zero
C:\Users\User\Desktop\ServerMacros\gamemodes\MacrosGM.pwn(1832) : fatal error 107: too many error messages on one line
Reply
#7

Place under OnPlayerCommandText:

pawn Код:
if(strcmp(cmd, "/goto", true, 5) == 0 && IsPlayerAdmin(playerid))
{
    new giveplayerid, tmp[256], idx, string[128];
   
    tmp = strtok(cmdtext, idx);
    giveplayerid = strval(tmp);
   
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /goto [id]");
    if(!IsNumeric(tmp)) return SendClientMessage(playerid, -1, "USAGE: /goto [id] - ID Must Be A Number.");

    if(IsPlayerConnected(giveplayerid))
    {
        SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
       
        new Float:x, Float:y, Float:z;
        GetPlayerPos(giveplayerid, x,y,z);
        SetPlayerPos(playerid, x+1,y,z);
    }
    else
    {
        format(string, sizeof(string), "%d Is Not An Active Player.", giveplayerid);
        SendClientMessage(playerid, -1, string);
    }
    return 1;
}
Reply
#8

best way:
pawn Код:
#include <zcmd>

CMD:goto(playerid, params[])
{
    new
        id;
    if(sscanf(params,"r",id)) {
        if(IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_LIGHTRED, "[MM] this player id is not connected!");
        new Float:X,Float:Y,Float:Z,Float:Angle;
        new message[40];
        GetPlayerPos(id, X, Y, Z);
        GetPlayerFacingAngle(playerid, Angle);
        SetPlayerPos(playerid, X, Y, Z);
        SetPlayerFacingAngle(playerid, Angle);
        format(message, sizeof(message), "[MM] You have teleported to %d", id);
        SendClientMessage(playerid, COLOR_GREEN, message);
        format(message, sizeof(message), "[MM] %d has been teleported to you", playerid);
        SendClientMessage(playerid, COLOR_GREEN, message);
    }
    else {
        SendClientMessage(playerid, COLOR_LIGHTRED,"[MM] USAGE: /goto [playerid]");
    }
    return 1;
}
Reply
#9

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
You can't just assume people are using/have the ZCMD/YCMD/DCMD and sscanf includes ...
Probably thats why there reads "NOTE: This uses YCMD & sscanf2 ?
Reply
#10

Quote:
Originally Posted by xkirill
Посмотреть сообщение
best way:
pawn Код:
#include <zcmd>

CMD:goto(playerid, params[])
{
    new
        id;
    if(sscanf(params,"r",id)) {
        if(IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_LIGHTRED, "[MM] this player id is not connected!");
        new Float:X,Float:Y,Float:Z,Float:Angle;
        new message[40];
        GetPlayerPos(id, X, Y, Z);
        GetPlayerFacingAngle(playerid, Angle);
        SetPlayerPos(playerid, X, Y, Z);
        SetPlayerFacingAngle(playerid, Angle);
        format(message, sizeof(message), "[MM] You have teleported to %d", id);
        SendClientMessage(playerid, COLOR_GREEN, message);
        format(message, sizeof(message), "[MM] %d has been teleported to you", playerid);
        SendClientMessage(playerid, COLOR_GREEN, message);
    }
    else {
        SendClientMessage(playerid, COLOR_LIGHTRED,"[MM] USAGE: /goto [playerid]");
    }
    return 1;
}
That one is using sscsanf. You didn't included that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)