12.08.2010, 10:50
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.
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;
}
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));
}