SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/11/2019, 02:58 AM   #1
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Show cops on radar (only for other cops)

I have this function:
pawn Code:
forward TeamRadar(playerid); public TeamRadar(playerid) {
    if(IsACop(playerid)) {
        foreach(new i : Player) {
            if(IsACop(i)) {
                SetPlayerMarkerForPlayer(i, playerid, COLOR_LIMEGREEN);
            }
        }
    }
}

It is called in function every 1 second, check if player is a COP, and if player is a COP show to others COPs on radar...
It is already working, but there is a problem, if the partner go out of the player range, map icon show always to north
Even if the partner is not on the north
There is a way to fix it?

My server is already:
pawn Code:
ShowPlayerMarkers(1);
binnyl is offline   Reply With Quote
Old 22/11/2019, 02:30 AM   #2
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: Show cops on radar (only for other cops)

bump
binnyl is offline   Reply With Quote
Old 22/11/2019, 07:53 AM   #3
Hitek
Big Clucker
 
Hitek's Avatar
 
Join Date: Apr 2012
Posts: 152
Reputation: 1
Default Re: Show cops on radar (only for other cops)

Your code is a little bit incorrect!
I'd better use
Code:
public IsACop(killerid)
{
        if(GetPlayerSkin(killerid) == 280 || GetPlayerSkin(killerid) == 281 || GetPlayerSkin(killerid) == 282 || GetPlayerSkin(killerid) == 283 || GetPlayerSkin(killerid) == 284 || GetPlayerSkin(killerid) == 285 || GetPlayerSkin(killerid) == 286 || GetPlayerSkin(killerid) == 287 || GetPlayerSkin(killerid) == 288)
        {
                return 1;
        }
        else
        {
                return 0;
        }
}
Check your other scripts and PLUGINS also streamer you use and if your pawn include matches with plugin ver
__________________
Hitek is offline   Reply With Quote
Old 22/11/2019, 08:27 AM   #4
Gforcez
Gangsta
 
Gforcez's Avatar
 
Join Date: Jul 2010
Location: The Netherlands.
Posts: 770
Reputation: 449
Default Re: Show cops on radar (only for other cops)

Quote:
Originally Posted by binnyl View Post
pawn Code:
ShowPlayerMarkers(1);
Shouldn't you set ShowPlayerMarkers to 0, since you want to hide all the markers and only show the cops to other cops.


Quote:
Originally Posted by Hitek View Post
Your code is a little bit incorrect!
I'd better use
Code:
public IsACop(killerid)
{
        if(GetPlayerSkin(killerid) == 280 || GetPlayerSkin(killerid) == 281 || GetPlayerSkin(killerid) == 282 || GetPlayerSkin(killerid) == 283 || GetPlayerSkin(killerid) == 284 || GetPlayerSkin(killerid) == 285 || GetPlayerSkin(killerid) == 286 || GetPlayerSkin(killerid) == 287 || GetPlayerSkin(killerid) == 288)
        {
                return 1;
        }
        else
        {
                return 0;
        }
}
Check your other scripts and PLUGINS also streamer you use and if your pawn include matches with plugin ver
Are you just randomly saying something? IsACop isn't shown here so how'd you know if it's wrong?
__________________

Gforcez is offline   Reply With Quote
Old 22/11/2019, 03:40 PM   #5
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: Show cops on radar (only for other cops)

Quote:
Originally Posted by Gforcez View Post
Shouldn't you set ShowPlayerMarkers to 0, since you want to hide all the markers and only show the cops to other cops.




Are you just randomly saying something? IsACop isn't shown here so how'd you know if it's wrong?

Yes, he is


About showplayermakers i'm using this
pawn Code:
stock TransparentColor(color) { return (color  & 0xFFFFFF00); }

So players are not showing on map, only when i want to i remove this transparent color for a little time

By the way the function TeamRadar(playerid); is working as i think
It is only bugging when someone get over from a range, every cops so far to you shows to be on north, not on the right direction
binnyl is offline   Reply With Quote
Old 29/11/2019, 11:24 PM   #6
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: Show cops on radar (only for other cops)

bump
binnyl is offline   Reply With Quote
Old 30/11/2019, 09:14 PM   #7
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: Show cops on radar (only for other cops)

bump
binnyl is offline   Reply With Quote
Old 30/11/2019, 11:23 PM   #8
ApolloScripter
Huge Clucker
 
ApolloScripter's Avatar
 
Join Date: Sep 2018
Posts: 228
Reputation: 7
Default Re: Show cops on radar (only for other cops)

Hello binnyl, I don't know how exactly SetPlayerMarkerForPlayer works, but I have a similar system, but I used SetPlayerMapIcon to put an icon for all players of the same clan.

The difference is that SetPlayerMapIcon makes it possible to change the constant style to appear on every radar, or just in your field of view.

