Raised This Month: $ Target: $400
 0% 

Does not start the server


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vadim7695
New Member
Join Date: Aug 2014
Old 08-07-2014 , 16:26   Does not start the server
Reply With Quote #1

Good day.
There is a plugin:
Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <nvault>
 
#define PLUGIN "credits"
#define AUTHOR "Vadik"
#define VERSION "0.1"
 
new credits[33] //value
new s_AuthID[35] //steam_id player
new i_credits //Pointer to store the file
 
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    RegisterHam(Ham_Killed, "player", "player_killed", 1)
      
	i_credits = nvault_open("credits") //Open the file and save it in the index

if (i_credits == INVALID_HANDLE)
set_fail_state("Error opening nVault file!") 
}
 
public client_authorized(id)
{
    // Obtain and store in an array of Steam ID Player
    get_user_authid(id, s_AuthID[id], charsmax(s_AuthID[]))
} 
 
public client_putinserver(id)
{
	//Initially clears the statistics by id
	credits[id] = 0
	
	//Receive value for the player steam_id
	new i_cred = nvault_get(i_credits, s_AuthID[id])
	
	//If you find a record that puts the player received the amount of value
	if (i_cred)
	{
		credits[id] = i_cred
	}
	else
	{	
		nvault_set(i_credits, s_AuthID, credits[id]) //reserve credits for steam id
	}
    
}

public player_killed(victim, attacker, shouldgib)
{
        if(!is_user_connected(attacker) || !is_user_connected(victim))
                return HAM_IGNORED
 
        switch(cs_get_user_team(victim))
        {
             case(CS_TEAM_CT):
             {
                      if(cs_get_user_team(attacker) == CS_TEAM_T) 
					  {
                      credits[attacker]++
					get_user_authid(attacker, s_AuthID, charsmax(s_AuthID)) 
					  nvault_set(i_credits, s_AuthID, credits[attacker]) 
					  client_print(attacker, print_chat, "You got 1 credit for killing the enemy")
					  }
             }
             
             case(CS_TEAM_T): // Жертва - Т
             {
                      if(cs_get_user_team(attacker) == CS_TEAM_CT) 
					  {
                      credits[attacker]+=3
					get_user_authid(attacker, s_AuthID, charsmax(s_AuthID)) 
					  nvault_set(i_credits, s_AuthID, credits[attacker]) 
					  client_print(attacker, print_chat, "You got 3 credit for killing the enemy")
					  }
             }
        }
        return HAM_IGNORED
}

public Round_Start()
{
	set_task( 1.0, "Hud_Soobshenie", _ ,_ ,_ ,"b" );
}

public Hud_Soobshenie(id)
{
	set_hudmessage(255, 0, 0, 1.0, 1.0, 0, 0, 2.0)
    show_hudmessage(id, credits[id])
}


public plugin_end(){
     nvault_close(i_credits)
}
Plugin compiled, but the server does not start, what's the problem?

P.S. Plugins writing about 2 weeks
P.S.S. Sorry for my English, Google translate

TY

Last edited by vadim7695; 08-07-2014 at 16:28.
vadim7695 is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-08-2014 , 08:09   Re: Does not start the server
Reply With Quote #2

You have an array of size 33 to store credits , but you only have a 1x34 dimension with which to store the steam id of a player. Did you intend on making this a 2D array, such as "new s_AuthID[MAX_PLAYERS][35];" ?

The server will fail to start if the vault is corrupted. If you actually look at the documentation for nVault, you'd see that nvault_set takes a string, not an int. Use the appropriate conversion function before putting data into the vault.
PreDominance is offline
vadim7695
New Member
Join Date: Aug 2014
Old 08-08-2014 , 10:14   Re: Does not start the server
Reply With Quote #3

Thank you
Tell me how to get the variable credits [id] by HUD for each player, respectively, as well as the change of the hud messages according to the change of variable credits [id], that is, the number of credits. The message should hang time.
vadim7695 is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-08-2014 , 10:26   Re: Does not start the server
Reply With Quote #4

I won't write all of the code for you, but there's a trick you can do with set_task. If you look at the documentation for set_task, you'll notice you can set an ID for the task.
A common practice to execute tasks repeatedly per-player is to do something like..
Code:
#define TASK_LOOP_CREDITS    200 // <-- task it show_credits(id)// <-- player id {     set_task("0.5", "loop_credits", TASK_LOOP_CREDITS + id, _, _, "b", _); } public loop_credits(id) { //<-- task id     new pId = id - TASK_LOOP_CREDITS; // task id - playerid  - task id..or player id     //do stuff }
Hopefully you can understand the code there.

*Edit
WYSYG editing sucks.

