/goto only goes to id 0
#1

when an admin types /goto it only teleports them to ID 0, even if you just type /goto, if somebody could show me what i'v done wrong it would be much appericated.
pawn Код:
COMMAND:goto(playerid, params[])
{
    if(GetPlayerAdmin(playerid) < 1) return SendBlockedAdminCommand(playerid, 1);
    new
        toid,
        Float:ox,
        Float:oy,
        Float:oz;
    if (sscanf(params, "uF(1.5)F(0.0)F(0.0)", toid, ox, oy, oz)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /goto PLAYERID [X_OFFSET [Y_OFFSET [Z_OFFSET]]]");
    if (toid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]:That player is not connected.");
    new
        Float:x,
        Float:y,
        Float:z;
    GetPlayerPos(toid, x, y, z);
    SetPlayerInterior(playerid, GetPlayerInterior(toid));
    SetPlayerPos(playerid, x + ox, y + oy, z + oz);
    new
        str[38 + 10 + MAX_PLAYER_NAME + 1];
    GetPlayerName(toid, str, MAX_PLAYER_NAME);
    format(str, sizeof (str), "Teleported to %s(%d).", str, toid);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    return 1;
}
Reply
#2

Are you using 0.3c? The 'u' parameter doesn't work in any 0.3 RC except 0.3 RC4-2.
Reply
#3

why the hell you did it this way?
replace:
pawn Код:
COMMAND:goto(playerid, params[])
{
    if(GetPlayerAdmin(playerid) < 1) return SendBlockedAdminCommand(playerid, 1);
    if (sscanf(params, "i",toid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /goto PLAYERID");
    if (toid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]:That player is not connected.");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(toid, x, y, z);
    SetPlayerPos(playerid, x, y, z);
    SetPlayerInterior(playerid, GetPlayerInterior(toid));
    SetPlayerVirtualWorld(playerid,GetPlayerVitrualWorld(toid));
    new str[128],pn[MAX_PLAYER_NAME];
    GetPlayerName(toid, pn, MAX_PLAYER_NAME);
    format(str, sizeof (str), "Teleported to %s(%d).",pn, toid);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    return 1;
}
Reply
#4

Quote:
Originally Posted by XePloiT
Посмотреть сообщение
why the hell you did it this way?
replace:
Maybe because he wants the admin to set the teleport offset from the player just in case the player is in a monster truck or something?
Reply
#5

ok then... but he still complicated it...
Correction:
pawn Код:
COMMAND:goto(playerid, params[])
{
    if(GetPlayerAdmin(playerid) < 1) return SendBlockedAdminCommand(playerid, 1);
    if (sscanf(params, "i",toid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /goto PLAYERID");
    if (toid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]:That player is not connected.");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(toid, x, y, z);
    SetPlayerPos(playerid, x+2, y+3, z); // WOW +2 and +3!!!!... -_-"
    SetPlayerInterior(playerid, GetPlayerInterior(toid));
    SetPlayerVirtualWorld(playerid,GetPlayerVitrualWorld(toid));
    new str[128],pn[MAX_PLAYER_NAME];
    GetPlayerName(toid, pn, MAX_PLAYER_NAME);
    format(str, sizeof (str), "Teleported to %s(%d).",pn, toid);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    return 1;
}
EDIT: anyway... if you want to keep your code
replace this:
pawn Код:
if (sscanf(params, "ifff", toid, ox, oy, oz))
Reply
#6

Tryed a couple of things but couldn't manage to fix it, any ideas?

errors:
pawn Код:
./OnPlayerCommand.pwn(182) : error 017: undefined symbol "toid"
./OnPlayerCommand.pwn(183) : error 017: undefined symbol "toid"
./OnPlayerCommand.pwn(185) : error 017: undefined symbol "toid"
./OnPlayerCommand.pwn(187) : error 017: undefined symbol "toid"
./OnPlayerCommand.pwn(188) : error 017: undefined symbol "GetPlayerVitrualWorld"
./OnPlayerCommand.pwn(190) : error 017: undefined symbol "toid"
./OnPlayerCommand.pwn(191) : error 017: undefined symbol "toid"
Reply
#7

Correction: this is suppose to work
pawn Код:
COMMAND:goto(playerid, params[])
{
    if(GetPlayerAdmin(playerid) < 1) return SendBlockedAdminCommand(playerid, 1);
    new toid;
    if (sscanf(params, "i",toid)) return SendClientMessage(playerid, COLOR_RED, "[USAGE]: /goto PLAYERID");
    if (toid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "[ERROR]:That player is not connected.");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(toid, x, y, z);
    SetPlayerPos(playerid, x+2, y+3, z); // WOW +2 and +3!!!!... -_-"
    SetPlayerInterior(playerid, GetPlayerInterior(toid));
    SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(toid));
    new str[128],pn[MAX_PLAYER_NAME];
    GetPlayerName(toid, pn, MAX_PLAYER_NAME);
    format(str, sizeof (str), "Teleported to %s(%d).",pn, toid);
    SendClientMessage(playerid, COLOR_YELLOW, str);
    return 1;
}
Reply
#8

Cheers XePloiT, thanks for the help.
Reply
#9

no prob... enjoy :]
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)