Can some one give me an example?
#1

Hi everyone, does anyone know how to create a command that offers other player for example to heal them, and the other player has to accept it. I would need a simple example to look at, as i tried to create it 2 days now
If possible i would be happy if it was created in <zcmd>, it don't have to be to heal, anything really ill edit and learn the code my self then.

Cheers in advance if anyone helps would be very grateful
Reply
#2

You should not create this one topic, just bump the old one and then maybe someone reply you. I've already gave you the code in the old topic.
Reply
#3

The old topic wasn't really the same, i tried to create it my self but i just can't i don't understand that bool and the code i used didnt work
Reply
#4

Check this code.. it's not tested.

pawn Код:
#include    <a_samp>
#include    <zcmd>
#include    <sscanf2>


new bool:pOffersHeal[MAX_PLAYERS] = false;
new Float:HealthAmount;

CMD:heal(playerid, params[])
{
    new         giveplayerid,
                Float:heal,
                Float:X, Float:Y, Float:Z;
    if(sscanf(params, "df", giveplayerid, heal))return SendClientMessage(playerid, -1, "Type: /heal (playerid) (health)");
    {
        if(!IsPlayerConnected(giveplayerid) || giveplayerid == playerid)
        {
            SendClientMessage(playerid, -1, "Error: Unable to find this player.");
            return true;
        }
       
        GetPlayerPos(playerid, X, Y, Z);
        if(!IsPlayerInRangeOfPoint(giveplayerid, 5.0, X, Y, Z))
        {
            SendClientMessage(playerid, -1, "Error: This player is too far from you!");
            return true;
        }
       
        new string[128];
        format(string, sizeof(string), "You've received an offer to heal you by %2.1f", heal);
        SendClientMessage(giveplayerid, -1, string);
        SendClientMessage(giveplayerid, -1, "Type in the chat \"Yes\" or \"No\" to reply the offer.");
        pOffersHeal[giveplayerid] = true;
        HealthAmount = heal;
    }
    return true;
}

public OnPlayerText(playerid, text[])
{
    if(pOffersHeal[playerid])
    {
        if(strcmp(text, "Yes", true) == 0)
        {
            SetPlayerHealth(playerid, HealthAmount);
        }
       
        else if(strcmp(text, "No", true) == 0)
        {
            GameTextForPlayer(playerid, "Canceled heal offer", 3000, 3);
        }
        return true;
    }
    return true;
}
Reply
#5

Quote:

public OnPlayerText(playerid, text[])
{
if(pOffersHeal[playerid])
{
if(strcmp(text, "Yes", true) == 0)
{
SetPlayerHealth(playerid, HealthAmount);
}

else if(strcmp(text, "No", true) == 0)
{
GameTextForPlayer(playerid, "Canceled heal offer", 3000, 3);
}
return true;
}
}
return true;
}

{
new
realchat = 1,
string[ 128 ]
;
if(IsPlayerConnected(playerid))
{
if(realchat)
{
if(PlayerInfo[playerid][pAccent] == 0)
{
format(string, sizeof(string), "%s Mowi: %s", RPName(playerid), text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
}
else
{
new
accent[20]
;
switch(PlayerInfo[playerid][pAccent])
{
case 1: accent = "Russian";
case 2: accent = "Italian";
case 3: accent = "Germany";
case 4: accent = "Japanese";
case 5: accent = "French";
case 6: accent = "Spain";
case 7: accent = "China";
case 8: accent = "British";
}
format(string, sizeof(string), "%s Mowi: [%s Accent] %s", RPName(playerid), accent, text);
ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
}
return 0;
}
}
return 1;
}

I get like 20 errors & warnings i think its because i didnt separate them right and thanks alot man
Reply
#6

actually i think its the new boolOffersHeal[MAX_PLAYERS] = false;
new Float:HealthAmount;

i put wrong i think
Reply
#7

Indentation!!!

pawn Код:
public OnPlayerText(playerid, text[])
{
    if(pOffersHeal[playerid])
    {
        if(strcmp(text, "Yes", true) == 0)
        {
            SetPlayerHealth(playerid, HealthAmount);
        }

        else if(strcmp(text, "No", true) == 0)
        {
            GameTextForPlayer(playerid, "Canceled heal offer", 3000, 3);
        }
        return true;
    }
   
    new realchat = 1, string[ 128 ];
   
    if(IsPlayerConnected(playerid))
    {
        if(realchat)
        {
            if(PlayerInfo[playerid][pAccent] == 0)
            {
                format(string, sizeof(string), "%s Mowi: %s", RPName(playerid), text);
                ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
            }
        }
       
        else
        {
            new accent[20];

            switch(PlayerInfo[playerid][pAccent])
            {
                case 1: accent = "Russian";
                case 2: accent = "Italian";
                case 3: accent = "Germany";
                case 4: accent = "Japanese";
                case 5: accent = "French";
                case 6: accent = "Spain";
                case 7: accent = "China";
                case 8: accent = "British";
            }
            format(string, sizeof(string), "%s Mowi: [%s Accent] %s", RPName(playerid), accent, text);
            ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_F ADE4,COLOR_FADE5);
        }
    }
    return 1;
}
Reply
#8

yepp Okay, i think everything works! Now gonna ask someone to help me test it, @Riddick94 thanks alot AGAIN .. ill +rep when i can again
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)