Query for dialog box + CMD -
fuckingcruse - 19.12.2015
Hey , think that i have made a cmd , /addtext.
How do i add it to the /seetext ? the text that was enter in /addtext.
Also , if i typed something in /addtext and other player too added something in /addtext and i typed /seetext , how can i display both the msgs in /seetext . ( DIALOG BOX ) explain it anyone if you are free at the moment. thanks
Re: Query for dialog box + CMD -
prineside - 19.12.2015
PHP код:
#define MESSAGE_QUEUE_SIZE (10) // Number of last messages that will be stored and listed in dialog
#define MESSAGE_MAX_LENGTH (128) // Max. length of one messsage
new messages[ MESSAGE_QUEUE_SIZE ][ MESSAGE_MAX_LENGTH ];
new messagePointer = 0; // Current pointer in "messages" where new message will be stored
CMD:addtext( playerid, args ) {
// TODO message validation (var "args")
format( messages[ messagePointer ], MESSAGE_MAX_LENGTH, args ); //Store the message
messagePointer++; // Set the pointer to the next index of the array so the next message will be written there
if ( messagePointer == MESSAGE_QUEUE_SIZE ) { // If pointer reached the end of the array
messagePointer = 0; // Go to start of the array
}
}
CMD:seetext( playerid, args ) {
new buffer[ MESSAGE_QUEUE_SIZE * MESSAGE_MAX_LENGTH ]; // We'll store our dialog text here
// Add messages before pointer in descending order
for ( new i=messagePointer; i>-1; i-- ) {
if ( strlen( messages[ i ] ) != 0 ) {
strcat( buffer, messages[ i ] );
strcat( buffer, "\n" );
}
}
// Add messages after pointer in descending order
if ( messagePointer != MESSAGE_QUEUE_SIZE - 1 ) {
for ( new i=MESSAGE_QUEUE_SIZE - 1; i>messagePointer; i-- ) {
if ( strlen( messages[ i ] ) != 0 ) {
strcat( buffer, messages[ i ] );
strcat( buffer, "\n" );
}
}
}
// Show the dialog
ShowPlayerDialog( playerid, DIALOG_SOMETHING, DIALOG_STYLE_..., "Messages", buffer, "Close", "" );
}
It works like that (example):
- Player calls /addtext and his message is stored into messages[ 0 ], pointer is 1 now
- Another player calls /addtext and his message is stored into messages[ 1 ], pointer is 2 now
- ...
- Another player calls /addtext and his message is stored into messages[ 9 ], pointer is 0 now
- Another player calls /addtext and his message is stored into messages[ 0 ], pointer is 1 now // Rewrite the oldest message
- Another player calls /addtext and his message is stored into messages[ 1 ], pointer is 2 now
- Someone call /seetext, the script concatenates these messages (2, 1, 0, 9, 8, 7, 6, 5, 4, 3) and list them in dialog
That's the idea
Re: Query for dialog box + CMD -
fuckingcruse - 20.12.2015
I will try it soon. And let's see if your idea may work. As I have planned something yucky.
Re: Query for dialog box + CMD -
fuckingcruse - 23.01.2016
Error at this point..
format( messages[ messagePointer ], MESSAGE_MAX_LENGTH, args );
error : error 035: argument type mismatch (argument 3)
Re: Query for dialog box + CMD -
fuckingcruse - 24.01.2016
Bump..
Re: Query for dialog box + CMD -
fuckingcruse - 27.01.2016
Bump.
Re: Query for dialog box + CMD -
Jefff - 27.01.2016
Change 'playerid, args' to 'playerid, args[]' in CMD:...
Re: Query for dialog box + CMD -
fuckingcruse - 29.01.2016
Its working and I have tried something but it didn't work. I wanted like /addtext must show a dialog to enter the text. I tried but it didn't work.