Dialog Inputtext
#1

I was trying to fix a bug when player put "%" symbol in a dialog it will crash the server

OnDialogResponse :
PHP код:
if(dialogid == DIALOG_STREAMBOX)
    {
        new 
string[MAX_PLAYERS];
        if(
response)
        {
            for(new 
0MAX_PLAYERSi++)
               {
                   for(new 
sstrlen(inputtext); s++)
                   {
                    if(
inputtext == "%")
                    {
                         
inputtext "#";
                    }
                    
format(stringsizeof(string), "[DEEJAY] %s have play a song from | Url: %s"IsPlayerName(playerid), inputtext);
                    
SendClientMessage(i0x00FFCCAAstring);
                       
StopAudioStreamForPlayer(i);
                      
SendClientMessage(i, -1"================================");
                    
PlayAudioStreamForPlayer(iinputtext);
                     
SendClientMessage(i, -1"================================");
                      
SendClientMessage(i0x00FF99AA"Use /stopmusic if you want to stop the song from playing");
                }
              }
        }
        return 
1;
    } 
But when I was trying to compile the script it says :
Код:
C:\Users\USER\Desktop\Server Scripts\GM\MYGM.pwn(2131) : error 033: array must be indexed (variable "inputtext")
C:\Users\USER\Desktop\Server Scripts\GM\MYGM.pwn(2133) : error 046: unknown array size (variable "inputtext")
C:\Users\USER\Desktop\Server Scripts\GM\MYGM.pwn(2133) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
I've tried everything that I know, can you guys help me with this error?
Reply
#2

Add [s] after inputtext
Reply
#3

You okay Steve?

OP:

PHP код:
if(inputtext[s] == '%')
{
     
inputtext[s] = '#';

Reply
#4

Try this:
PHP код:
if(dialogid == DIALOG_STREAMBOX)
{
    new 
string[MAX_PLAYERS];
    if(
response)
    {
        for(new 
0MAX_PLAYERSi++)
        {
            if(
strlen(inputtext) == "%")
            {
                 
strlen(inputtext) = "#";
            }
            
format(stringsizeof(string), "[DEEJAY] %s have play a song from | Url: %s"IsPlayerName(playerid), inputtext);
            
SendClientMessage(i0x00FFCCAAstring);
            
StopAudioStreamForPlayer(i);
            
SendClientMessage(i, -1"================================");
            
PlayAudioStreamForPlayer(iinputtext);
            
SendClientMessage(i, -1"================================");
            
SendClientMessage(i0x00FF99AA"Use /stopmusic if you want to stop the song from playing");
          }
    }
    return 
1;

Reply
#5

Quote:
Originally Posted by Arthur Kane
Посмотреть сообщение
You okay Steve?

OP:

PHP код:
if(inputtext[s] == '%')
{
     
inputtext[s] = '#';

Nahh .. it's not working mate.
Reply
#6

Quote:
Originally Posted by Kraeror
Посмотреть сообщение
Try this:
PHP код:
if(dialogid == DIALOG_STREAMBOX)
{
    new 
string[MAX_PLAYERS];
    if(
response)
    {
        for(new 
0MAX_PLAYERSi++)
        {
            if(
strlen(inputtext) == "%")
            {
                 
strlen(inputtext) = "#";
            }
            
format(stringsizeof(string), "[DEEJAY] %s have play a song from | Url: %s"IsPlayerName(playerid), inputtext);
            
SendClientMessage(i0x00FFCCAAstring);
            
StopAudioStreamForPlayer(i);
            
SendClientMessage(i, -1"================================");
            
PlayAudioStreamForPlayer(iinputtext);
            
SendClientMessage(i, -1"================================");
            
SendClientMessage(i0x00FF99AA"Use /stopmusic if you want to stop the song from playing");
          }
    }
    return 
1;

Код:
Код:
C:\Users\USER\Desktop\Server Scripts\GM\MYGM(2131) : error 033: array must be indexed (variable "inputtext")
C:\Users\USER\Desktop\Server Scripts\GM\MYGM(2133) : error 022: must be lvalue (non-constant)
C:\Users\USER\Desktop\Server Scripts\GM\MYGM(2133) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#7

What part didn't work? Did you get an error?
Reply
#8

PHP код:
if(dialogid == DIALOG_STREAMBOX)
    {
        new 
string[MAX_PLAYERS];
        if(
response)
        {
            for(new 
0MAX_PLAYERSi++)
               {
                   
format(string,sizeof(string),"%s",str_replace("%""#",inputtext));
                       
StopAudioStreamForPlayer(i);
                      
PlayAudioStreamForPlayer(istring);
                      
format(stringsizeof(string), "[DEEJAY] %s have play a song from | Url: %s"IsPlayerName(playerid), inputtext);
                    
SendClientMessage(i0x00FFCCAAstring);
                      
SendClientMessage(i, -1"================================");
                     
SendClientMessage(i, -1"================================");
                      
SendClientMessage(i0x00FF99AA"Use /stopmusic if you want to stop the song from playing");
                }
              }
        }
        return 
1;
    } 
and for the str_replace function use this one !
https://github.com/GRGServer/SAMP/bl...tr_replace.inc
Reply
#9

PHP код:
if(dialogid == DIALOG_STREAMBOX)
{
    new 
string[MAX_PLAYERS];
     if(
response)
      {
         if(
strfind(inputtext"#"true) != -1) return SCM(playeridCOLOR_GREY"Not supported!");
         foreach(
Playeri)
         {
             
format(stringsizeof(string), "[DEEJAY] %s have play a song from | Url: %s"IsPlayerName(i), inputtext);
              
SendClientMessage(i0x00FFCCAAstring);
               
StopAudioStreamForPlayer(i);
            
PlayAudioStreamForPlayer(iinputtext);
            
SendClientMessage(i, -1"================================");
             
SendClientMessage(i, -1"================================");
              
SendClientMessage(i0x00FF99AA"Use /stopmusic if you want to stop the song from playing");
        }
    }
    return 
1;

Reply
#10

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
PHP код:
if(dialogid == DIALOG_STREAMBOX)
    {
        new 
string[MAX_PLAYERS];
        if(
response)
        {
            for(new 
0MAX_PLAYERSi++)
               {
                   
format(string,sizeof(string),"%s",str_replace("%""#",inputtext));
                       
StopAudioStreamForPlayer(i);
                      
PlayAudioStreamForPlayer(istring);
                      
format(stringsizeof(string), "[DEEJAY] %s have play a song from | Url: %s"IsPlayerName(playerid), inputtext);
                    
SendClientMessage(i0x00FFCCAAstring);
                      
SendClientMessage(i, -1"================================");
                     
SendClientMessage(i, -1"================================");
                      
SendClientMessage(i0x00FF99AA"Use /stopmusic if you want to stop the song from playing");
                }
              }
        }
        return 
1;
    } 
and for the str_replace function use this one !
https://github.com/GRGServer/SAMP/bl...tr_replace.inc
Tested it, still crash my server when I type % into the dialog
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)