AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problem with plugin (https://forums.alliedmods.net/showthread.php?t=233895)

hunter00 01-21-2014 14:25

Problem with plugin
 
Hey can someone help me with this plugin http://www.4shared.com/file/OycP0KAm..._Smartest.html
I've got this problem with compilation - http://prikachi.com/images/528/6978528i.png

wickedd 01-21-2014 15:27

Re: Problem with plugin
 
Why don't you ask the author?

hunter00 01-21-2014 16:34

Re: Problem with plugin
 
hmm he didn't answer me , can you compile this .sma and give me the plugin please ?

fysiks 01-21-2014 17:18

Re: Problem with plugin
 
Attach the plugin to your post. Don't use a website plagued by advertisements.

If I had to guess, it kinda looks like the file might be saved as UTF-8 with BOM where it should be without BOM.

hunter00 01-22-2014 10:10

Re: Problem with plugin
 
1 Attachment(s)
here is the plugin - please if u can compile it

Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <zombie_plague_advance>
#include <dhudmessage>

#define PLUGIN "The Smartest"
#define VERSION "1.0"
#define AUTHOR "BaHeK"

//new string_nums
new question[131]
new answer[64]
new quest[64]
new nick_winner[32]
new results
new string_num
new random_quest
new SayText
//new NomNagrada

// Квары
new red, green, blue
new money, armor, sound

public plugin_init() {
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_logevent("newround", 2, "1=Round_Start");
    red = register_cvar("sm_red","0");
    green = register_cvar("sm_green","255");
    blue = register_cvar("sm_blue","0");
    money = register_cvar("sm_money","15");
    sound = register_cvar("sm_sound","1");
    armor = register_cvar("sm_armor","20");
    register_clcmd("say /vupros","resultats");
    register_clcmd("say /question","resultats");
    register_clcmd("say /winner", "winner");
    register_clcmd("say","check_results");
    register_clcmd("say_team","check_results");
    SayText = get_user_msgid("SayText");
    readfiles()
}

public plugin_precache()
{
  precache_sound("the_smart/pipewarp.wav")
  return PLUGIN_CONTINUE
}

public readfiles()
{
    if (!file_exists("addons/amxmodx/configs/questions.ini"))
    {
    write_file("addons/amxmodx/configs/questions.ini", ";Это файл с вопросами и ответам. Как должен выглядеть файл:^n;^"вопрос^" ^"ответ^"^n^"1+1^" ^"2^"", -1)
}
}

public newround()
{
    results = 0
    new txtlen
    string_num = file_size("addons/amxmodx/configs/questions.ini", 1)
    random_quest = random_num ( 1,string_num )
    read_file("addons/amxmodx/configs/questions.ini", random_quest, question, 130, txtlen)
    while ( (question[0] == ';' || equali(question,"")) )
    {
        random_quest = random_num ( 1,string_num )
        read_file("addons/amxmodx/configs/questions.ini", random_quest, question, 130, txtlen)
    }
   
    // парсим
    trim(question)
   
    parse(question, quest, sizeof(quest) , answer, sizeof(answer))
   
   
    set_dhudmessage(get_pcvar_num(red), get_pcvar_num(green), get_pcvar_num(blue), 0.03, 0.55, 0, 6.0, 12.0, 0.2, 0.2, -1)
    show_dhudmessage(0, "Vupros: %s = ?", quest)
        print_col_chat(0, "^4Vupros: %s = ?", quest)
}



public check_results(id)
{

static chat[192];
read_args(chat, sizeof(chat) - 1);
remove_quotes(chat);

if ( results == 0 ) { // проверка на доступность ответа

if (equali(chat, answer ))
{
go_nagrada(id)
}
} else
   
if (chat[0] == '-' || chat[0] == '1' || chat[0] == '2' || chat[0] == '3' || chat[0] == '4' || chat[0] == '5' || chat[0] == '6' || chat[0] == '7' ||
chat[0] == '8' || chat[0] == '9' || chat[0] == '0')
print_col_chat(id, "^4К Za sujalenie, igracha ^3%s ^4ve4e e otgovoril na vuprosa i e vzel nagradata.", nick_winner) // Обламываем
}

public go_nagrada(id) // награда
{
 if(zp_get_user_zombie(id)){
  results = 1 // записываем ответ

  if (get_pcvar_num(sound) == 1) {
    client_cmd(0, "spk the_smart/pipewarp" )
  }
  new random = random_num(1,2)
  if(random==1)
  {
    new hpz
    hpz = 500
    if (is_user_alive(id)) {
      new give_health = get_user_health(id) + hpz
      set_user_health(id, give_health)
    }   
    get_user_name(id,nick_winner,31);

    print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4hp!", nick_winner, hpz)
  }
  if(random==2)
  {
  if (is_user_alive(id)) {
    zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(money))
  }
  get_user_name(id,nick_winner,31);

  print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4ammo packa!", nick_winner, get_pcvar_num(money))
  }
 }
 else
  if(zp_get_user_survivor(id))
  {
    results = 1 // записываем ответ

    if (get_pcvar_num(sound) == 1) {
      client_cmd(0, "spk the_smart/pipewarp" )
    }
    new random = random_num(1,2)
    if(random==1)
    {
      new hps
      hps = 1000
      if (is_user_alive(id)) {
        new give_health = get_user_health(id) + hps
        set_user_health(id, give_health)
      }   
      get_user_name(id,nick_winner,31);

      print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4hp!", nick_winner, hps)
    }
    if(random==2)
    {
    if (is_user_alive(id)) {
      zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(money))
    }
    get_user_name(id,nick_winner,31);

    print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4ammo packa!", nick_winner, get_pcvar_num(money))
    }
  }
  else
    if(zp_get_user_nemesis(id))
    {
      results = 1 // записываем ответ

      if (get_pcvar_num(sound) == 1) {
        client_cmd(0, "spk the_smart/pipewarp" )
      }
      new random = random_num(1,2)
      if(random==1)
      {
        new hpn
        hpn = 2500
        if (is_user_alive(id)) {
          new give_health = get_user_health(id) + hpn
          set_user_health(id, give_health)
        }   
        get_user_name(id,nick_winner,31);

        print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4hp!", nick_winner, hpn)
      }
      if(random==2)
      {
      if (is_user_alive(id)) {
        zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(money))
      }
      get_user_name(id,nick_winner,31);

      print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4ammo packa!", nick_winner, get_pcvar_num(money))
      }
    }
    else
    {
      results = 1 // записываем ответ

      if (get_pcvar_num(sound) == 1) {
        client_cmd(0, "spk the_smart/pipewarp" )
      }
      new random = random_num(1,5)
      if(random==1)
      {
        new give_armor = get_pcvar_num(armor)
        set_user_armor(id, give_armor)

        get_user_name(id,nick_winner,31);

        print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4bronq!", nick_winner, give_armor)
      }
      if(random==2)
      {
        if (is_user_alive(id)) {
          zp_set_user_ammo_packs(id, zp_get_user_ammo_packs(id) + get_pcvar_num(money))
        }
        get_user_name(id,nick_winner,31);

        print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3%i ^4ammo packa!", nick_winner, get_pcvar_num(money))
      }
      if(random==3)
      {
        if (is_user_alive(id)) {
          give_item(id, "weapon_g3sg1")
          give_item(id, "weapon_g3sg1")
          give_item(id, "weapon_g3sg1")
              give_item(id, "weapon_g3sg1")
          give_item(id, "weapon_g3sg1")
          give_item(id, "weapon_g3sg1")
          give_item(id, "weapon_g3sg1")
              give_item(id, "weapon_g3sg1")
        }
        get_user_name(id,nick_winner,31);

        print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3orujiq^4!", nick_winner)
      }
      if(random==4)
      {
        if (is_user_alive(id)) {
          give_item(id, "weapon_m249")
          give_item(id, "weapon_m249")
          give_item(id, "weapon_m249")
        }
        get_user_name(id,nick_winner,31);

        print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3pistolet^4!", nick_winner)
      }
      if(random==5)
      {
        if (is_user_alive(id)) {
          give_item(id, "weapon_hegrenade")
          give_item(id, "weapon_flashbang")
          give_item(id, "weapon_smokegrenade")
        }
        get_user_name(id,nick_winner,31);

        print_col_chat(0, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada ^3granati^4!", nick_winner)
      }
    }
}

