How to make this command? -
PlayHard - 08.12.2011
Hello,
Today my friend scripted a command for me ( Heal ) for a job. Now after I thought about it, it's like /heal playerid amount. It can be bugged and spammed on people ... So, I decided to make a command that accepts the command heal ( /acceptheal ). But I am stuck in it, here is my command:
pawn Код:
CMD:heal(playerid, params[])
{
if(PlayerInfo[playerid][Job] == 1)
{
new targetid,
string[128],
amount;
if( sscanf ( params, "ii", targetid, amount)) return SendClientMessage(playerid, -1,"/heal [PlayerID/PlayerName] [Amount]"); // This will actually do it - I is a interget and that's a targetid.
format(string, sizeof(string), "[Medic]Your patient have been healed for %d",amount);
SetPlayerHealth(targetid, 100);
GivePlayerMoney(playerid, amount);
GivePlayerMoney(targetid, amount);
} else return SendClientMessage(playerid, 0xFFFFFFFF, ".:: Error: You need to be a m3dic to use this command! ::.");
return 1;
}
How can I make the /acceptheal command?
Thanks a lot!
Re: How to make this command? -
Kingunit - 08.12.2011
Add a SendClientMessage to your format, and remove the insults.
Set a variable to 1 at the targetid and set it at the accept to 0 and give him the health and the money.
Check serveral things like: Is the targetID a medic? And go on.
Re: How to make this command? -
PlayHard - 08.12.2011
I don't understand ..
Re: How to make this command? -
Kingunit - 08.12.2011
https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/GetPlayerName
Re: How to make this command? -
PlayHard - 08.12.2011
Like that?
pawn Код:
CMD:acceptheal(playerid, params[])
{
new targetid, amount, string[128];
PlayerInfo[targetid][Healed] = 0;
PlayerInfo[playerid][Healed] = 1;
format(string, sizeof(string), "[Medic]You've been healed for %d",amount);
return 1;
}

?
Re: How to make this command? -
bartje01 - 08.12.2011
Quote:
Originally Posted by Kingunit
|
*facepalm* That will not help him at alll...
Re : How to make this command? -
Amine_Mejrhirrou - 08.12.2011
first learn to use variables

then u will understand
Re: How to make this command? -
Kingunit - 08.12.2011
Quote:
Originally Posted by bartje01
*facepalm* That will not help him at alll...
|
Explain why that will not help? Just dropping: "That will not help him at all" is just lame.
Re: How to make this command? -
grand.Theft.Otto - 08.12.2011
Try this, untested:
pawn Код:
// top of script
new OfferedHeal[MAX_PLAYERS];
new HealthPrice;
new MedicID, PatientID;
new healedname[24], medicname[24];
// new heal command
CMD:heal(playerid, params[])
{
if(PlayerInfo[playerid][Job] == 1)
{
new string[128];
if(sscanf(params, "ii", PatientID, HealthPrice)) return SendClientMessage(playerid, -1,"/heal [PlayerID/PlayerName] [Amount]"); // This will actually do it - I is a interget and that's a targetid.
GetPlayerName(PatientID,healedname,24);
GetPlayerName(MedicID,medicname,24);
if(GetPlayerHealth(PatientID) <= 99)
{
format(string,128,"Medic %s (%d) Has Offered You Health Services For $%d. Type /acceptheal To Accept.",medicname,MedicID,HealthPrice);
SendClientMessage(PatientID,-1,string);
format(string,128,"Offered %s (%d) Health Services For $%d. Wait To See If He Will Respond.",healedname,PatientID,HealthPrice);
SendClientMessage(MedicID,-1,string);
OfferedHeal[PatientID] = 1;
} else return SendClientMessage(MedicID,-1,"The Target Player's Health Is Already Full.");
} else return SendClientMessage(MedicID, 0xFFFFFFFF, ".:: Error: You need to be a m3dic to use this command! ::.");
return 1;
}
// /acceptheal command
CMD:acceptheal(playerid,params[])
{
if(OfferedHeal[PatientID] == 1)
{
new string[128];
SetPlayerHealth(PatientID,100);
format(string,128,"Healed By Medic %s (%d) For $%d.",medicname,MedicID,HealthPrice);
SendClientMessage(PatientID,-1,string);
format(string,128,"Healed %s (%d) For $%d.",healedname,PatientID,HealthPrice);
SendClientMessage(PatientID,-1,string);
GivePlayerMoney(PatientID, -HealthPrice);
GivePlayerMoney(MedicID, HealthPrice);
OfferedHealth[PatientID] = 0;
} else return SendClientMessage(PatientID,-1,"You Weren't Offered Any Medic Services.");
return 1;
}
Re: How to make this command? -
PlayHard - 09.12.2011
Quote:
Originally Posted by grand.Theft.Otto
Try this, untested:
pawn Код:
// top of script
new OfferedHeal[MAX_PLAYERS]; new HealthPrice; new MedicID, PatientID; new healedname[24], medicname[24];
// new heal command
CMD:heal(playerid, params[]) { if(PlayerInfo[playerid][Job] == 1) { new string[128];
if(sscanf(params, "ii", PatientID, HealthPrice)) return SendClientMessage(playerid, -1,"/heal [PlayerID/PlayerName] [Amount]"); // This will actually do it - I is a interget and that's a targetid.
GetPlayerName(PatientID,healedname,24); GetPlayerName(MedicID,medicname,24);
if(GetPlayerHealth(PatientID) <= 99) { format(string,128,"Medic %s (%d) Has Offered You Health Services For $%d. Type /acceptheal To Accept.",medicname,MedicID,HealthPrice); SendClientMessage(PatientID,-1,string); format(string,128,"Offered %s (%d) Health Services For $%d. Wait To See If He Will Respond.",healedname,PatientID,HealthPrice); SendClientMessage(MedicID,-1,string); OfferedHeal[PatientID] = 1; } else return SendClientMessage(MedicID,-1,"The Target Player's Health Is Already Full."); } else return SendClientMessage(MedicID, 0xFFFFFFFF, ".:: Error: You need to be a m3dic to use this command! ::."); return 1; }
// /acceptheal command
CMD:acceptheal(playerid,params[]) { if(OfferedHeal[PatientID] == 1) { new string[128]; SetPlayerHealth(PatientID,100); format(string,128,"Healed By Medic %s (%d) For $%d.",medicname,MedicID,HealthPrice); SendClientMessage(PatientID,-1,string);
format(string,128,"Healed %s (%d) For $%d.",healedname,PatientID,HealthPrice); SendClientMessage(PatientID,-1,string);
GivePlayerMoney(PatientID, -HealthPrice); GivePlayerMoney(MedicID, HealthPrice); OfferedHealth[PatientID] = 0; } else return SendClientMessage(PatientID,-1,"You Weren't Offered Any Medic Services."); return 1; }
|
Hm,
I have 1 warning
pawn Код:
C:\Documents and Settings\Administrator\Desktop\server\filterscripts\blah.pwn(1470) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Warning.
Line:
pawn Код:
if(GetPlayerHealth(PatientID) <= 99)