Server Crash after Choose Team -
ChandraLouis - 23.03.2014
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DTEAMS)
{
if(!response) return ShowPlayerDialog(playerid, DTEAMS, DIALOG_STYLE_LIST, "Teams:", ""#EMB_USA"United States of America\n"#EMB_GERMANY"Germany", "Select", "");
if(response)
{
switch(listitem)
{
case 0:
{
gTeam[playerid] = ARMY_TEAM;
SetPlayerTeam(playerid, 0);
SetPlayerPos(playerid, 203.51, 1861.86, 13.14);
SetPlayerSkin(playerid, 287);
SetPlayerColor(playerid, A_COLOR);
SendClientMessage(playerid, COLOR_USA, "[Army]: You have chosen Army Team.");
SendClientMessageToAll(COLOR_USA, "[Army]: Player %s has joined Army Team !");
SpawnPlayer(playerid);
}
case 1:
{
gTeam[playerid] = TERROR_TEAM;
SetPlayerPos(playerid, 268.80, 1883.47, -30.09);
SetPlayerSkin(playerid, 16);
SetPlayerColor(playerid, T_COLOR);
SetPlayerTeam(playerid, 1);
SendClientMessage(playerid, COLOR_RED, "[Terrorist]: You have chosen Terrorist Team.");
SendClientMessageToAll(COLOR_RED, "[Terrorist]: Player %s has joined Terrorist Team !");
SpawnPlayer(playerid);
}
}
}
}
return 1;
}
Help
Re: Server Crash after Choose Team -
Equuuuin0X - 23.03.2014
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DTEAMS)
{
if(!response) return ShowPlayerDialog(playerid, DTEAMS, DIALOG_STYLE_LIST, "Teams:", ""#EMB_USA"United States of America\n"#EMB_GERMANY"Germany", "Select", "");
if(response)
{
switch(listitem)
{
case 0:
{
gTeam[playerid] = ARMY_TEAM;
SetPlayerTeam(playerid, 0);
SetPlayerPos(playerid, 203.51, 1861.86, 13.14);
SetPlayerSkin(playerid, 287);
SetPlayerColor(playerid, A_COLOR);
SendClientMessage(playerid, COLOR_USA, "[Army]: You have chosen Army Team.");
SendClientMessageToAll(COLOR_USA, "[Army]: Player %s has joined Army Team !",GetName(playerid));
SpawnPlayer(playerid);
}
case 1:
{
gTeam[playerid] = TERROR_TEAM;
SetPlayerPos(playerid, 268.80, 1883.47, -30.09);
SetPlayerSkin(playerid, 16);
SetPlayerColor(playerid, T_COLOR);
SetPlayerTeam(playerid, 1);
SendClientMessage(playerid, COLOR_RED, "[Terrorist]: You have chosen Terrorist Team.");
SendClientMessageToAll(COLOR_RED, "[Terrorist]: Player %s has joined Terrorist Team !",GetName(playerid));
SpawnPlayer(playerid);
}
}
}
}
return 1;
}
add this on bottom of the script
stock GetName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
return Name;
}
Re: Server Crash after Choose Team -
ChandraLouis - 23.03.2014
warning 202: number of arguments does not match definition
Re: Server Crash after Choose Team -
Equuuuin0X - 23.03.2014
line ?
Re: Server Crash after Choose Team -
Konstantinos - 23.03.2014
Quote:
Originally Posted by Equuuuin0X
line ?
|
pawn Код:
SendClientMessageToAll(COLOR_RED, "[Terrorist]: Player %s has joined Terrorist Team !",GetName(playerid));
Again, you need to use format:
https://sampwiki.blast.hk/wiki/Format
For server crashes, load crashdetect:
https://github.com/Zeex/samp-plugin-...es/tag/v4.13.1
Use debug info:
https://github.com/Zeex/samp-plugin-...ith-debug-info
Re-compile your scripts, start the server and select a team. After a server crash, post your server log. Note that it won't work if the crash is on the client.
Re: Server Crash after Choose Team -
ChandraLouis - 23.03.2014
(617) : warning 202: number of arguments does not match definition
(62

: warning 202: number of arguments does not match definition
pawn Код:
SendClientMessageToAll(COLOR_USA, "[Army]: Player %s has joined Army Team !",GetName(playerid));
SendClientMessageToAll(COLOR_RED, "[Army]: Player %s has joined Terrorist Team !",GetName(playerid));
Re: Server Crash after Choose Team -
Zeppo - 23.03.2014
SendClientMessageToAll has the parameters of: SendClientMessageToAll(playerid, Message); You need to format those then send them through SendclientMessageToAll.
Re: Server Crash after Choose Team -
Evocator - 23.03.2014
replace this
Код:
SendClientMessageToAll(COLOR_USA, "[Army]: Player %s has joined Army Team !",GetName(playerid));
with
pawn Код:
new string[128];
format(string, sizeof(string), "[Army]: Player %s has joined Army Team !",GetName(playerid));
SendClientMessageToAll(COLOR_USA, string);
and
Код:
SendClientMessageToAll(COLOR_RED, "[Terrorist]: Player %s has joined Terrorist Team !",GetName(playerid));
with
pawn Код:
new string1[128];
format(string1, sizeof(string1), "[Terrorist]: Player %s has joined Terrorist Team !",GetName(playerid));
SendClientMessageToAll(COLOR_USA, string1);
Re: Server Crash after Choose Team -
Equuuuin0X - 23.03.2014
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DTEAMS)
{
if(!response) return ShowPlayerDialog(playerid, DTEAMS, DIALOG_STYLE_LIST, "Teams:", ""#EMB_USA"United States of America\n"#EMB_GERMANY"Germany", "Select", "");
if(response)
{
switch(listitem)
{
case 0:
{
new JoinMessage[128];
gTeam[playerid] = ARMY_TEAM;
SetPlayerTeam(playerid, 0);
SetPlayerPos(playerid, 203.51, 1861.86, 13.14);
SetPlayerSkin(playerid, 287);
SetPlayerColor(playerid, A_COLOR);
SendClientMessage(playerid, COLOR_USA, "[Army]: You have chosen Army Team.");
format(JoinMessage, sizeof(JoinMessage), "Player%s(%d) has joined the Army Team", GetName);
SendClientMessageToAll(COLOR_LIGHTBLUE, JoinMessage);
SpawnPlayer(playerid);
}
case 1:
{
new JoinMessage[128];
gTeam[playerid] = TERROR_TEAM;
SetPlayerPos(playerid, 268.80, 1883.47, -30.09);
SetPlayerSkin(playerid, 16);
SetPlayerColor(playerid, T_COLOR);
SetPlayerTeam(playerid, 1);
SendClientMessage(playerid, COLOR_RED, "[Terrorist]: You have chosen Terrorist Team.");
format(JoinMessage, sizeof(JoinMessage), "Player%s(%d) has joined the Terrorist Team", GetName);
SendClientMessageToAll(COLOR_LIGHTBLUE, JoinMessage);
SpawnPlayer(playerid);
}
}
}
}
return 1;
}
add this on bottom of the script
stock GetName(playerid)
{
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
return Name;
}
Re: Server Crash after Choose Team -
Konstantinos - 23.03.2014
I just remembered why it crashes your server. The lines that crashes the server are:
pawn Код:
SendClientMessageToAll(COLOR_USA, "[Army]: Player %s has joined Army Team !");
// AND:
SendClientMessageToAll(COLOR_RED, "[Terrorist]: Player %s has joined Terrorist Team !");
Using %s in SendClientMessage/SendClientMessageToAll functions will result in a crash. However the solution has been mentioned already 3 times in the above posts.