27.09.2013, 00:20
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.?
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;
}
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; }