SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 07/10/2017, 06:58 AM   #1
AfiqIqbal
Big Clucker
 
AfiqIqbal's Avatar
 
Join Date: Feb 2016
Location: Pahang, Malaysia
Posts: 71
Reputation: 0
Question Dialog Inputtext

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

OnDialogResponse :
PHP Code:
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 :
Code:
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 (c) 1997-2006, ITB CompuPhase


2 Errors.
I've tried everything that I know, can you guys help me with this error?
__________________
"Starting from the bottom now we here."
AfiqIqbal is offline   Reply With Quote
Old 07/10/2017, 07:43 AM   #2
Steve57
Little Clucker
 
Join Date: Oct 2017
Posts: 7
Reputation: 1
Default Re: Dialog Inputtext

Add [s] after inputtext
Steve57 is offline   Reply With Quote
Old 07/10/2017, 07:47 AM   #3
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 821
Reputation: 125
Default Re: Dialog Inputtext

You okay Steve?

OP:

PHP Code:
if(inputtext[s] == '%')
{
     
inputtext[s] = '#';

__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester

Kane is online now   Reply With Quote
Old 07/10/2017, 08:31 AM   #4
Kraeror
Gangsta
 
Kraeror's Avatar
 
Join Date: Mar 2017
Location: Bulgaria
Posts: 534
Reputation: 19
Default Re: Dialog Inputtext

Try this:
PHP Code:
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;

Kraeror is offline   Reply With Quote
Old 07/10/2017, 08:36 AM   #5
AfiqIqbal
Big Clucker
 
AfiqIqbal's Avatar
 
Join Date: Feb 2016
Location: Pahang, Malaysia
Posts: 71
Reputation: 0
Default Re: Dialog Inputtext

Quote:
Originally Posted by Arthur Kane View Post
You okay Steve?

OP:

PHP Code:
if(inputtext[s] == '%')
{
     
inputtext[s] = '#';

Nahh .. it's not working mate.
__________________
"Starting from the bottom now we here."
AfiqIqbal is offline   Reply With Quote
Old 07/10/2017, 08:42 AM   #6
AfiqIqbal
Big Clucker
 
AfiqIqbal's Avatar
 
Join Date: Feb 2016
Location: Pahang, Malaysia
Posts: 71
Reputation: 0
Default Re: Dialog Inputtext

Quote:
Originally Posted by Kraeror View Post
Try this:
PHP Code:
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;

Code:
Code:
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 (c) 1997-2006, ITB CompuPhase


2 Errors.
__________________
"Starting from the bottom now we here."
AfiqIqbal is offline   Reply With Quote
Old 07/10/2017, 08:50 AM   #7
Kane
Gangsta
 
Kane's Avatar
 
Join Date: Sep 2012
Posts: 821
Reputation: 125
Default Re: Dialog Inputtext

What part didn't work? Did you get an error?
__________________
Los Santos Roleplay - Developer
@ls-rp.com

Former Beta Tester

Kane is online now   Reply With Quote
Old 07/10/2017, 09:00 AM   #8
FuNkYTheGreat
Huge Clucker
 
FuNkYTheGreat's Avatar
 
Join Date: Jun 2016
Location: Pakistan.
Posts: 270
Reputation: 124
Default Re: Dialog Inputtext

PHP Code:
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
FuNkYTheGreat is offline   Reply With Quote
Old 07/10/2017, 09:10 AM   #9
OsmanMalagic
Little Clucker
 
Join Date: Jul 2016
Location: EX-YU
Posts: 34
Reputation: 51
Default Re: Dialog Inputtext

PHP Code:
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;

OsmanMalagic is offline   Reply With Quote
Old 07/10/2017, 11:57 AM   #10
AfiqIqbal
Big Clucker
 
AfiqIqbal's Avatar
 
Join Date: Feb 2016
Location: Pahang, Malaysia
Posts: 71
Reputation: 0
Default Re: Dialog Inputtext

Quote:
Originally Posted by FuNkYTheGreat View Post
PHP Code:
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
__________________
"Starting from the bottom now we here."
AfiqIqbal is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dialog->inputtext Luicy. Scripting Help 1 04/12/2015 09:16 PM
Help with dialog inputtext AroseKhanNiazi Scripting Help 11 27/05/2014 02:46 PM
Inputtext Dialog help. rangerxxll Scripting Help 2 24/12/2013 10:32 PM
Inputtext Dialog Day_Jons Русский/Russian 5 19/11/2013 03:16 PM
InPutText Dialog Help Private200 Scripting Help 1 22/01/2013 09:03 PM


All times are GMT. The time now is 05:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.