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

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   You have pasted content with formatting.   Remove formatting

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

Loading...
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • Leo_Carter
      By Leo_Carter
      Такая проблема то что я пишу мод с нуля и когда почти мод был готов, я решил его залить на хостинг, ну там есть подключение к mysql и всё подобное, только вот залил на хостинг, запускаю и у меня вот такие дебаги вылезают и сервер Unknown

       
      Loaded log file: "server_log.txt". ---------- SA-MP Dedicated Server ---------------------- v0.3.7-R2, (C)2005-2015 SA-MP Team [18:54:42] filterscripts = "" (string) [18:54:42] [18:54:42] Server Plugins [18:54:42] -------------- [18:54:42] Loading plugin: mysql_static.so [18:54:42] >> plugin.mysql: R39-2 successfully loaded. [18:54:42] Loaded. [18:54:42] Loading plugin: pawncmd.so [18:54:42] Pawn.CMD plugin v3.1.4 by urShadow loaded [18:54:42] Loaded. [18:54:42] Loading plugin: pawnregex.so [18:54:42] Pawn.Regex plugin v1.1 by urShadow loaded [18:54:42] Loaded. [18:54:42] Loading plugin: crashdetect.so [18:54:42] CrashDetect v4.18.1 is OK. [18:54:42] Loaded. [18:54:42] Loading plugin: streamer.so [18:54:42] *** Streamer Plugin v2.8.2 by Incognito loaded *** [18:54:42] Loaded. [18:54:42] Loading plugin: sscanf.so [18:54:42] [18:54:42] =============================== [18:54:42] sscanf plugin loaded. [18:54:42] Version: 2.8.1 [18:54:42] (c) 2012 Alex "Y_Less" Cole [18:54:42] =============================== [18:54:42] Loaded. [18:54:42] Loaded 6 plugins. [18:54:42] [18:54:42] Filterscripts [18:54:42] --------------- [18:54:42] Loaded 0 filterscripts. [18:54:42] [debug] Run time error 19: "File or function is not found" [18:54:42] [debug] cache_get_value_name [18:54:42] [debug] cache_get_value_name_int [18:54:42] [debug] Run time error 19: "File or function is not found" [18:54:42] [debug] cache_get_value_name [18:54:42] [debug] cache_get_value_name_int [18:54:42] Script[gamemodes/project.amx]: Run time error 19: "File or function is not found" [18:54:42] Number of vehicle models: 0 [18:54:42] [debug] Run time error 19: "File or function is not found" [18:54:42] [debug] cache_get_value_name [18:54:42] [debug] cache_get_value_name_int [18:54:42] [debug] Run time error 19: "File or function is not found" [18:54:42] [debug] cache_get_value_name [18:54:42] [debug] cache_get_value_name_int