How to make this command?
#1

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!
Reply
#2

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.
Reply
#3

I don't understand ..
Reply
#4

https://sampwiki.blast.hk/wiki/Scripting_Basics#Variables
https://sampwiki.blast.hk/wiki/Format
https://sampwiki.blast.hk/wiki/GetPlayerName
Reply
#5

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;
}
?
Reply
#6

*facepalm* That will not help him at alll...
Reply
#7

first learn to use variables then u will understand
Reply
#8

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.
Reply
#9

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;
}
Reply
#10

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)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)