SA-MP Forums Archive
On Pressed key help - 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: On Pressed key help (/showthread.php?tid=458720)



On Pressed key help - NinjahZ - 18.08.2013

I want to make it so when a player fires his gun,it shows a playermarker
and when he stops shooting it removes the marker,this is my idea,but I dont know if it will work and I cant test it right now

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( IsPlayerSpawned(playerid) && (PRESSED(KEY_FIRE)))
    {
        if (gTeam[playerid] == TEAM_BLUE)
        {
            ShowPlayerMarkers(2);
            SetPlayerMarkerForPlayer(TEAM_BLUE,TEAM_RED,COLOR_BLUE );//SetPlayerMarkerForPlayer(playerid, showplayerid, color)
        }
        else if (gTeam[playerid] == TEAM_RED)
        {
            ShowPlayerMarkers(2);
            SetPlayerMarkerForPlayer(TEAM_RED,TEAM_BLUE,COLOR_RED );
        }
        else if( IsPlayerSpawned(playerid) && (!PRESSED(KEY_FIRE)))
        {
            ShowPlayerMarkers(0);
        }
    }
    if( IsPlayerSpawned(playerid) && !IsPlayerInAnyVehicle(playerid) && (PRESSED(KEY_HANDBRAKE) || RELEASED(KEY_HANDBRAKE)) )
    {
        if(IsPlayerAiming(playerid))
        {
            SetPlayerFirstPersonMode(playerid,0);
            pFirstPersonTick[playerid] = GetTickCount();
        }
    }
    return 1;
}



Re: On Pressed key help - Edix - 18.08.2013

Well if you want to do so when a player shoots it will show a marker then you need to also check if the palyer is holding the key_fire.


Re: On Pressed key help - NinjahZ - 18.08.2013

Oh okay.