I need some help with a goto command and gethere
#1

ive been searching hours with my freind, and we just cant seem to get this command.

We are looking for a /goto command and a /gethere command using DCMD.

This is for an admin script so the if player is an a admin looks like this.

Code:
if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"You need to be level 2 to use this command!");
Reply
#2

pawn Code:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

dcmd_goto(playerid, params[])
{
    if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"You need to be level 2 to use this command!");
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /Goto < Player ID >");

    new
        pID = strval(params),
        Float: iPos[3];

    GetPlayerPos(pID, iPos[0], iPos[1], iPos[2]);
    SetPlayerPos(playerid, iPos[0], iPos[1], iPos[2] + 3);

    new
        iStr[50],
        pIDN[24];

    GetPlayerName(pID, pIDN, sizeof(pIDN));

    format(iStr, sizeof(iStr), "You've teleported to: %s", pIDN);
    return SendClientMessage(playerid, -1, iStr);
}

dcmd_gethere(playerid, params[])
{
    if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"You need to be level 2 to use this command!");
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /Gethere < Player ID >");
   
    new
        pID = strval(params),
        Float: iPos[3];

    GetPlayerPos(playerid, iPos[0], iPos[1], iPos[2]);
    SetPlayerPos(pID, iPos[0], iPos[1], iPos[2] + 3);
   
    new
        iStr[50],
        pIDN[24];

    GetPlayerName(pID, pIDN, sizeof(pIDN));

    format(iStr, sizeof(iStr), "You've teleported: %s to you", pIDN);
    return SendClientMessage(playerid, -1, iStr);
}
Reply
#3

Quote:
Originally Posted by [L3th4l]
View Post
pawn Code:
#if !defined isnull
    #define isnull(%1) \
                ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1]))))
#endif

dcmd_goto(playerid, params[])
{
    if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"You need to be level 2 to use this command!");
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /Goto < Player ID >");

    new
        pID = strval(params),
        Float: iPos[3];

    GetPlayerPos(pID, iPos[0], iPos[1], iPos[2]);
    SetPlayerPos(playerid, iPos[0], iPos[1], iPos[2] + 3);

    new
        iStr[50],
        pIDN[24];

    GetPlayerName(pID, pIDN, sizeof(pIDN));

    format(iStr, sizeof(iStr), "You've teleported to: %s", pIDN);
    return SendClientMessage(playerid, -1, iStr);
}

dcmd_gethere(playerid, params[])
{
    if(PInfo[playerid][Level] < 2) return SendClientMessage(playerid,COLOR_RED,"You need to be level 2 to use this command!");
    if(isnull(params)) return SendClientMessage(playerid, -1, "Usage: /Gethere < Player ID >");
   
    new
        pID = strval(params),
        Float: iPos[3];

    GetPlayerPos(playerid, iPos[0], iPos[1], iPos[2]);
    SetPlayerPos(pID, iPos[0], iPos[1], iPos[2] + 3);
   
    new
        iStr[50],
        pIDN[24];

    GetPlayerName(pID, pIDN, sizeof(pIDN));

    format(iStr, sizeof(iStr), "You've teleported: %s to you", pIDN);
    return SendClientMessage(playerid, -1, iStr);
}
Unkown Command
Reply
#4

try this:
Code:
dcmd_goto(playerid, params[])
{
    if(PlayerInfo[playerid][AdminLevel] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not authorized to use that command!");
    {
        new targetid;
        if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /goto [playerid | name]");
        else if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, 0xFFFFFFAA, "That player is not connected");
        {
            new Float:PosX, Float:PosY, Float:PosZ;
            GetPlayerPos(targetid, PosX, PosY, PosZ);
            SetPlayerPos(playerid, PosX, PosY, PosZ);
            SetPlayerInterior(playerid, GetPlayerInterior(targetid));
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(targetid));
        }
    }
    return 1;
}
you need dcmd and sscanf
Reply
#5

For every command i have Goto or Gethere it sends back UNkown Server command
Reply
#6

Did you forget to add
Code:
dcmd(goto,4,cmdtext);
to the OnPlayerCommandText?
Reply
#7

Quote:
Originally Posted by coole210
View Post
Did you forget to add
Code:
dcmd(goto,4,cmdtext);
to the OnPlayerCommandText?
Of course not
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)