PDA

View Full Version : Medic problem


jimis
16/07/2012, 08:40 AM
Hi all i am using this medic command,but when a medic can health him self all the time and do spamm score to him self,how i can make this command to dont work on him self id?

COMMAND:heal(playerid,params[])
{
new pId;
new pskin = GetPlayerSkin(playerid);
if(pskin == 275 || pskin == 276 || pskin == 274)

{
if(sscanf(params, "d", pId)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /heal [ID]");
else if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
else
{
new Float:x, Float:y, Float:z;
GetPlayerPos(pId, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
{
new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250], string2[256], string3[100], string4[100];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(pId, aname, sizeof(aname));
new Float:Health;
GetPlayerHealth(pId, Health);
if(Health == 0)
{
SendClientMessage(playerid, 0xFF0000AA, "This player is very healthy!");
return 1;
}

else
GetPlayerHealth(pId, Health);
if(Health < 100)
{
GivePlayerMoney(playerid,200);

GivePlayerMoney(pId,-200);
SetPlayerHealth(pId, 100);

format(string1, sizeof(string1), "%s(%d) Has been healthed by medic %s(%d)", aname, pId, pname, playerid);
SendClientMessageToAll(0xFF0000AA, string1);
format(string2, sizeof(string2), "You are full of health now!");
SendClientMessage(pId, 0xFF0000AA, string2);
SetPlayerScore(playerid,GetPlayerScore(playerid)+1 );
format(string3, sizeof(string3), "You have received 1 score for health an injured player!");
SendClientMessage(playerid, 0xFF0000AA, string3);

return 1;
}
}
}
}
else
{
return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not medic or you can heal people every 15 sec!!");
}
return 1;
}
help..

jimis
16/07/2012, 08:55 AM
someone?

[MM]RoXoR[FS]
16/07/2012, 09:11 AM
Hi all i am using this medic command,but when a medic can health him self all the time and do spamm score to him self,how i can make this command to dont work on him self id?

COMMAND:heal(playerid,params[])
{
new pId;
new pskin = GetPlayerSkin(playerid);
if(pskin == 275 || pskin == 276 || pskin == 274)

{
if(sscanf(params, "d", pId)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /heal [ID]");
else if(!IsPlayerConnected(pId)) return SendClientMessage(playerid, 0xFF0000AA, "The ID You Entered Was Not Found.");
else
{
new Float:x, Float:y, Float:z;
GetPlayerPos(pId, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 5.0, x, y, z))
{
new pname[MAX_PLAYER_NAME], aname[MAX_PLAYER_NAME], string1[250], string2[256], string3[100], string4[100];
GetPlayerName(playerid, pname, sizeof(pname));
GetPlayerName(pId, aname, sizeof(aname));
new Float:Health;
GetPlayerHealth(pId, Health);
if(Health == 0)
{
SendClientMessage(playerid, 0xFF0000AA, "This player is very healthy!");
return 1;
}

else
GetPlayerHealth(pId, Health);
if(Health < 100)
{
GivePlayerMoney(playerid,200);

GivePlayerMoney(pId,-200);
SetPlayerHealth(pId, 100);

format(string1, sizeof(string1), "%s(%d) Has been healthed by medic %s(%d)", aname, pId, pname, playerid);
SendClientMessageToAll(0xFF0000AA, string1);
format(string2, sizeof(string2), "You are full of health now!");
SendClientMessage(pId, 0xFF0000AA, string2);
SetPlayerScore(playerid,GetPlayerScore(playerid)+1 );
format(string3, sizeof(string3), "You have received 1 score for health an injured player!");
SendClientMessage(playerid, 0xFF0000AA, string3);

return 1;
}
}
}
}
else
{
return SendClientMessage(playerid, 0xFF0000AA, "Error: You are not medic or you can heal people every 15 sec!!");
}
return 1;
}
help..


if(pID == playerid) return SendClientMessage(playerid,-1,"You can not heal yourself");

jimis
16/07/2012, 09:18 AM
ok,thanks