SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 03/12/2019, 07:28 AM   #11
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 4D1L View Post
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;
}
I've tried the way u suggest and it just stop to show map icon to allies

Did i've done something wrong?

Code:
public OnActorStreamIn(actorid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(actorid)) {
        SetPlayerMarkerForPlayer(actorid, forplayerid, COLOR_LIMEGREEN);
    }
    else if(!IsACop(forplayerid) && fmembro[forplayerid] != 0) {
        if(fmembro[forplayerid] == fmembro[actorid]) {
            SetPlayerMarkerForPlayer(actorid, forplayerid, COLOR_LIMEGREEN);
        }
    }
}
public OnPlayerStreamOut(playerid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(playerid)) {
        SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
    }
    else if(!IsACop(forplayerid) && fmembro[forplayerid] != 0) {
        if(fmembro[forplayerid] == fmembro[playerid]) {
            SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
        }
    }
    return 1;
}
binnyl is offline   Reply With Quote
Old 03/12/2019, 10:15 AM   #12
Awide
Big Clucker
 
Join Date: Mar 2014
Posts: 109
Reputation: 15
Default Re: Show cops on radar (only for other cops)

It would be more efficient to do this whenever a cop's entering or exiting a vehicle.
Awide is offline   Reply With Quote
Old 03/12/2019, 03:41 PM   #13
4D1L
Big Clucker
 
Join Date: Mar 2016
Location: United Kingdom
Posts: 74
Reputation: 22
Default Re: Show cops on radar (only for other cops)

Quote:
Originally Posted by binnyl View Post
I've tried the way u suggest and it just stop to show map icon to allies

Did i've done something wrong?

Code:
public OnActorStreamIn(actorid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(actorid)) {
        SetPlayerMarkerForPlayer(actorid, forplayerid, COLOR_LIMEGREEN);
    }
    else if(!IsACop(forplayerid) && fmembro[forplayerid] != 0) {
        if(fmembro[forplayerid] == fmembro[actorid]) {
            SetPlayerMarkerForPlayer(actorid, forplayerid, COLOR_LIMEGREEN);
        }
    }
}
public OnPlayerStreamOut(playerid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(playerid)) {
        SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
    }
    else if(!IsACop(forplayerid) && fmembro[forplayerid] != 0) {
        if(fmembro[forplayerid] == fmembro[playerid]) {
            SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
        }
    }
    return 1;
}
If the two players aren't the same teams then I would SetPlayerMarkerForPlayer using a different colour.

In your case, SetPlayerMarkerForPlayer in an else block after your two if statements will set the player marker if they're not allies.

Also, I'm not sure if SetPlayerMarkerForPlayer will work with actors.
4D1L is offline   Reply With Quote
Old 07/12/2019, 04:32 PM   #14
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 4D1L View Post
If the two players aren't the same teams then I would SetPlayerMarkerForPlayer using a different colour.

In your case, SetPlayerMarkerForPlayer in an else block after your two if statements will set the player marker if they're not allies.

Also, I'm not sure if SetPlayerMarkerForPlayer will work with actors.
This script
pawn Code:
public OnActorStreamIn(actorid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(actorid)) {
        SetPlayerMarkerForPlayer(actorid, forplayerid, COLOR_LIMEGREEN);
    }
    else if(!IsACop(forplayerid) && fmembro[forplayerid] != 0) {
        if(fmembro[forplayerid] == fmembro[actorid]) {
            SetPlayerMarkerForPlayer(actorid, forplayerid, COLOR_LIMEGREEN);
        }
    }
}
public OnPlayerStreamOut(playerid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(playerid)) {
        SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
    }
    else if(!IsACop(forplayerid) && fmembro[forplayerid] != 0) {
        if(fmembro[forplayerid] == fmembro[playerid]) {
            SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
        }
    }
    return 1;
}

Is not work at all, its never showing the allies

My old one was working good, except if the player get out of a range, so it always shows the marker on north
binnyl is offline   Reply With Quote
Old 08/12/2019, 12:05 AM   #15
4D1L
Big Clucker
 
Join Date: Mar 2016
Location: United Kingdom
Posts: 74
Reputation: 22
Default Re: Show cops on radar (only for other cops)

What are you returning in IsACop?

Instead of using OnActorStreamIn, use OnPlayerStreamIn. Actors are not players nor are they NPCs.
4D1L is offline   Reply With Quote
Old 02/01/2020, 07:37 AM   #16
binnyl
Huge Clucker
 
Join Date: Aug 2017
Posts: 290
Reputation: 6
Default Re: Show cops on radar (only for other cops)

Is a COP is a simple stock
Code:
stock IsACop(playerid) {
    if(org[playerid] == 1 || org[playerid] == 2 || org[playerid] == 3 || org[playerid] == 4 || org[playerid] == 11 || org[playerid] == 5 || org[playerid] == 10) { return 1; }
    return 0;
}

Before i was using this:
Code:
SetTimer("OnPlayerUpdateEx", 50,1); // loop players 50 ms
Code:
forward OnPlayerUpdateEx(); public OnPlayerUpdateEx() {
	foreach(new i : Player) {
			TeamRadar(i);
Code:
forward TeamRadar(playerid); public TeamRadar(playerid) {
    if(IsACop(playerid)) {
        foreach(new i : Player) {
            if(IsACop(i)) {
                SetPlayerMarkerForPlayer(i, playerid, COLOR_LIMEGREEN);
            }
        }
    }
}
It was working good, every teams mates was marked on the map
With that problem, if leave some range, player mark always shows to the north


Now with:
Code:
public OnPlayerStreamIn(playerid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(playerid)) {
        SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
    }
}
public OnPlayerStreamOut(playerid, forplayerid)
{
    if(IsACop(forplayerid) && IsACop(playerid)) {
        SetPlayerMarkerForPlayer(playerid, forplayerid, COLOR_LIMEGREEN);
    }
    return 1;
}
The team mates isn't showing none mark on map


What should i do?
binnyl 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 10:31 AM.


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