SA-MP Forums Archive
SetPlayerMarkerForPlayer, to update? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: SetPlayerMarkerForPlayer, to update? (/showthread.php?tid=364107)



SetPlayerMarkerForPlayer, to update? - Mikkel_RE - 29.07.2012

Hello, i have gangchats in my roleplay server, when you type /joingang [number] it will show you a marker at the minimap for all the players in the gang, but after shortly time the marker will be gone, is there a way to update the marker every 2 second? or something like that


stock ShowGang(playah,gang)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i) && PlayerInfo[i][pGang] == gang && !PlayerInfo[i][pBanished])
{
SetPlayerMarkerForPlayer(i, playah, 0xAFAFAFAA);
SetPlayerMarkerForPlayer(playah, i, 0xAFAFAFAA);
}
}
return 1;
}


Re: SetPlayerMarkerForPlayer, to update? - Misiur - 29.07.2012

pawn Code:
//Over ShowGang function
forward HideGang(playerid)

//find
SetPlayerMarkerForPlayer(playah, i, 0xAFAFAFAA);
//add below
SetTimerEx("HideGang", 2000, false, "ii", playah, gang);

//Create
public HideGang(playah,gang) {
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerInfo[i][pGang] == gang && !PlayerInfo[i][pBanished])
        {
            SetPlayerMarkerForPlayer(i, playah, 0xFFFFFF00);
            SetPlayerMarkerForPlayer(playah, i, 0xFFFFFF00);
        }
    }
    return 1;
}
I think that storing gangs in separate arrays would be more efficient than looping through all players.


Re: SetPlayerMarkerForPlayer, to update? - Mikkel_RE - 29.07.2012

Do i have to remove stock then?


Re: SetPlayerMarkerForPlayer, to update? - Misiur - 29.07.2012

Do not delete anything, just follow instructions exactly as written. HideGang has to be public due to usage in timer callback


Re: SetPlayerMarkerForPlayer, to update? - Mikkel_RE - 29.07.2012

Alright, i did as you said, but when im trying to compile it i get this error "error 025: function heading differs from prototype"


Re: SetPlayerMarkerForPlayer, to update? - Misiur - 29.07.2012

ah, yes, my mistake

pawn Code:
//change
forward HideGang(playerid);
//to
forward HideGang(playah, gang)



Re: SetPlayerMarkerForPlayer, to update? - Mikkel_RE - 29.07.2012

Thanks alot