OnPlayerShot?
#1

Hello i have a system that only shot your teams on minimap, my idea is to make if some enemy shot (Damage player or no) he will appear on the minimap...
Its there that callback or how would i do this?
Reply
#2

https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot

Use something like https://sampwiki.blast.hk/wiki/SetPlayerMarkerForPlayer and then set a timer and then rehide it when the timer gets called.
Reply
#3

Quote:
Originally Posted by Stinged
Посмотреть сообщение
https://sampwiki.blast.hk/wiki/OnPlayerWeaponShot

Use something like https://sampwiki.blast.hk/wiki/SetPlayerMarkerForPlayer and then set a timer and then rehide it when the timer gets called.
I know the function and how made it, but first i need define if the player who shotted is not in the same team than the player2.
This will work?
if(gTeam[playerid] != gTeam[playerid])
Reply
#4

Do you want the market to show whenever the player shoots? Even if the no one gets hit?
If so, loop using for or foreach, and get every player that isn't on the shooter's team.
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    for (new i = 0, j = GetPlayerPoolSize(); i != j; i++)
    {
        if (gTeam[playerid] != gTeam[i])
        {
    	    // ...
	}
    }
    return 1;
}
Reply
#5

DELETE.
Reply
#6

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Do you want the market to show whenever the player shoots? Even if the no one gets hit?
If so, loop using for or foreach, and get every player that isn't on the shooter's team.
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    for (new i = 0, j = GetPlayerPoolSize(); i != j; i++)
    {
        if (gTeam[playerid] != gTeam[i])
        {
    	    // ...
	}
    }
    return 1;
}
Thanks iґll try.
This wonґt work? for(new i = 0; i < MAX_PLAYERS; i++)
Look i have this code, can someone help me?
Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && gTeam[playerid] == Terroristas && gTeam[i] != Terroristas)
       	{
 			   SetPlayerMarkerForPlayer(i, playerid, RojoMarcado);
		}
		if(IsPlayerConnected(i) && gTeam[playerid] == Policias && gTeam[i] != Policias)
       	{
		    	SetPlayerMarkerForPlayer(i, playerid, AzulMarcado);
		}
	}
    return 1;
}
Reply
#7

Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
	if(hittype == 1)
	{
         if (GetPlayerTeam(playerid) != GetPlayerTeam(hitid))
        {
           foreach(Player,i)
           {
    	    SetPlayerMarkerForPlayer(i, playerid, 0xFF0000FF );
	   }
        }
        }
    return 1;
}
As i little understand you want if teammate !=teammate show shotter in minimap for all.
well test this out. i didn't tested yet.
Reply
#8

Show me your #defines of
RojoMarcado
AzulMarcado
Reply
#9

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Show me your #defines of
RojoMarcado
AzulMarcado
Код:
#define RojoMarcado     0xFF0000FF
#define AzulMarcado     0x0000FFFF
I think the code is good, but i need a timer to reset that function.
Reply
#10

Your code was fine, I just wanted your defines to change the transparency of the color.
(Note, your SetPlayerMarkerForPlayer has the arguments mixed up)

Код:
#define ChangeAlpha(%0,%1)      (%0 & 0xFFFFFF00) | %1

forward Timer_HideMarker(playerid, i);

public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i))
        {
	    if(gTeam[playerid] == Terroristas && gTeam[i] != Terroristas)
	        SetPlayerMarkerForPlayer(playerid, i, RojoMarcado);
	    else if(gTeam[playerid] == Policias && gTeam[i] != Policias)
                SetPlayerMarkerForPlayer(playerid, i, AzulMarcado);
	    else continue;
	    SetTimerEx("Timer_HideMarker", 2000, false, "ii", playerid, i);
	}
    }
    return 1;
}

public Timer_HideMarker(playerid, i)
{
    if (gTeam[playerid] == Terroristas) SetPlayerMarkerForPlayer(playerid, i, ChangeAlpha(RojoMarcado, 0x00));
    else if (gTeam[playerid] == Policias) SetPlayerMarkerForPlayer(playerid, i, ChangeAlpha(AzulMarcado, 0x00));
    return 1;
}
EDIT: Sorry, I noticed a small bug in my code, fixed it.
NOTE: I also updated ChangeAlpha, I was using the old macro I had, and not the current one I'm normally using.
Reply


Forum Jump:


Users browsing this thread: 5 Guest(s)