1 post in this topic

Игрок (врач) предлагает другому игроку восстановить здоровье за n-сумму, если игрок согласен - он должен нажать клавишу Y, если не согласен - N     Автор: Roman

Спойлер

if(strcmp(cmd, "/heal", true) == 0)
{
    if(!IsPlayerConnected(playerid)) return 1;
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_GRAD2,"ИНФО: /heal [ид игрока] [цена]");
    giveplayerid = ReturnUser(tmp);
    if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid,COLOR_GREY,"Этот игрок оффлайн!");
    new Float:hpPlayer;
    GetPlayerHealth(giveplayerid,hpPlayer);
    if(hpPlayer >= 100.0) return SendClientMessage(playerid,COLOR_GREY,"Этот человек здоров!");
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_GRAD2,"ИНФО: /heal [ид игрока] [цена]");
    new price = strval(tmp);
    if(price <= 0) return SendClientMessage(playerid,COLOR_GRAD2,"Сумма должна быть выше 0р");
    if(GetPlayerMoney(giveplayerid) < price) return SendClientMessage(playerid,COLOR_GREY,"У него нет такой суммы!");
    GetPlayerName(playerid,sendername,sizeof(sendername));
    GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
    format(string,sizeof(string),"Врач %s предлагает вам восстановить здоровье за %iр",sendername,price);
    SendClientMessage(giveplayerid,COLOR_WHITE,string);
    SendClientMessage(giveplayerid,COLOR_WHITE,"Нажмите Y чтобы согласиться или N чтобы отказаться");
    format(string,sizeof(string),"Вы предложили %s восстановить здоровье за %iр",giveplayer,price);
    SendClientMessage(playerid,COLOR_WHITE,string);
    SetPVarInt(giveplayerid,"hp_price",price);
    SetPVarInt(giveplayerid,"medic",playerid);
    return 1;
}

 

Спойлер

if(newkeys == KEY_YES)
{
    if(GetPVarInt(playerid,"hp_price") != 0)
    {
        new price = GetPVarInt(playerid,"hp_price"),medic = GetPVarInt(playerid,"medic");
        GetPlayerName(playerid,sendername,sizeof(sendername));
        GetPlayerName(medic,giveplayer,sizeof(giveplayer));
        format(string,sizeof(string),"Врач %s восстановил вам здоровье за %iр",giveplayer,price);
        SendClientMessage(playerid,COLOR_WHITE,string);
        format(string,sizeof(string),"Вы восстановили %s здоровье за %iр",sendername,price);
        SendClientMessage(medic,COLOR_WHITE,string);
        SetPlayerHealth(playerid,100.0);
        GivePlayerMoney(playerid,-price);
        GivePlayerMoney(medic,-price);
        DeletePVar(playerid,"hp_price");
        DeletePVar(playerid,"medic");
    }
    return 1;
}
if(newkeys == KEY_NO)
{
    if(GetPVarInt(playerid,"hp_price") != 0)
    {
        new medic = GetPVarInt(playerid,"medic");
        GetPlayerName(playerid,sendername,sizeof(sendername));
        SendClientMessage(playerid,COLOR_RED,"Вы отказались!");
        format(string,sizeof(string),"%s отказался",sendername);
        SendClientMessage(medic,COLOR_RED,string);
        DeletePVar(playerid,"hp_price");
        DeletePVar(playerid,"medic");
    }
    return 1;
}

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By def
      arizona.pwn(23374) : error 012: invalid function call, not a valid address
      arizona.pwn(23374) : error 001: expected token: ";", but found ")"
      arizona.pwn(23374) : error 029: invalid expression, assumed zero
      arizona.pwn(23374) : fatal error 107: too many error messages on one line
      жалуется на данную строчку:
       
      %s{cccccc}Для продолжения нажмите 'Далее'",PN(playerid),playerid,ItemsInfo[itemid][ItemName2],hours,cost*hours,Inventory[playerid][2][slot], AksColorName(Inventory[playerid][4][slot]), Inventory[playerid][5][slot] ? GetNameStripe(Inventory[playerid][5][slot]) : "");