|
Доброе время суток. Столкнулся с такой проблемой что если в данной функции отправить пустое значение string сервер крашиться. Но дело в том что я уже искал по форуму как исправить данную проблему но так точного ответа и не нашел но понял лишь то что это баг самого сампа. Можно ли как какой то метод что бы обойти этот баг и иногда при необходимости если отправляешь пустое значение string[] сервер не падал?
|
|
Не отправляй пустое сообщение, отправляй знак, в функции проверку на знак. Если указан знак то значит не было сообщения.
if(string[0] == '`')return 0; |
|
А зачем тебе использовать CallRemoteFunction? Ты передаешь данные из ФС в ГМ или наоборот?
|
#define SPD(%0) CallRemoteFunction("SPD","dddssss",%0)
public SPD(playerid, dialogid, style, caption[], info[], button1[], button2[]) {
Variable[playerid][pDialogID] = dialogid;
ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
return 1;
}
SPD(playerid, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay", "");
SPD(playerid, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay", "Okay2");
public SPD(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[]) {
new emptyString[] = "";
SPD(playerid, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay", emptyString);
public SPD(playerid, dialogid, style, const caption[], const info[], const button1[], const button2[] = "") {
Variable[playerid][pDialogID] = dialogid;
ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
return 1;
}
SPD(playerid, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay");
SPD(playerid, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay", "Okay2");
|
Ну начнем с того что правильнее будет:
pawn Код:
|
ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
error 035: argument type mismatch (argument 4)
public SPD(playerid, dialogid, style, caption[], info[], button1[], button2[] = "") {
error 059: function argument may not have a default value (variable "button2")
native ShowPlayerDialog(playerid, dialogid, style, caption[], info[], button1[], button2[]);
public OnPlayerConnect(playerid)
{
SPD(playerid, 1, 2, "", "", "", "");
return 1;
}
forward SPD(playerid, dialogid, style, caption[], info[], button1[], button2[]);
public SPD(playerid, dialogid, style, caption[], info[], button1[], button2[])
{
if(strlen(button2) < 1) ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, "");
else ShowPlayerDialog(playerid, dialogid, style, caption, info, button1, button2);
return 1;
}
#include <a_samp>
#define SPD(%0) CallRemoteFunction("SPDs","dddssss",%0)
forward SPDs(playerid, dialogid, style, caption[], info[], button1[]);
main(){}
public OnGameModeInit() {
SPD(1, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay");
SPD(1, 0, DIALOG_STYLE_MSGBOX, "Text", "Text", "Okay", "Okay2");
return 1;
}
public SPDs(playerid, dialogid, style, caption[], info[], button1[]) {
new button2[128];
if (numargs() == 7) {
for (new i; i < sizeof(button2); ++i) {
if(getarg(6, i)) button2[i] = getarg(6, i);
else break;
}
if (!strcmp("SPDs", button2)) strdel(button2, 0, sizeof(button2));//небольшой фикс, почему-то недостающим элементом передается имя колбека.
}
printf("-%d, %d, %d, %s, %s, %s, %s-\n", playerid, dialogid, style, caption, info, button1, button2);
return 1;
}
[00:43:51] -1, 0, 0, Text, Text, Okay, - [00:43:51] -1, 0, 0, Text, Text, Okay, Okay2-