10.08.2011, 17:31
pawn Код:
stock Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x3,Float:y3,Float:z3;
if (!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x3,y3,z3);
return floatsqroot(floatpower(floatabs(floatsub(x3,x1)),2)+floatpower(floatabs(floatsub(y3,y1)),2)+floatpower(floatabs(floatsub(z3,z1)),2));
}
Here is a simple /rape command I made (I'll use strcmp since I don't know what command processor you're using):
pawn Код:
if(strcmp(cmdtext, "/rape", true, 5) == 0) // 5 = command length including forward slash /
{
new tmp[128], player1,string[128],aname[24],pname[24];
GetPlayerName(player1,name,24); // attacker name
GetPlayerName(playerid,pname,24); // victim name
player1 = strval(tmp); // so we make player1 a number / id value
if(GetDistanceBetweenPlayers(playerid, player1) > 20) return SendClientMessage(playerid,red,"Target Player Is Not Close Enough To Rape.");
// playerid = rapist || player1 = victim
// below is if the player is less than 20 metres and what will happen, else if it goes over, it returns the error above
new Float: health;
GetPlayerHealth(player1,health); // getting player1's health
SetPlayerHealth(player1, health -25); // getting player1's health and setting to -25 percent at the same time
// so if their health is 50 (half percent) it will set to -25 percent from 50, which = 25 percent health (almost dead)
format(string,128,"%s (%d) Has Raped You.",aname,playerid);
SendClientMessage(player1, COLOR, string);
format(string,128,"You Have Raped %s (%d).",pname,player1);
SendClientMessage(playerid, COLOR, string);
Untested but I'm sure it should work.
Good luck.