OnPlayerConnect
#1

Hello!

im trying to get markers on the map invisible when connect and/or on spawn, but nothing seams to help
im doing like this

pawn Код:
public OnGameModeInit()
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        gradar[i] = 0;
    }


public OnPlayerConnect(playerid)
{
    gradar[playerid] = 0;
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(Member[playerid] != Member[i] && IsPlayerConnected(i)) SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
    }

public OnPlayerSpawn(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(Member[playerid] != Member[i] && IsPlayerConnected(i)) SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
    }
EDIT: forgot to add this here to
pawn Код:
public GangRadar(playerid)
{
    for(new i; i < MAX_PLAYERS; i++)
    {
        if(!IsPlayerConnected(i)) continue;
        if(Member[playerid] != Member[i] && gradar[i] == 1) SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(playerid) & 0xFFFFFF00));
        if(Leader[playerid] != Leader[i] && gradar[i] == 1) SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(playerid) & 0xFFFFFF00));
    }
}

COMMAND:radar(playerid, params[])
    {
        if(gradar[playerid] == 0)
        {
            for(new i; i < MAX_PLAYERS; i++)
            {

                if(Member[playerid] != Member[i] && IsPlayerConnected(i)) SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
                if(Leader[playerid] != Leader[i] && IsPlayerConnected(i)) SetPlayerMarkerForPlayer(playerid, i, (GetPlayerColor(i) & 0xFFFFFF00));
            }
            gradar[playerid] = 1;
            gradartimer[playerid] = SetTimerEx("GangRadar", 1000, true, "i", playerid);
        }
        else
        {
            for(new i; i < MAX_PLAYERS; i++) SetPlayerMarkerForPlayer(playerid, i, GetPlayerColor(i));
            gradar[playerid] = 0;
            KillTimer(gradartimer[playerid]);
        }
        return 1;
    }
and i also have tried this way
pawn Код:
if(Member[playerid] != Member[i] && gradar[i] == 0) SetPlayerMarkerForPlayer(i, playerid, (GetPlayerColor(playerid) & 0xFFFFFF00));
nothing seams to help
Reply
#2

At this at top of script:
#define COLOR_INVISIBLE 0xFFFFFF00
OnPlayerspawn add:
SetPlayerColor(playerid,COLOR_INVISIBLE);
Reply
#3

Quote:
Originally Posted by admigo
Посмотреть сообщение
At this at top of script:
#define COLOR_INVISIBLE 0xFFFFFF00
OnPlayerspawn add:
SetPlayerColor(playerid,COLOR_INVISIBLE);
he wants to keep the chat the same.

(GetPlayerColor(i) & 0xFFFFFF00)

yet I have never gotten it to work, I don't think the wiki is right..

I don't know how can this be fixed ;\
Reply
#4

Quote:
Originally Posted by admigo
Посмотреть сообщение
At this at top of script:
#define COLOR_INVISIBLE 0xFFFFFF00
OnPlayerspawn add:
SetPlayerColor(playerid,COLOR_INVISIBLE);
This makes everyone invisible, you need to be able to see your team members on the map

Quote:
Originally Posted by Kar
Посмотреть сообщение
he wants to keep the chat the same.

(GetPlayerColor(i) & 0xFFFFFF00)

yet I have never gotten it to work, I don't think the wiki is right..

I don't know how can this be fixed ;\
Thats correct, and also that the /radar cmd only removes other then your own team
Reply
#5

A quote from the wiki article on GetPlayerColor
Quote:

Important Note: GetPlayerColor will return nothing unless SetPlayerColor has been used!

If you want to use the default colours, click here, and add that code to your script.
Then, when a player connects, do:
pawn Код:
SetPlayerColor(playerid,PlayerColors[playerid]-FF);//"-FF" takes away the alpha (transparency) value of 255 (FF)
Reply
#6

Quote:
Originally Posted by Badger(new)
Посмотреть сообщение
A quote from the wiki article on GetPlayerColor

If you want to use the default colours, click here, and add that code to your script.
Then, when a player connects, do:
pawn Код:
SetPlayerColor(playerid,PlayerColors[playerid]-FF);//"-FF" takes away the alpha (transparency) value of 255 (FF)
I use SetPlayerColor for all teams when a player spawning.
Reply
#7

Quote:
Originally Posted by cruising
Посмотреть сообщение
I use SetPlayerColor for all teams when a player spawning.
I could not see that in the code you provided.

If you have used it, add -FF to the end of the colour to make map icons invisable (this will take away the alpha/transparency value, the last bit of 0xFF155DFF, to make map icons invisable).

e.g.
pawn Код:
SetPlayerColor(playerid,COLOR_RED-FF);
Reply
#8

Fail by me.
Reply
#9

Quote:
Originally Posted by Badger(new)
Посмотреть сообщение
I could not see that in the code you provided.

If you have used it, add -FF to the end of the colour to make map icons invisable (this will take away the alpha/transparency value, the last bit of 0xFF155DFF, to make map icons invisable).

e.g.
pawn Код:
SetPlayerColor(playerid,COLOR_RED-FF);
Thats because it wasnt that the question was about in first place.
And i had not problem with the colors, just the cmd it self, that i have solved now anyways

But just one question left, when i type /radar i get invisible for my enemies and stay visible for my team, but when i get close to a enemy, i get visible again, any good solution for that?
Reply
#10

Personally I would make something like this
pawn Код:
public OnPlayerSpawn( playerid )
{
    foreach (Player,i)
    {
        if ( Member[ playerid ] == Member[ i ] )
            continue;

        SetPlayerMarkerForPlayer( i, playerid, ( GetPlayerColor( playerid ) & 0xFFFFFF00 ) ); // Invisible
    }

    gradar[ playerid ] = 1; // Radar turned off for other teams.

    return 1;
}

CMD:radar( playerid, params[ ] )
{
    if ( !gradar[ playerid ] )
    {
        gradar[ playerid ] = 1;
       
        foreach (Player, i)
        {
            if ( Member[ playerid ] == Member[ i ] )
                continue;
               
            SetPlayerMarkerForPlayer( i, playerid, ( GetPlayerColor( playerid ) & 0xFFFFFF00 ) ); // Invisible for other teams.
        }
    }
   
    else
    {
        gradar[ playerid ] = 0;
       
        foreach (Player, i)
        {
            SetPlayerMarkerForPlayer( i, playerid, GetPlayerColor( playerid ) ); // Visible for other teams.
        }
    }
   
    return 1;
}
I hope this is what you want, and sorry for pressing Submit Post accidentally.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)