Last edited by PreDominance; 08-08-2014 at 10:30.
PreDominance is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-08-2014 , 18:06   Re: Does not start the server
Reply With Quote #5

Quote:
Originally Posted by PreDominance View Post
*Edit
WYSYG editing sucks.
I just disable the WYSIWYG.
__________________
fysiks is offline
vadim7695
New Member
Join Date: Aug 2014
Old 08-09-2014 , 05:13   Re: Does not start the server
Reply With Quote #6

Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <nvault>
 
#define PLUGIN "credits"
#define AUTHOR "Vadik"
#define VERSION "0.1"
#define TASK_LOOP_CREDITS    200 // <-- task it
 
new credits[33] //кредиты (ammo packs)
new s_AuthID[33][35] //steam_id игрока
new i_credits //Указатель для хранения файла
 
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    RegisterHam(Ham_Killed, "player", "player_killed", 1)
      
	i_credits = nvault_open("credits") //Открываем файл и сохраняем его в указателе

if (i_credits == INVALID_HANDLE)
set_fail_state("Error opening nVault file!") 
	
	register_logevent("show_credits", 2, "1=Round_Start")
}
 
public client_authorized(id)
{
    // Получаем и сохраняем в массиве Steam ID игрока
    get_user_authid(id, s_AuthID[id], charsmax(s_AuthID[]))
} 
 
public client_putinserver(id)
{
	//Изначально обнуляем статистику по id
	credits[id] = 0
	
	//Получаем кредиты игрок по steam_id
	new i_cred = nvault_get(i_credits, s_AuthID[id])
	
	//Если находим запись, то выставляем игроку полученное кличество кредитов
	if (i_cred)
	{
		credits[id] = i_cred
	}
	else
	{	
		new String[]
		num_to_str(credits[id],String,6)
		nvault_set(i_credits, s_AuthID, String) //сохраняем кредиты по стим_иду
	}
    
}

public player_killed(victim, attacker, shouldgib)
{
        if(!is_user_connected(attacker) || !is_user_connected(victim))
                return HAM_IGNORED
 
        switch(cs_get_user_team(victim)) // Команда жертвы
        {
             case(CS_TEAM_CT):
             {
                      if(cs_get_user_team(attacker) == CS_TEAM_T) // Его убийца - Т
					  {
                      credits[attacker]++
					get_user_authid(attacker, s_AuthID, charsmax(s_AuthID)) //Получаем стим_ид игрока
					
					  new String[]
					  num_to_str(credits[attacker],String,6)
					  nvault_set(i_credits, s_AuthID, String) //сохраняем кредиты по стим_иду
					  client_print(attacker, print_chat, "You got 1 credit for killing the enemy")
					  }
             }
             
             case(CS_TEAM_T): // Жертва - Т
             {
                      if(cs_get_user_team(attacker) == CS_TEAM_CT) // Убийца - КТ
					  {
                      credits[attacker]+=3
					get_user_authid(attacker, s_AuthID, charsmax(s_AuthID)) //Получаем стим_ид игрока
					
					  new String[]
					  num_to_str(credits[attacker],String,6)
					  nvault_set(i_credits, s_AuthID, credits[attacker]) //сохраняем кредиты по стим_иду
					  client_print(attacker, print_chat, "You got 3 credit for killing the enemy")
					  }
             }
        }
        return HAM_IGNORED
}

public show_credits(id)
{
	set_task("0.5", "loop_credits", TASK_LOOP_CREDITS + id, _, _, "b", _);
}

public loop_credits(id)
{
	 new pId = id - TASK_LOOP_CREDITS;
	set_hudmessage(255, 0, 0, 1.0, 1.0, 0, 0, 99999.0)
    show_hudmessage(id, credits[pId])
}


public plugin_end(){
     nvault_close(i_credits) //Закрываем сохранение
}
Here's what happened, I do everything correctly?
Please indicate errors.
TY
vadim7695 is offline
PreDominance
Member
Join Date: Jul 2014
Old 08-09-2014 , 14:15   Re: Does not start the server
Reply With Quote #7

In your loop_credits you find the player's id fine but don't do the show_hudmessage correctly.

In other player_killed event you incorrectly initialize a string variable; you can only declare an array without a dimension length if you plan on initializing the variable when you instantiate it. Otherwise you need do something like new string[7].

Last edited by PreDominance; 08-09-2014 at 14:16.
PreDominance is offline
vadim7695
New Member
Join Date: Aug 2014
Old 08-10-2014 , 11:31   Re: Does not start the server
Reply With Quote #8

With a length of the array is clear, and that's how the HUD can not understand.

Last edited by vadim7695; 08-10-2014 at 11:32.
vadim7695 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:59.


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