The problem is that for each Map Icon will need to get the position of the player, but if you are interested follow the steps below and put them in your code, which maybe will work perfectly.

pawn Code:
new iconMapPlayerCount[MAX_PLAYERS]; //Set the variable to Map Icon Count

forward TeamRadar(playerid); public TeamRadar(playerid)
{
    if(IsACop(playerid))
    {
        foreach(new i : Player)
        {
            if(IsACop(i))
            {
                if(IsPlayerConnected(i))
                {
                    new Float:tg_x, tg_y, tg_z; //Set variables to target coordinates
                    GetPlayerPos(i, Float:tg_x, Float:tg_y, Float:tg_z); //Get target pos
                    SetPlayerMapIcon(playerid, iconMapPlayerCount[playerid], Float:tg_x, Float:tg_y, Float:tg_z, 0, 0x59f060FF, MAPICON_GLOBAL); //Add a icon to the target position
                    iconMapPlayerCount[playerid]++; //Increment the player count icon id
                }
                else
                {
                    RemovePlayerMapIcon(playerid, iconMapPlayerCount[playerid]); //Remove the icon if the target disconnect
                }
            }
        }

        iconMapPlayerCount[playerid] = 0; //Set the count to 0
    }
}

I didn't have time to test the operation, but if you use it and some error occurs, just call me.
EDIT NOTE: The problem with this Icon is that only 100 can be used.
__________________
ApolloScripter is offline   Reply With Quote
Old 02/12/2019, 03:54 AM   #9
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: Show cops on radar (only for other cops)

Quote:
Originally Posted by ApolloScripter View Post
Hello binnyl, I don't know how exactly SetPlayerMarkerForPlayer works, but I have a similar system, but I used SetPlayerMapIcon to put an icon for all players of the same clan.

The difference is that SetPlayerMapIcon makes it possible to change the constant style to appear on every radar, or just in your field of view.

The problem is that for each Map Icon will need to get the position of the player, but if you are interested follow the steps below and put them in your code, which maybe will work perfectly.

pawn Code:
new iconMapPlayerCount[MAX_PLAYERS]; //Set the variable to Map Icon Count

forward TeamRadar(playerid); public TeamRadar(playerid)
{
    if(IsACop(playerid))
    {
        foreach(new i : Player)
        {
            if(IsACop(i))
            {
                if(IsPlayerConnected(i))
                {
                    new Float:tg_x, tg_y, tg_z; //Set variables to target coordinates
                    GetPlayerPos(i, Float:tg_x, Float:tg_y, Float:tg_z); //Get target pos
                    SetPlayerMapIcon(playerid, iconMapPlayerCount[playerid], Float:tg_x, Float:tg_y, Float:tg_z, 0, 0x59f060FF, MAPICON_GLOBAL); //Add a icon to the target position
                    iconMapPlayerCount[playerid]++; //Increment the player count icon id
                }
                else
                {
                    RemovePlayerMapIcon(playerid, iconMapPlayerCount[playerid]); //Remove the icon if the target disconnect
                }
            }
        }

        iconMapPlayerCount[playerid] = 0; //Set the count to 0
    }
}

I didn't have time to test the operation, but if you use it and some error occurs, just call me.
EDIT NOTE: The problem with this Icon is that only 100 can be used.
I'm already uses SetPlayerMapIcon for a lot of stuff
Even had to use a streammer to don't get to the 100

SetPlayerMarkerForPlayer was made for it
Idk what happen if i'm missing something or if it is bugged already

Anyways, ty to your try, i rep you
binnyl is offline   Reply With Quote
Old 02/12/2019, 08:39 PM   #10
4D1L
Big Clucker
 
Join Date: Mar 2016
Location: United Kingdom
Posts: 74
Reputation: 22
Default Re: Show cops on radar (only for other cops)

I believe reducing the number of times you call SetPlayerMarkerForPlayer could help you with your problem.

I would call SetPlayerMarkerForPlayer in both OnPlayerStreamIn and in OnPlayerStreamOut and then do checks between them.

Instead of your timer, the following would work:

pawn Code:
public OnPlayerStreamOut(playerid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(playerid))
    {
          SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
    }

    return 1;
}
4D1L is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Cops Lokii Includes 15 28/01/2019 12:55 PM
[Ajuda] Cops Poderem pegar carros de outros Cops Vitor_Marfioso Português/Portuguese 16 12/01/2012 01:54 PM
[Ajuda] COPS pegarem carros de outros COPS Vitor_Marfioso Português/Portuguese 2 06/01/2012 08:22 PM
GF cops&fbi....... skynny Help Archive 1 17/02/2010 06:57 PM
Car Cops monster010 Help Archive 4 14/09/2009 04:07 PM


All times are GMT. The time now is 07:55 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.