HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   ANTICHAT > ПРОГРАММИРОВАНИЕ > С/С++, C#, Rust, Swift, Go, Java, Perl, Ruby
   
Ответ
 
Опции темы Поиск в этой теме Опции просмотра

  #1  
Старый 01.08.2013, 20:22
Active[X]
Познающий
Регистрация: 20.05.2013
Сообщений: 35
С нами: 6832420

Репутация: 0
По умолчанию

Hi, I tried nick changer command and compiling is ok, but when I testing on SAMP server, my game crashed... Why? please can you help me? Here is code

Код:





Код:
void cmd_nick ( char *param )
{
    if ( !strlen( param ) )
    {
        addMessageToChatWindow( "USAGE: /nick " );
        return;
    }
 
    else if ( g_SAMP == NULL )
        return;
 
    else if ( strlen( param )  ALLOWED_PLAYER_NAME_LENGTH )
    {
        addMessageToChatWindow( "USAGE: /nick " );
        return;
    }
 
    setLocalPlayerName( (char *)atoi( param ) );
    restartGame();
    disconnect( 500 );
    cheat_state_text( "Rejoining in %d seconds...", set.rejoin_delay / 1000 );
    cheat_state->_generic.rejoinTick = GetTickCount();
}




init_samp_chat_cmds()

Код:





Код:
addClientCommand( "nick", (char)cmd_nick );




Thanks
 
Ответить с цитированием

  #2  
Старый 01.08.2013, 22:36
25GHz
Новичок
Регистрация: 23.03.2013
Сообщений: 11
С нами: 6915896

Репутация: 0
По умолчанию

"param" is a "char *" just like "setLocalPlayerName" function argument, so you don't need to convert to int and then to "char *" again.

so, just...

setLocalPlayerName(param);

and the second argument of "addClientCommand" is a int, so you must not convert that void to char, but do it as an int, like this:

addClientCommand("nick", (int)cmd_nick);
 
Ответить с цитированием

  #3  
Старый 01.08.2013, 22:44
Active[X]
Познающий
Регистрация: 20.05.2013
Сообщений: 35
С нами: 6832420

Репутация: 0
По умолчанию

Thanks
 
Ответить с цитированием

  #4  
Старый 02.08.2013, 12:39
Skel
Познающий
Регистрация: 31.03.2013
Сообщений: 92
С нами: 6903095

Репутация: 0
По умолчанию

void cmd_nick( char *param )

{

setLocalPlayerName(param); //name

disconnect( 1 );//disconect

restartGame();//restart games

cheat_state->_generic.rejoinTick = GetTickCount();

}
 
Ответить с цитированием

  #5  
Старый 03.08.2013, 07:33
25GHz
Новичок
Регистрация: 23.03.2013
Сообщений: 11
С нами: 6915896

Репутация: 0
По умолчанию

Цитата:
Сообщение от Skel  

void cmd_nick( char *param )
{
setLocalPlayerName(param); //name
disconnect( 1 );//disconect
restartGame();//restart games
cheat_state->_generic.rejoinTick = GetTickCount();
}
disconnect( 1 ); will timeout your connection. use 500.
 
Ответить с цитированием

  #6  
Старый 03.08.2013, 11:07
Skel
Познающий
Регистрация: 31.03.2013
Сообщений: 92
С нами: 6903095

Репутация: 0
По умолчанию

Цитата:
Сообщение от 25GHz  

disconnect( 1 ); will timeout your connection. use 500.

i use "1" millisecond
 
Ответить с цитированием

  #7  
Старый 03.08.2013, 18:39
25GHz
Новичок
Регистрация: 23.03.2013
Сообщений: 11
С нами: 6915896

Репутация: 0
По умолчанию

Цитата:
Сообщение от Skel  

i use "1" millisecond
the value of this function(possibly) isn't about "timing", but the value to push, that represent the function reason, so if you set it to 1, you will not disconnect properly from server, and then, the connection will timeout.
 
Ответить с цитированием

  #8  
Старый 05.08.2013, 00:15
25GHz
Новичок
Регистрация: 23.03.2013
Сообщений: 11
С нами: 6915896

Репутация: 0
По умолчанию

Цитата:
Сообщение от UnknownPlayer  
here, look at this function at sobeit:

http://puu.sh/3TJ20

now look at this function at samp dll:

timing out(losting connection):

http://puu.sh/3TIxH

http://puu.sh/3TICF

leaving:

http://puu.sh/3TISt

so, dec: 500(hex: 0x01F4) will corectly close connection, any other value(default is 0) will timeout the connection.
 
Ответить с цитированием

  #9  
Старый 05.08.2013, 11:38
UnknownPlayer
Познающий
Регистрация: 04.08.2013
Сообщений: 33
С нами: 6722028

Репутация: 0
По умолчанию

Цитата:
Сообщение от 25GHz  

here, look at this function at sobeit:
http://puu.sh/3TJ20

now look at this function at samp dll:

timing out(losting connection):
http://puu.sh/3TIxH
http://puu.sh/3TICF

leaving:
http://puu.sh/3TISt

so, dec: 500(hex: 0x01F4) will corectly close connection, any other value(default is 0) will timeout the connection.
Okey
 
Ответить с цитированием
Ответ



Предыдущая тема Следующая тема

Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.