When player shot player
#1

Hi, I need script, when player1 shot player2. And when player1 shot him to head,hands,body or legs and player2 after will live, so player1 get wanted level. Thanks.
Reply
#2

uhh?
do you mean, when a guy kills an other guy gets wanted?
scripting it for you now
Reply
#3

Quote:
Originally Posted by Mike_Peterson
Посмотреть сообщение
uhh?
do you mean, when a guy kills an other guy gets wanted?
scripting it for you now
I guess he's not talking only about kills, I guess he needs something like "OnPlayerAttackPlayer". I have the code for it but it's really bugged, and only works with fists
Reply
#4

Jony, i know this isnt really quite supported yet :P
btw its OnPlayerClickPlayer, since 0.3 its added :P
currently testing that script if someone comes on my server..
Reply
#5

OnPlayerClickPlayer happens when somebody clicks on another player via <source>. The only source at the moment, is by clicking on a player in the player list (The TAB-list).
Reply
#6

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
SendClientMessage(playerid,COLOR_RED,"You've died.");
new Player[24];
GetPlayerName(playerid, Player, sizeof(Player));
new string[128];
new level;
format(string, sizeof(string), "You have killed %s, you're wanted level have been increased.", Player, killerid);
SendClientMessage(killerid,COLOR_GREY, string);
level = GetPlayerWantedLevel(killerid);
SetPlayerWantedLevel(killerid,level+2);
return 1;
}
[code] allows you to paste it,
btw this is just when someone kills someone else the killer gets wanted +2
Reply
#7

I dont want script onplayerdeath.. I want "OnPlayerAttackPlayer". When player1 shot or attack on player2, player1 get wanted level. Player2 not die, but his HP will be low.
Reply
#8

kiwi123, ATM thats kind of not possible, well it is possible but very unaccuarate, i suggest we all wait for the new release and hope for this callback, cause for now nobody can math it 100 percent accuarate, tho you can detect whenever his health changed then loop through the players getting the players angle, and when was the last time he shot and in which direction which should to the trick but you need to keep distance to <100 cause from LS to SF wouldn't be very possible wouldn't it?
Reply
#9

try it with "IsPlayerAimingAt" when the player1 aim player2 and press key_fire
the player1 get wanted level

know how to make that or want to make it for you?
Reply
#10

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:X,Float:Y,Float:Z,Float:pX,Float:pY,Float:pZ;
    GetPlayerPos(playerid, pX,pY,pZ);
    if((newkeys & KEY_FIRE))
    {
    	for(new i=0; i < MAX_PLAYERS; i++)
		{
  			if(IsPlayerInRangeOfPoint(i,60, pX,pY,pZ))
   			{
      			if(i != playerid)
	        	{
					GetPlayerPos(i, X,Y,Z);
  					if(IsPlayerAimingAt(playerid, X,Y,Z,1))
    				{
    				SetPlayerWantedLevel(playerid, GetPlayerWantedLevel( playerid )+1 );
					}
				}
			}
		}
	}
	return 1;
}
Float:DistanceCameraTargetToLocation(Float:CamX, Float:CamY, Float:CamZ,  Float:ObjX, Float:ObjY, Float:ObjZ,  Float:FrX, Float:FrY, Float:FrZ)
{

	new Float:TGTDistance;

	// get distance from camera to target
	TGTDistance = floatsqroot((CamX - ObjX) * (CamX - ObjX) + (CamY - ObjY) * (CamY - ObjY) + (CamZ - ObjZ) * (CamZ - ObjZ));

	new Float:tmpX, Float:tmpY, Float:tmpZ;

	tmpX = FrX * TGTDistance + CamX;
	tmpY = FrY * TGTDistance + CamY;
	tmpZ = FrZ * TGTDistance + CamZ;

	return floatsqroot((tmpX - ObjX) * (tmpX - ObjX) + (tmpY - ObjY) * (tmpY - ObjY) + (tmpZ - ObjZ) * (tmpZ - ObjZ));
}
stock IsPlayerAimingAt(playerid, Float:x, Float:y, Float:z, Float:radius)
{
    new Float:cx,Float:cy,Float:cz,Float:fx,Float:fy,Float:fz;
    GetPlayerCameraPos(playerid, cx, cy, cz);
    GetPlayerCameraFrontVector(playerid, fx, fy, fz);
    return (radius >= DistanceCameraTargetToLocation(cx, cy, cz, x, y, z, fx, fy, fz));
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)