kٍeyboard...
#1

is this possible to do if me was near other player and press key on my kٍeyboard something happen to that player like set hes heath to 100 or send him to jail.?
Reply
#2

Yes it possible

pawn Код:
GetNearPlayer(playerid)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X, Y, Z);

    for(new i=0; i != MAX_PLAYERS; i++) // loop
        if(IsPlayerConnected(i) && i != playerid && IsPlayerStreamedIn(playerid, i)) // checking connected streamed players for Me
            if(IsPlayerInRangeOfPoint(i, SetRangeHere, X, Y, Z)) // if player is in range of Me
                return i; // return victim id

    return INVALID_PLAYER_ID; // if none is in range of Me return invalid id
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_YES) // key 'Y'
    {
        new victim = GetNearPlayer(playerid);
        if(victim != INVALID_PLAYER_ID) // we found a victim
        {
            SetPlayerHealth(victim, 100.0); // sets victim 100 HP
            return 0;
        }
    }
    return 1;
}
Reply
#3

Yes, it's certainly possible and here is an example:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(newkeys == KEY_FIRE)
	{
	    new Float:p[3];
	    GetPlayerPos(playerid, p[0], p[1], p[2]);
	    for(new i = 0; i < MAX_PLAYERS; i++)
	    {
	        if(!IsPlayerInRangeOfPoint(i, 10, p[0], p[1], p[2])) continue;
	        SetPlayerHealth(i, 100.0);
	    }
	}
	return 1;
}
(In this case you will heal everyone whoever is in a range of 10 meters far away.)
Reply
#4

Thank you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)