/spec OFF not working
#1

when I /Spec OFF a player, it doesnt return me to my last pos. It returns me to 0,0,0.

pawn Код:
if(strcmp(cmd, "/spec", true) == 0 || strcmp(cmd, "/recon", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [playerid/off]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(strcmp("off", tmp, true, strlen(tmp)) == 0)
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not spectating anyone!");
                    return 1;
                }
                SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
                SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                SetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                SendClientMessage(playerid, COLOR_WHITE, "You are no longer spectating.");
                TogglePlayerSpectating(playerid, 0);
                SpectatedID[playerid] = INVALID_PLAYER_ID;
                SpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                HidePM[playerid] = 0;
                PhoneOnline[playerid] = 0;
                ResetPlayerAdminWeaponsEx(playerid);
                UpdateWeapons(playerid);
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                    GetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                }
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                TogglePlayerSpectating(playerid, 1);
                SpectatedID[playerid] = giveplayerid;
                HidePM[playerid] = 1;
                PhoneOnline[playerid] = 1;
                new Float:X, Float:Y, Float:Z;
                new Float:health;
                GetPlayerHealth(giveplayerid, health);
                new Float:armor;
                GetPlayerArmour(giveplayerid, armor);GetPlayerPos(playerid, X, Y, Z);
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                new cash =  GetPlayerMoney(giveplayerid);
                if (PlayerInfo[playerid][pAdmin] >= 1)
                {
                    format(string, sizeof(string), "Specing: [%d]%s [$%d] [H:%.0f] [A:%.0f]",giveplayerid,giveplayer,cash,health,armor);
                }
                SendClientMessage(playerid, COLOR_GREEN, string);
                if(IsPlayerInAnyVehicle(giveplayerid))
                {
                    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
                }
                else
                {
                    PlayerSpectatePlayer(playerid, giveplayerid);
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   That player isn't active!");
                return 1;
            }
        }
        return 1;
    }
Reply
#2

pawn Код:
if(strcmp(cmd, "/spec", true) == 0 || strcmp(cmd, "/recon", true) == 0)
    {
    new Float:P,FLoat:O,Float:S;
    GetPlayerPos(playerid,P,O,S);
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [playerid/off]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(strcmp("off", tmp, true, strlen(tmp)) == 0)
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not spectating anyone!");
                    return 1;
                }
                SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
                SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                SetPlayerPos(playerid, P,O,S);
                SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                SendClientMessage(playerid, COLOR_WHITE, "You are no longer spectating.");
                TogglePlayerSpectating(playerid, 0);
                SpectatedID[playerid] = INVALID_PLAYER_ID;
                SpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                HidePM[playerid] = 0;
                PhoneOnline[playerid] = 0;
                ResetPlayerAdminWeaponsEx(playerid);
                UpdateWeapons(playerid);
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                    GetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                }
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                TogglePlayerSpectating(playerid, 1);
                SpectatedID[playerid] = giveplayerid;
                HidePM[playerid] = 1;
                PhoneOnline[playerid] = 1;
                new Float:X, Float:Y, Float:Z;
                new Float:health;
                GetPlayerHealth(giveplayerid, health);
                new Float:armor;
                GetPlayerArmour(giveplayerid, armor);GetPlayerPos(playerid, X, Y, Z);
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                new cash =  GetPlayerMoney(giveplayerid);
                if (PlayerInfo[playerid][pAdmin] >= 1)
                {
                    format(string, sizeof(string), "Specing: [%d]%s [$%d] [H:%.0f] [A:%.0f]",giveplayerid,giveplayer,cash,health,armor);
                }
                SendClientMessage(playerid, COLOR_GREEN, string);
                if(IsPlayerInAnyVehicle(giveplayerid))
                {
                    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
                }
                else
                {
                    PlayerSpectatePlayer(playerid, giveplayerid);
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   That player isn't active!");
                return 1;
            }
        }
        return 1;
    }
Added something that gets the player position when he/she does /spec, and sets the pos to the gotten float.
Not tested, please say if it helped

EDIT: better use SnG.Scot_MisCuDI's code, I think it has more chance to work than mines
Reply
#3

Not tested but try

