[mod_sa help] Nick Changer

Статус
В этой теме нельзя размещать новые ответы.

Active[X]

Новичок
Автор темы
35
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 <your new nick>" );
        return;
    }
 
    else if ( g_SAMP == NULL )
        return;
 
    else if ( strlen( param ) < 3 || strlen( param ) > ALLOWED_PLAYER_NAME_LENGTH )
    {
        addMessageToChatWindow( "USAGE: /nick <3 - 20 SA-MP allowed characters>" );
        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
 

25GHz

Новичок
11
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); ;)
 

Skel

Потрачен
92
3
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
void cmd_nick( char *param )
{
setLocalPlayerName(param); //name
disconnect( 1 );//disconect
restartGame();//restart games
cheat_state->_generic.rejoinTick = GetTickCount();
}
 
Статус
В этой теме нельзя размещать новые ответы.