public winner(id)
{
    if ( results == 1 )
    {
    print_col_chat(id, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada!", nick_winner)
    } else
    print_col_chat(id, "^4Nqma Winner vse o6te. Budi purvi?")
}

public resultats(id)
{
set_dhudmessage(get_pcvar_num(red), get_pcvar_num(green), get_pcvar_num(blue), 0.03, 0.55, 0, 6.0, 12.0, 0.2, 0.2, -1)
if ( results == 1 )
{
show_hudmessage(id, "Конкурс окончен. Pobeditel v chata")
print_col_chat(id, "^4Конкурс окончен.")
print_col_chat(id, "^4Na vuprosa purvi otgovori ^3%s ^4i polu4i nagrada!", nick_winner)
} else
{
print_col_chat(id, "^4Vupros: %s = ?", quest)
show_dhudmessage(id, "Vupros: %s = ?", quest)
}
}

stock print_col_chat(const id, const input[], any:...)
{
    new count = 1, players[32];
    static msg[191];
    vformat(msg, 190, input, 3);
    replace_all(msg, 190, "!g", "^4"); // Green Color
    replace_all(msg, 190, "!y", "^1"); // Default Color (у©°  湫)
    replace_all(msg, 190, "!t", "^3"); // Team Color
    if (id) players[0] = id; else get_players(players, count, "ch");
    {
        for ( new i = 0; i < count; i++ )
        {
            if ( is_user_connected(players[i]) )
            {
                message_begin(MSG_ONE_UNRELIABLE, SayText, _, players[i]);
                write_byte(players[i]);
                write_string(msg);
                message_end();
            }
        }
    }
}


fysiks 01-22-2014 11:42

Re: Problem with plugin
 
It compile perfectly fine for me. My previous thought is correct.

matsi 01-22-2014 11:59

Re: Problem with plugin
 
I think you might have some extra characters in your code. Scroll to the top and see.


EDIT:

Opening that .sma i get this:
Code:
#include <amxmodx>

fysiks 01-22-2014 12:07

Re: Problem with plugin
 
Quote:

Originally Posted by matsi (Post 2089509)
I think you might have some extra characters in your code. Scroll to the top and see.


EDIT:

Opening that .sma i get this:
Code:
#include <amxmodx>

That is the BOM that I previously mentioned. Those are non-visible characters if you have an editor that can properly view UTF-8 files. The solution is to save it as UTF-8 without BOM.

YamiKaitou 01-22-2014 12:08

Re: Problem with plugin
 
It is not there when I open it in Notepad++, but I do see that the file is encoded as 'UTF8' instead of 'UTF8 without BOM'

hunter00 01-22-2014 13:08

Re: Problem with plugin
 
fysiks -i save the file with UTF-8 Without BOM and then compiled the plugin , thanks
but i have one question about the plugin- can you help how to set the plugin to show the question for x seconds , because there isn't any cvar for this


All times are GMT -4. The time now is 17:16.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.