pawn Код:
forward ReturnPosition(playerid);
pawn Код:
new Float:Pos[MAX_PLAYERS][4];
pawn Код:
if(strcmp(cmd, "/spec", true) == 0 || strcmp(cmd, "/recon", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [playerid/off]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(strcmp("off", tmp, true, strlen(tmp)) == 0)
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not spectating anyone!");
                    return 1;
                }
                SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
                SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                SetTimerEx("ReturnPosition",1000,0,"d",playerid);
                SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                SendClientMessage(playerid, COLOR_WHITE, "You are no longer spectating.");
                TogglePlayerSpectating(playerid, 0);
                SpectatedID[playerid] = INVALID_PLAYER_ID;
                SpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                HidePM[playerid] = 0;
                PhoneOnline[playerid] = 0;
                ResetPlayerAdminWeaponsEx(playerid);
                UpdateWeapons(playerid);
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                    GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
                    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                }
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                TogglePlayerSpectating(playerid, 1);
                SpectatedID[playerid] = giveplayerid;
                HidePM[playerid] = 1;
                PhoneOnline[playerid] = 1;
                new Float:X, Float:Y, Float:Z;
                new Float:health;
                GetPlayerHealth(giveplayerid, health);
                new Float:armor;
                GetPlayerArmour(giveplayerid, armor);GetPlayerPos(playerid, X, Y, Z);
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                new cash =  GetPlayerMoney(giveplayerid);
                if (PlayerInfo[playerid][pAdmin] >= 1)
                {
                    format(string, sizeof(string), "Specing: [%d]%s [$%d] [H:%.0f] [A:%.0f]",giveplayerid,giveplayer,cash,health,armor);
                }
                SendClientMessage(playerid, COLOR_GREEN, string);
                if(IsPlayerInAnyVehicle(giveplayerid))
                {
                    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
                }
                else
                {
                    PlayerSpectatePlayer(playerid, giveplayerid);
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   That player isn't active!");
                return 1;
            }
        }
        return 1;
    }
pawn Код:
public ReturnPosition(playerid)
{
    SetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
}
Reply
#4

Quote:
Originally Posted by SnG.Scot_MisCuDI
Посмотреть сообщение
Not tested but try

pawn Код:
forward ReturnPosition(playerid);
pawn Код:
new Float:Pos[MAX_PLAYERS][4];
pawn Код:
if(strcmp(cmd, "/spec", true) == 0 || strcmp(cmd, "/recon", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /spec [playerid/off]");
                return 1;
            }
            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(strcmp("off", tmp, true, strlen(tmp)) == 0)
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    SendClientMessage(playerid, COLOR_GREY, "   You are not spectating anyone!");
                    return 1;
                }
                SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
                SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                SetTimerEx("ReturnPosition",1000,0,"d",playerid);
                SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                SendClientMessage(playerid, COLOR_WHITE, "You are no longer spectating.");
                TogglePlayerSpectating(playerid, 0);
                SpectatedID[playerid] = INVALID_PLAYER_ID;
                SpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                HidePM[playerid] = 0;
                PhoneOnline[playerid] = 0;
                ResetPlayerAdminWeaponsEx(playerid);
                UpdateWeapons(playerid);
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                    GetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
                    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                }
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                TogglePlayerSpectating(playerid, 1);
                SpectatedID[playerid] = giveplayerid;
                HidePM[playerid] = 1;
                PhoneOnline[playerid] = 1;
                new Float:X, Float:Y, Float:Z;
                new Float:health;
                GetPlayerHealth(giveplayerid, health);
                new Float:armor;
                GetPlayerArmour(giveplayerid, armor);GetPlayerPos(playerid, X, Y, Z);
                GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
                new cash =  GetPlayerMoney(giveplayerid);
                if (PlayerInfo[playerid][pAdmin] >= 1)
                {
                    format(string, sizeof(string), "Specing: [%d]%s [$%d] [H:%.0f] [A:%.0f]",giveplayerid,giveplayer,cash,health,armor);
                }
                SendClientMessage(playerid, COLOR_GREEN, string);
                if(IsPlayerInAnyVehicle(giveplayerid))
                {
                    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
                }
                else
                {
                    PlayerSpectatePlayer(playerid, giveplayerid);
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   That player isn't active!");
                return 1;
            }
        }
        return 1;
    }
pawn Код:
public ReturnPosition(playerid)
{
    SetPlayerPos(playerid,Pos[playerid][0],Pos[playerid][1],Pos[playerid][2]);
}
Not Working. I have the code as you laid it out.
Reply
#5

bump still need help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)