#1

When i write /goto [id] it dosen't go to the player it goes to blueberry and then i lag and then i crash.

CODE:
pawn Код:
CMD:goto(playerid, params[])
{
    new playerb, string[128];
    new Float:Pos[3];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
//   if(!aDuty[playerid] && PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goto [playerid]");
    if(!IsPlayerLoggedIn(playerb) && !IsPlayerNPC(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(PlayerInfo[playerid][pHelper] && !PlayerInfo[playerid][pAdmin])
    {
        if(!HelpTime[playerb]) return SendClientMessage(playerid, COLOR_GREY, "This player hasn't requested any help.");
        if(hPos[playerid][0] == 0 && hPos[playerid][1] == 0 && hPos[playerid][2] == 0 && hPOS[playerid][0] == 0 && hPOS[playerid][0] == 0)
        {
            GetPlayerPos(playerid, hPos[playerid][0], hPos[playerid][1], hPos[playerid][2]);
            hPOS[playerid][0] = GetPlayerInterior(playerid);
            hPOS[playerid][1] = GetPlayerVirtualWorld(playerid);
            GetPlayerPos(playerb, Pos[0], Pos[1], Pos[2]);
            SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
            SetPlayerInterior(playerid, GetPlayerInterior(playerb));
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
            format(string, sizeof(string), " You have teleported to %s.", NORPN(playerb));
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), " %s %s has teleported to you.", RPHLN(playerid), NORPN(playerid));
            SendClientMessage(playerb, COLOR_WHITE, string);
            format(string, sizeof(string), "{FF0000}[Helper Warn]{FF6347} %s has teleported to %s.", NORPN(playerid), NORPN(playerb));
            SendHelperMessage(COLOR_LIGHTRED, 1, string);
        }
        else SendClientMessage(playerid, COLOR_GREY, "You must /goback before teleporting to another player.");
    }
    else
    {
        if(Spec[playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is spectating someone.");
        GetPlayerPos(playerb, Pos[0], Pos[1], Pos[2]);
        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            SetVehiclePos(GetPlayerVehicleID(playerid), Pos[0]+2, Pos[1]+2, Pos[2]);
        }
        else
        {
            SetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
        }
        SetPlayerInterior(playerid, GetPlayerInterior(playerb));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
        format(string, sizeof(string), " You have teleported to %s.", NORPN(playerb));
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), " Administrator %s has teleported to you.", NORPN(playerid));
        SendClientMessage(playerb, COLOR_WHITE, string);
    }
    return 1;
}
Reply
#2

If it goes to blueberry then that means you do not get that player's position. About the lag and crash I'm not sure as you should show us the command.
Reply
#3

Quote:
Originally Posted by ******
Посмотреть сообщение
And are we meant to guess your code?
This..
Reply
#4

The following would be a working /goto command using ZCMD and sscanf...:

pawn Код:
CMD:goto(playerid, params[])
{
   new giveplayerid;
   if(sscanf(params, "u", giveplayerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Correct usage: /goto [playerid/name]");
   if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFFFFF, "Player not connected.");
   new Float:x, Float:y, Float:z;
   GetPlayerPos(giveplayerid, x, y, z);
   SetPlayerPos(playerid, x, y+2, z);
   SendClientMessage(playerid, 0xFFFFFFFF, "{AFAFAF}You've been teleported to the requested ID.");
   return 1;
}
I'm not saying use it, I'm saying look how we get the player's position and then set the player's position.
Reply
#5

You crash because you didnt set +1 on pos 2 thats what makes you crash, and you dont teleport to the playerid because you took the players position and then you removed +1 again. This would work
pawn Код:
CMD:goto(playerid, params[])
{
    new playerb, string[128];
    new Float:Pos[3];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1 && PlayerInfo[playerid][pHelper] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
//   if(!aDuty[playerid] && PlayerInfo[playerid][pAdmin]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
    if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /goto [playerid]");
    if(!IsPlayerLoggedIn(playerb) && !IsPlayerNPC(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
    if(PlayerInfo[playerid][pHelper] && !PlayerInfo[playerid][pAdmin])
    {
        if(!HelpTime[playerb]) return SendClientMessage(playerid, COLOR_GREY, "This player hasn't requested any help.");
        if(hPos[playerid][0] == 0 && hPos[playerid][1] == 0 && hPos[playerid][2] == 0 && hPOS[playerid][0] == 0 && hPOS[playerid][0] == 0)
        {
            GetPlayerPos(playerid, hPos[playerid][0], hPos[playerid][1], hPos[playerid][2]);
            hPOS[playerid][0] = GetPlayerInterior(playerid);
            hPOS[playerid][1] = GetPlayerVirtualWorld(playerid);
            GetPlayerPos(playerb, Pos[0], Pos[1], Pos[2]);
            SetPlayerPos(playerid, Pos[0]+1, Pos[1], Pos[2]);
            SetPlayerInterior(playerid, GetPlayerInterior(playerb));
            SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
            format(string, sizeof(string), " You have teleported to %s.", NORPN(playerb));
            SendClientMessage(playerid, COLOR_WHITE, string);
            format(string, sizeof(string), " %s %s has teleported to you.", RPHLN(playerid), NORPN(playerid));
            SendClientMessage(playerb, COLOR_WHITE, string);
            format(string, sizeof(string), "{FF0000}[Helper Warn]{FF6347} %s has teleported to %s.", NORPN(playerid), NORPN(playerb));
            SendHelperMessage(COLOR_LIGHTRED, 1, string);
        }
        else SendClientMessage(playerid, COLOR_GREY, "You must /goback before teleporting to another player.");
    }
    else
    {
        if(Spec[playerb]) return SendClientMessage(playerid, COLOR_GREY, "Player is spectating someone.");
        GetPlayerPos(playerb, Pos[0], Pos[1], Pos[2]);
        if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            SetVehiclePos(GetPlayerVehicleID(playerid), Pos[0]+2, Pos[1]+2, Pos[2]);
        }
        else
        {
            SetPlayerPos(playerid, Pos[0]+1, Pos[1], Pos[2]);
        }
        SetPlayerInterior(playerid, GetPlayerInterior(playerb));
        SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(playerb));
        format(string, sizeof(string), " You have teleported to %s.", NORPN(playerb));
        SendClientMessage(playerid, COLOR_WHITE, string);
        format(string, sizeof(string), " Administrator %s has teleported to you.", NORPN(playerid));
        SendClientMessage(playerb, COLOR_WHITE, string);
    }
    return 1;
}
Reply
#6

DanishHaq i want my code..
Reply
#7

Danialdano thanks bro
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)