How to set string in dialog -
DerickClark - 26.01.2017
How can i make this command a dialog box when you type inside of it that code will be set and save in database.
Код:
CMD:setmessage(playerid,params[])
{
new Message[128], string[128], query[128];
if(sscanf(params,"s[128]", Message)) return SendClientMessage(playerid, -1, "Usage: /setmessage [custom_message]");
format(string, sizeof(string), "You have set your Join Message to: %s", Message);
SendClientMessage(playerid, -1, string);
format(PlayerInfo[playerid][personalmsg], 128, "%s", Message);
//save player account
mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `SCORE`= %i , `Admin` = '%i' , `personalmsg` = '%e' WHERE `ID` = '%d'", GetPlayerScore(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][personalmsg], PlayerInfo[playerid][ID]);
mysql_tquery(mysql, query, "", "");
print(query);
return 1;
}
Re: How to set string in dialog -
StrikerZ - 26.01.2017
DIALOG_STYLE_INPUT and OnDialogResponse. Use the query in on dialog response
Re: How to set string in dialog -
DerickClark - 26.01.2017
Quote:
Originally Posted by Sunehildeep
DIALOG_STYLE_INPUT and OnDialogResponse. Use the query in on dialog response
|
can you post the code. my code wrong.
Re: How to set string in dialog -
StrikerZ - 26.01.2017
Lemme switch to pc
Re: How to set string in dialog -
DerickClark - 26.01.2017
Quote:
Originally Posted by Sunehildeep
Lemme switch to pc
|
ok i'll wait
Re: How to set string in dialog -
StrikerZ - 26.01.2017
Here you go.
PHP код:
CMD:setmessage(playerid,params[])
{
ShowPlayerDialog(playerid,97,DIALOG_STYLE_INPUT,"Set Message","Enter the new join message you want to set","Set","Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 97)
{
if(response)
{
new string[128];
format(string, sizeof(string), "You have set your Join Message to: %s", inputtext);
SendClientMessage(playerid, -1, string);
format(PlayerInfo[playerid][personalmsg], 128, "%s", inputtext);
//save player account
mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `SCORE`= %i , `Admin` = '%i' , `personalmsg` = '%e' WHERE `ID` = '%d'", GetPlayerScore(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][personalmsg], PlayerInfo[playerid][ID]);
mysql_query(mysql, query);
print(query);
}
}
return 1;
}
Re: How to set string in dialog -
DerickClark - 26.01.2017
Quote:
Originally Posted by Sunehildeep
Here you go.
PHP код:
CMD:setmessage(playerid,params[])
{
ShowPlayerDialog(playerid,97,DIALOG_STYLE_INPUT,"Set Message","Enter the new join message you want to set","Set","Cancel");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 97)
{
if(response)
{
new string[128];
format(string, sizeof(string), "You have set your Join Message to: %s", inputtext);
SendClientMessage(playerid, -1, string);
format(PlayerInfo[playerid][personalmsg], 128, "%s", inputtext);
//save player account
mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `SCORE`= %i , `Admin` = '%i' , `personalmsg` = '%e' WHERE `ID` = '%d'", GetPlayerScore(playerid), PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][personalmsg], PlayerInfo[playerid][ID]);
mysql_query(mysql, query);
print(query);
}
}
return 1;
}
|
It didn't do anything or set
Re: How to set string in dialog -
StrikerZ - 26.01.2017
Quote:
Originally Posted by DerickClark
It didn't do anything or set
|
Are you using it in a FS or gamemode?
And did the dialog appeared?
Re: How to set string in dialog -
DerickClark - 26.01.2017
Quote:
Originally Posted by Sunehildeep
Are you using it in a FS or gamemode?
And did the dialog appeared?
|
Gamemode, yes dialog appeared. SendClientMessage don't show or set message
Re: How to set string in dialog -
StrikerZ - 26.01.2017
I tested it and it's working, try returning 0 at the end of ondialogresponse instead of 1