Query for dialog box + CMD
#1

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

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 messagesMESSAGE_QUEUE_SIZE ][ MESSAGE_MAX_LENGTH ];
new 
messagePointer 0// Current pointer in "messages" where new message will be stored

CMD:addtextplayeridargs ) {
    
// TODO message validation (var "args")
    
formatmessagesmessagePointer ], MESSAGE_MAX_LENGTHargs ); //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:seetextplayeridargs ) {
    new 
bufferMESSAGE_QUEUE_SIZE MESSAGE_MAX_LENGTH ]; // We'll store our dialog text here

    // Add messages before pointer in descending order
    
for ( new i=messagePointeri>-1i-- ) {
        if ( 
strlenmessages] ) != ) {
            
strcatbuffermessages] );
            
strcatbuffer"\n" );
        }
    }
    
    
// Add messages after pointer in descending order
    
if ( messagePointer != MESSAGE_QUEUE_SIZE ) {
        for ( new 
i=MESSAGE_QUEUE_SIZE 1i>messagePointeri-- ) {
            if ( 
strlenmessages] ) != ) {
                
strcatbuffermessages] );
                
strcatbuffer"\n" );
            }
        }
    }

    
// Show the dialog
    
ShowPlayerDialogplayeridDIALOG_SOMETHINGDIALOG_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
Reply
#3

I will try it soon. And let's see if your idea may work. As I have planned something yucky.
Reply
#4

Error at this point..
format( messages[ messagePointer ], MESSAGE_MAX_LENGTH, args );

error : error 035: argument type mismatch (argument 3)
Reply
#5

Bump..
Reply
#6

Bump.
Reply
#7

Change 'playerid, args' to 'playerid, args[]' in CMD:...
Reply
#8

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


Forum Jump:


Users browsing this thread: 1 Guest(s)