Просмотр полной версии : [mod_sa help] Nick Changer
Active[X]
01.08.2013, 20:22
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
"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); ;)
Active[X]
01.08.2013, 22:44
Thanks :)
void cmd_nick( char *param )
{
setLocalPlayerName(param); //name
disconnect( 1 );//disconect
restartGame();//restart games
cheat_state->_generic.rejoinTick = GetTickCount();
}
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.
disconnect( 1 ); will timeout your connection. use 500.
i use "1" millisecond :D
i use "1" millisecond :D
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. ;)
here, look at this function at sobeit:
http://puu.sh/3TJ20 (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVEoyMA)
now look at this function at samp dll:
timing out(losting connection):
http://puu.sh/3TIxH (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVEl4SA)
http://puu.sh/3TICF (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVElDRg)
leaving:
http://puu.sh/3TISt (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVElTdA)
so, dec: 500(hex: 0x01F4) will corectly close connection, any other value(default is 0) will timeout the connection. ;)
UnknownPlayer
05.08.2013, 11:38
here, look at this function at sobeit:
http://puu.sh/3TJ20 (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVEoyMA)
now look at this function at samp dll:
timing out(losting connection):
http://puu.sh/3TIxH (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVEl4SA)
http://puu.sh/3TICF (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVElDRg)
leaving:
http://puu.sh/3TISt (https://www.blast.hk/redirect/aHR0cDovL3B1dS5zaC8zVElTdA)
so, dec: 500(hex: 0x01F4) will corectly close connection, any other value(default is 0) will timeout the connection. ;)
Okey :(
vBulletin® v3.8.14, Copyright ©2000-2026, vBulletin Solutions, Inc. Перевод: zCarot