PDA

Просмотр полной версии : [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

25GHz
01.08.2013, 22:36
"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 :)

Skel
02.08.2013, 12:39
void cmd_nick( char *param )

{

setLocalPlayerName(param); //name

disconnect( 1 );//disconect

restartGame();//restart games

cheat_state->_generic.rejoinTick = GetTickCount();

}

25GHz
03.08.2013, 07:33
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.

Skel
03.08.2013, 11:07
disconnect( 1 ); will timeout your connection. use 500.




i use "1" millisecond :D

25GHz
03.08.2013, 18:39
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. ;)

25GHz
05.08.2013, 00:15
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 :(