Make player invisible
#1

Hi, I'm wondering whether there's some way to make a player invisible to other players.

I've read that making a desync with a player on OnPlayerUpdate can do something similar. Also, that putting a player in an invisible car is possible.

I'm very newbie to scripting, so any help would be appreciated.
Thanks in advance.
Reply
#2

The first option just seems like a bad idea to me.

However, the second option seems to work fine most of the time. If you REALLY want to make a player invisible, the code below should work fine:

pawn Код:
new
    bool:g_Invisible[playerid] = false
;

CMD:toginvisibility(playerid, params[])
{
    new
        vehID = GetPlayerVehicleID(playerid)
    ;
   
    if(vehID == INVALID_VEHICLE_ID)
            return 1;

    if(!g_Invisible[playerid])
    {  
        g_Invisible[playerid] = true;
        LinkVehicleToInterior(vehID, playerid*5); // taking the player's ID and multiplying it by 5 means they will (generally) never be in the same VW as another player
        for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, playerid, 0); // normally I'd use foreach here, but whatever
    }
    else
    {
        g_Invisible[playerid] = false;
        LinkVehicleToInterior(vehID,  0);  
        for(new i = 0; i < MAX_PLAYERS; i++) ShowPlayerNameTagForPlayer(i, playerid, 1); // normally I'd use foreach here, but whatever
    }
    return 1;
}
Reply
#3

Here is as good as you'll get but it's pretty buggy.

Reply
#4

I'm getting following error:

Код:
error 008: must be a constant expression; assumed zero
It's on this line:

Код:
 bool:g_Invisible[playerid] = false;
Thanks.
Reply
#5

Oops, my fault! Change [playerid] to [MAX_PLAYERS].
Reply
#6

Just curious, would returning 0 on OnPlayerStreamIn work? (bad practice, I know)
Reply
#7

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Oops, my fault! Change [playerid] to [MAX_PLAYERS].
It compiled fine.
I'm going to test it now.

Thanks, RealCop288.
Reply
#8

No, the OnPlayerUpdate is a good idea. You could walk everythere, but players would see you in other place, like somewhere else.
Reply
#9

Quote:
Originally Posted by Rajat_Pawar
Посмотреть сообщение
Just curious, would returning 0 on OnPlayerStreamIn work? (bad practice, I know)
Quote:
Originally Posted by MyPony
Посмотреть сообщение
No, the OnPlayerUpdate is a good idea. You could walk everythere, but players would see you in other place, like somewhere else.
Those just seem like bad ideas. Screwing around with the sync is probably one of the dumbest things you could do. If you ask me, you're just leaving yourself open to a bunch of problems!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)