Make player invisible -
Morten_Guado - 25.03.2013
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.
Re: Make player invisible -
Scenario - 25.03.2013
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;
}
Re: Make player invisible -
Pottus - 25.03.2013
Here is as good as you'll get but it's pretty buggy.
Re: Make player invisible -
Morten_Guado - 25.03.2013
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.
Re: Make player invisible -
Scenario - 25.03.2013
Oops, my fault! Change [playerid] to [MAX_PLAYERS].
Re: Make player invisible -
RajatPawar - 25.03.2013
Just curious, would returning 0 on OnPlayerStreamIn work? (bad practice, I know)
Re: Make player invisible -
Morten_Guado - 25.03.2013
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.
Re: Make player invisible -
MyPony - 25.03.2013
No, the OnPlayerUpdate is a good idea. You could walk everythere, but players would see you in other place, like somewhere else.
Re: Make player invisible -
Scenario - 25.03.2013
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!