/heal ID - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: /heal ID (
/showthread.php?tid=156182)
/heal ID -
Crusty - 21.06.2010
Hello, I'm almost finished with my /heal command, but the only thing I must fix is that only players in a specific range of the player should be able to heal the player. How do I do it?
pawn Код:
if(strcmp(cmd, "/heal", true) == 0)
{
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_WHITE, "/heal ID");
return 1;
}
new playa;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
if(HealInfo[playerid][pHealkit] == 1)
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
HealInfo[playerid][pHeal] = 0;
SetPlayerHealth(playa, 100);
}
}
}
else
{
SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command");
}
}
return 1;
}
Re: /heal ID -
ViruZZzZ_ChiLLL - 21.06.2010
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));
}
Re: /heal ID -
Crusty - 21.06.2010
Shouldn't it be possible to use a functions such as IsPlayerInRangeOfPoint of PlayerToPoint?
Re: /heal ID -
Naxix - 21.06.2010
use use GetPlayerPos(targetid,x,y,z); to get the pos of targetid
then
Код:
If(!IsPlayerInRangeOfPoint(playerid,6,x,y,z) return SendClientMessage(playerid,color,"msg");
Re: /heal ID -
aircombat - 21.06.2010
Код:
new Target,Float:X,Float:Y,Float:Z;
GetPlayerPos(Target,X,Y,Z);
if(IsPlayerInRangeOfPoint(playerid,2.0,X,Y,Z))
{
//DO
}
else
{
//Don't
}
Re: /heal ID -
RatHack - 21.06.2010
download a good admin system and it will have that cmd
Re: /heal ID -
MWF2 - 21.06.2010
Add this somewhere in your script:
pawn Код:
stock GetDistanceBetweenPlayers(playerid,playerid2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
new Float:tmpdis;
GetPlayerPos(playerid,x1,y1,z1);
GetPlayerPos(playerid2,x2,y2,z2);
tmpdis = floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
return floatround(tmpdis);
}
Then add this to your /heal command
pawn Код:
if(GetDistanceBetweenPlayers(playerid,giveplayerid) > 5)
{
SendClientMessage(playerid,0x87CEEBAA, "Player is not close enough to heal")
return 1;
}