How to set string in dialog
#1

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;
}
Reply
#2

DIALOG_STYLE_INPUT and OnDialogResponse. Use the query in on dialog response
Reply
#3

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.
Reply
#4

Lemme switch to pc
Reply
#5

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Lemme switch to pc
ok i'll wait
Reply
#6

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(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 97)
    {
        if(
response)
        {
            new 
string[128];
            
format(stringsizeof(string), "You have set your Join Message to: %s"inputtext);
            
SendClientMessage(playerid, -1string);
            
format(PlayerInfo[playerid][personalmsg], 128"%s"inputtext);
            
//save player account
            
mysql_format(mysqlquerysizeof(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(mysqlquery);
            print(
query);
        }
    }
    return 
1;

Reply
#7

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(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 97)
    {
        if(
response)
        {
            new 
string[128];
            
format(stringsizeof(string), "You have set your Join Message to: %s"inputtext);
            
SendClientMessage(playerid, -1string);
            
format(PlayerInfo[playerid][personalmsg], 128"%s"inputtext);
            
//save player account
            
mysql_format(mysqlquerysizeof(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(mysqlquery);
            print(
query);
        }
    }
    return 
1;

It didn't do anything or set
Reply
#8

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?
Reply
#9

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
Reply
#10

I tested it and it's working, try returning 0 at the end of ondialogresponse instead of 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)